本文整理汇总了Python中astroquery.vizier.Vizier.query_region方法的典型用法代码示例。如果您正苦于以下问题:Python Vizier.query_region方法的具体用法?Python Vizier.query_region怎么用?Python Vizier.query_region使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类astroquery.vizier.Vizier
的用法示例。
在下文中一共展示了Vizier.query_region方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: galaxies_in_box
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_region [as 别名]
def galaxies_in_box(center, ra_span, dec_span):
"""
This function ...
:param center:
:param ra_span:
:param dec_span:
:return:
"""
# Initialize a list to contain the galaxies
names = []
# Other way ?? Much more results ?
#ra_radius = 0.5 * ra_span.value
#dec_radius = 0.5 * dec_span.value
#radius = math.sqrt(ra_radius**2 + dec_radius**2)
#result_table = Ned.query_region(center, radius=radius)
# Create a new Vizier object and set the row limit to -1 (unlimited)
viz = Vizier(keywords=["galaxies", "optical"])
viz.ROW_LIMIT = -1
# Debugging
log.debug("Querying the HYPERLEDA catalog ...")
# Query Vizier and obtain the resulting table
result = viz.query_region(center.to_astropy(), width=ra_span, height=dec_span, catalog=["VII/237"])
# I noticed something strange happening once; where there were no entries in the result,
# with the following parameters:
# center = (149.07614359, 69.24847936)
# ra_span = 1.600000128 deg
# dec_span = 1.3966667784 deg
# catalog = ["VII/237"]
# When ra_span was only slightly changed (e.g. change the last digit to a '7'), output was normal
# Thus, it seems that the query goes wrong with specific values of the width (and/or height), in which
# case changing the value very slightly resolves the problem...
# I am baffled by this and I see no reasonable explanation.
if len(result) == 0:
ra_span *= 1.0 + 1e-5
result = viz.query_region(center.to_astropy(), width=ra_span, height=dec_span, catalog=["VII/237"])
table = result[0]
# Loop over the rows in the table
for entry in table:
name = "PGC " + str(entry["PGC"])
coordinate = SkyCoordinate(ra=entry["_RAJ2000"], dec=entry["_DEJ2000"], unit="deg", frame="fk5")
namepluscoordinate = (name, coordinate)
names.append(namepluscoordinate)
# Return the list of galaxies
return names
示例2: query_nvss
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_region [as 别名]
def query_nvss(options, ra0, dec0, s=">0.0", proj='SIN'):
'''
query_nvss: module which queries the NVSS using the Vizier protocol.
inputs: ra0, dec0, s="<20"
ra0 = the central ra in degrees
dec0 = the central dec in degrees
s = the flux cutoff
returns L, M (relative coordinates in degrees), N (number of sources), S (1.4GHz Flux
Density in mJy)
'''
v = Vizier(column_filters={"S1.4":s})
v.ROW_LIMIT = 10000
result = v.query_region(coord.SkyCoord(ra=ra0, dec=dec0, unit=(u.deg, u.deg), frame='icrs'),
radius=Angle(1, "deg"), catalog='NVSS')
ra = result[0]['_RAJ2000']
dec = result[0]['_DEJ2000']
N = len(result[0])
if proj.upper()=='SIN':
L = (ra-ra0)*pl.cos(dec*deg2rad)
M = dec-dec0
if proj.upper()=='NCP':
L = 57.2957795*pl.cos(deg2rad*dec)*pl.sin(deg2rad*(ra-ra0))
M = 57.2957795*(pl.cos(deg2rad*dec0) - pl.cos(deg2rad*dec)*pl.cos(deg2rad*(ra-ra0)))/pl.sin(deg2rad*dec0)
S = result[0]['S1.4']
ascii.write(result[0], options.outfile+'.dat', format='tab')
ann_writer(options, result[0])
return L, M, N, S
示例3: catalog_search
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_region [as 别名]
def catalog_search(frame_wcs, shape, desired_catalog,
ra_column='RAJ2000',
dec_column='DEJ2000',
radius=0.5,
clip_by_frame=True):
"""
Description: This function takes coordinate data from an image and a
catalog name and returns the positions of those stars.
Preconditions:frame_wcs is a WCS object, shape is tuple, list or array of
numerical values, desired_catalog is a string and radius is a numerical
value.
Postconditions:
"""
rad = radius * units.deg
# Find the center of the frame
center_coord = frame_wcs.all_pix2world([[shape[1] / 2, shape[0] / 2]], 0)
center = SkyCoord(center_coord, frame='icrs', unit='deg')
# Get catalog via cone search
Vizier.ROW_LIMIT = -1 # Set row_limit to have no limit
cat = Vizier.query_region(center, radius=rad, catalog=desired_catalog)
# Vizier always returns list even if there is only one element. Grab that
# element.
cat = cat[0]
cat_coords = SkyCoord(ra=cat[ra_column], dec=cat[dec_column])
if clip_by_frame:
in_fov = in_frame(frame_wcs, cat_coords)
else:
in_fov = np.ones([len(cat_coords)], dtype=np.bool)
x, y = frame_wcs.all_world2pix(cat_coords.ra, cat_coords.dec, 0)
return (cat[in_fov], x[in_fov], y[in_fov])
示例4: selected_catalog
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_region [as 别名]
def selected_catalog( ra, dec, FOV_base, FOV_height, catalog ):
'''
Vizier.query_region in selected FoV. The hist of the apparent blue magnitude
and the sky coordinates are provided if GWGC catalog is selected
'''
from astroquery.vizier import Vizier
import astropy.coordinates as coord
import astropy.units as u
import aladinSAMP
# setting rows limit
Vizier.ROW_LIMIT = None
# no reduced query size (rq)
reduce_query_size = 1
FOV_base_reduced, FOV_height_reduced = FOV_base * reduce_query_size, FOV_height * reduce_query_size
FOV_base_str, FOV_height_str = str( FOV_base_reduced ) + 'd', str( FOV_height_reduced ) + 'd'
result = Vizier.query_region(coord.SkyCoord(ra = ra, dec = dec, unit = (u.deg, u.deg), frame='icrs'),
width = FOV_height_str, height = FOV_base_str, catalog = [ catalog ])
result.pprint()
print result.values()
示例5: panstarrs_query
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_region [as 别名]
def panstarrs_query(ra_deg, dec_deg, rad_deg, maxmag=20,
maxsources=10000):
"""
Query PanSTARRS @ VizieR using astroquery.vizier
:param ra_deg: RA in degrees
:param dec_deg: Declination in degrees
:param rad_deg: field radius in degrees
:param maxmag: upper limit G magnitude (optional)
:param maxsources: maximum number of sources
:return: astropy.table object
"""
vquery = Vizier(columns=['objID', 'RAJ2000', 'DEJ2000',
'e_RAJ2000', 'e_DEJ2000',
'gmag', 'e_gmag',
'rmag', 'e_rmag',
'imag', 'e_imag',
'zmag', 'e_zmag',
'ymag', 'e_ymag'],
column_filters={"gmag":
("<%f" % maxmag)},
row_limit=maxsources)
field = coord.SkyCoord(ra=ra_deg, dec=dec_deg,
unit=(u.deg, u.deg),
frame='icrs')
return vquery.query_region(field,
width=("%fd" % rad_deg),
catalog="II/349/ps1")[0]
示例6: query_vizier
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_region [as 别名]
def query_vizier(self, catalog='APASS'):
'''
Uses the astroquery environment to get the data from Vizier.
Possible selection of catalogues:
'''
result = Vizier.query_region("%.6f %.6f"%(self.ra, self.dec), radius=Angle(self.rad, "deg"), \
catalog=catalog) #column_filters={"rmag":">%s"%self.minmag,"rmag":"<%s"%self.maxmag }
return result[0]
示例7: showVizierCatalogs
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_region [as 别名]
def showVizierCatalogs(self):
(ra, dec) = self.centre
from astroquery.vizier import Vizier
Vizier.ROW_LIMIT = 50
from astropy import coordinates
from astropy import units as u
c = coordinates.SkyCoord(ra,dec,unit=('deg','deg'),frame='icrs')
skyHeight= coordinates.Angle(self.raRange, unit = u.deg)
results = Vizier.query_region(coordinates = c, radius= 1.0 * u.deg)
print results
示例8: query_circle
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_region [as 别名]
def query_circle(self, ra, dec, radius, catalog):
"""Vizier.query_region in a circle FoV."""
Vizier.ROW_LIMIT = None
radius_str = str(radius) + "d"
query_result = Vizier.query_region(
SkyCoord(ra=ra, dec=dec, unit=(u.deg, u.deg), frame="icrs"), radius=radius_str, catalog=[catalog]
)
return query_result
示例9: serendipitous_variablestars
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_region [as 别名]
def serendipitous_variablestars(catalogs, display=True):
"""match catalogs with VSX catalog using astroquery.Vizier
"""
if display:
print('# match frames with variable star database... ', end=' ',
flush=True)
logging.info('match frames with variable star database')
# derive center and radius of field of view of all images
ra_deg, dec_deg, rad_deg = skycenter(catalogs)
logging.info('FoV center (%.7f/%+.7f) and radius (%.2f deg) derived' %
(ra_deg, dec_deg, rad_deg))
# derive observation midtime of sequence
midtime = np.average([cat.obstime[0] for cat in catalogs])
# setup Vizier query
# note: column filters uses original Vizier column names
# -> green column names in Vizier
logging.info(('query Vizier for VSX at %7.3f/%+8.3f in '
+ 'a %.2f deg radius') %
(ra_deg, dec_deg, rad_deg))
field = coord.SkyCoord(ra=ra_deg, dec=dec_deg, unit=(u.deg, u.deg),
frame='icrs')
vquery = Vizier(columns=['Name', 'RAJ2000', 'DEJ2000'])
try:
data = vquery.query_region(field,
width=("%fd" % rad_deg),
catalog="B/vsx/vsx")[0]
except IndexError:
if display:
print('no data available from VSX')
logging.error('no data available from VSX')
return []
objects = []
for cat_idx, cat in enumerate(catalogs):
for star in data:
objects.append({'ident': star['Name'],
'obsdate.jd': cat.obstime[0],
'cat_idx': cat_idx,
'ra_deg': star['RAJ2000'],
'dec_deg': star['DEJ2000']})
if display:
print(len(objects)/len(catalogs), 'variable stars found')
return objects
示例10: query_box
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_region [as 别名]
def query_box(self, ra, dec, base, height, catalog):
"""Vizier.query_region in a square/rectangular FoV."""
Vizier.ROW_LIMIT = None
base_str, height_str = str(base) + "d", str(height) + "d"
query_result = Vizier.query_region(
SkyCoord(ra=ra, dec=dec, unit=(u.deg, u.deg), frame="icrs"),
width=height_str,
height=base_str,
catalog=[catalog],
)
return query_result
示例11: fetch_objects_in_box
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_region [as 别名]
def fetch_objects_in_box(box, catalog, keywords, radius, limit=None, column_filters=None):
"""
This function ...
:param box:
:param catalog:
:param keywords:
:param radius:
:param limit:
:param column_filters:
:return:
"""
# Define the center coordinate for the box
coordinate = SkyCoordinate(ra=box[0], dec=box[1], unit="deg", frame="fk5") # frame: icrs, fk5... ?
# Make a Vizier object
if column_filters is None:
viz = Vizier(columns=['_RAJ2000', '_DEJ2000','B-V', 'Vmag', 'Plx'], keywords=keywords)
else:
viz = Vizier(columns=['_RAJ2000', '_DEJ2000','B-V', 'Vmag', 'Plx'], column_filters=column_filters, keywords=keywords)
# No limit on the number of entries
viz.ROW_LIMIT = limit if limit is not None else -1
# Query the box of our image frame
result = viz.query_region(coordinate.to_astropy(), width=box[3] * Unit("deg"), height=box[2] * Unit("deg"), catalog=catalog)
region_string = "# Region file format: DS9 version 3.0\n"
region_string += "global color=green\n"
# Result may contain multiple tables (for different catalogs)
for table in result:
# For every entry in the table
for entry in table:
# Get the right ascension and the declination
ra = entry[0]
dec = entry[1]
# Create a string with the coordinates of the star
regline = "fk5;circle(%s,%s,%.2f\")\n" % (ra, dec, radius)
# Add the parameters of this star to the region string
region_string += regline
# Return the region
return regions.parse(region_string)
示例12: getSDSS
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_region [as 别名]
def getSDSS(galaxy):
"""
Query SDSS through Vizier, pick out only the stellar sources,
and put the SDSS magnitudes into AB
"""
Vizier.ROW_LIMIT = -1 # Removes row limit on output table
result = Vizier.query_region(galaxy, radius=Angle(0.1, "deg"), catalog='SDSS')
# Only select stellar sources
index = []
for i, entry in enumerate(result[1]):
if entry['cl'] != 6:
index.append(i)
result[1].remove_rows(index)
# SDSS magnitudes are not exactly in AB so need to correct
return result[1]
示例13: query_color
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_region [as 别名]
def query_color(self,
ra,
dec,
radius=0.01,
min_mag=10,
max_mag=20,
max_sources=100):
"""
Query NOMAD object
@param ra: RA of field center for search, format: degrees or hh:mm:ss
@type ra: str
@param dec: DEC of field center for search, format: degrees or hh:mm:ss
@type dec: str
@param radius: Radius.
@type radius: float
@param min_mag: Minimum magnitude value of query.
@type min_mag: float
@param max_mag: Maximum magnitude value of query.
@type max_mag: float
@param max_sources: Maximum strs to be queried..
@type max_sources: int
@return: astropy.table
"""
c = coord.SkyCoord(ra,
dec,
unit=(u.deg, u.deg),
frame='icrs')
r = radius * u.deg
vquery = Vizier(columns=['NOMAD1',
'RAJ2000',
'DEJ2000',
'Bmag',
'Vmag',
'Rmag'],
column_filters={"Rmag":
(">{:f}".format(min_mag)),
"Rmag":
("<{:f}".format(max_mag))},
row_limit=max_sources)
result = vquery.query_region(c, radius=r, catalog="NOMAD")[0]
return(result)
示例14: getVizierObjects
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_region [as 别名]
def getVizierObjects(self, catalogName):
""" Make a request to Vizier to get an Astropy Table of catalog object for this field. """
(ra, dec) = self.centre
availableCatalogs = catalogMetadata.keys()
if catalogName not in availableCatalogs:
print "The definitions for this catalogue are unknown. Available catalogues are:", availableCatalogs
return
# First look for a cached copy of this data
filenameParts = self.filename.split('.')
catalogCache = filenameParts[0] + "_" + catalogName + "_cache.fits"
cached = False
if not self.ignorecache:
print "Looking for a cached copy of the catalogue:", catalogCache,
if os.path.exists(catalogCache):
print "FOUND"
cached = True
else: print "NOT FOUND"
if cached:
newCatalog = Table.read(catalogCache)
else:
print "Going online to fetch %s results from Vizier with mag limit %f."%(catalogName, self.magLimit)
from astroquery.vizier import Vizier
Vizier.ROW_LIMIT = 1E5
Vizier.column_filters={"r":"<%d"%self.magLimit}
from astropy import coordinates
from astropy import units as u
c = coordinates.SkyCoord(ra,dec,unit=('deg','deg'),frame='icrs')
skyRA = coordinates.Angle(self.raRange, unit = u.deg)
skyDEC = coordinates.Angle(self.decRange, unit = u.deg)
print "Sky RA, DEC range:", skyRA, skyDEC
print "going to Astroquery for:", catalogMetadata[catalogName]['VizierLookup']
result = Vizier.query_region(coordinates = c, width = skyRA, height = skyDEC, catalog = catalogMetadata[catalogName]['VizierName'], verbose=True)
print result
newCatalog = result[catalogMetadata[catalogName]['VizierName']]
newCatalog.pprint()
# Write the new catalog to the cache file
newCatalog.write(catalogCache, format='fits', overwrite=True)
self.addCatalog(newCatalog, catalogName)
return
示例15: getSDSS
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_region [as 别名]
def getSDSS(galaxy):
"""
Query SDSS through Vizier, pick out only the stellar sources,
and put the SDSS magnitudes into AB
"""
Vizier.ROW_LIMIT = -1 # Removes row limit on output table
result = Vizier.query_region(galaxy, width=1.0*u.deg,
height=1.0*u.deg, catalog='SDSS')
# Only select stellar sources
index = []
for i, entry in enumerate(result[1]):
if entry['cl'] != 6:
index.append(i)
# Get the most recent SDSS catalog
result[len(result) - 1].remove_rows(index)
# SDSS magnitudes are not exactly in AB so need to correct (not doing this yet).
return result[len(result)-1]