本文整理汇总了Python中astroquery.vizier.Vizier.query_constraints方法的典型用法代码示例。如果您正苦于以下问题:Python Vizier.query_constraints方法的具体用法?Python Vizier.query_constraints怎么用?Python Vizier.query_constraints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类astroquery.vizier.Vizier
的用法示例。
在下文中一共展示了Vizier.query_constraints方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_catalog
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_constraints [as 别名]
def get_catalog(object):
from astroquery.vizier import Vizier
viz = Vizier( columns=['Star', '*'])
star = object.replace('_', ' ') + '*'
try:
return viz.query_constraints(catalog='II/183A/table2',Star=star)[0]
except IndexError:
return None
示例2: get_hip
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_constraints [as 别名]
def get_hip(ra, dec, mag):
"""
Given an RA (in hours and decimals), and Dec (in
degrees and decimals), and a magnitude (in
visual magnitudes), queries VizieR and attempts
to locate a Hipparcos star ID at the location.
Returns an integer HIP ID if found, or None otherwise
Maintains a .hip_cache file to speed up lookups;
you can delete the .hip_cache file to perform
fresh lookups.
"""
coord = SkyCoord(ra=Angle("{} hours".format(ra)),
dec=Angle("{} degree".format(dec)),
obstime="J2000.0")
# Search the Hipparcos catalog, and only return results that include
# a HIP (Hipparcos) column, sorting the results by magnitude. The
# top result is almost certainly the star we want.
v = Vizier(catalog='I/239/hip_main', columns=["HIP", "+Vmag"])
# Constrain the search to stars within 1 Vmag of our target
v.query_constraints(Vmag="{}..{}".format(mag - 0.5, mag + 0.5))
# Start with a targeted search, which returns more quickly from the
# API. If that fails to find a star, query a 3 degree diameter circle
# around the ra/dec. This is because Sky & Telescope has a convention
# of stopping their constellation lines a degree or so away from the
# star, if that star isn't actually part of the constellation
# (example: Alpheratz, which is part of the Pegasus figure, but the
# star is in Andromeda)
for radius in (0.05, 1.5):
result = v.query_region(coord, radius=radius*u.deg)
try:
table = result['I/239/hip_main']
except TypeError:
# A TypeError means that the results didn't include anything from
# the I/239/hip_main catalog. The "in" operator doesn't seem to
# work with Table objects.
continue
else:
return table['HIP'][0]
return None
示例3: fill_from_allwise
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_constraints [as 别名]
def fill_from_allwise (self, ident, catalog_ident='II/328/allwise'):
"""Fill in astrometric information from the AllWISE catalog using Astroquery.
This uses the :mod:`astroquery` module to query the AllWISE
(2013wise.rept....1C) source catalog through the Vizier
(2000A&AS..143...23O) web service. It then fills in the instance with
the relevant information. Arguments are:
ident
The AllWISE catalog identifier of the form ``"J112254.70+255021.9"``.
catalog_ident
The Vizier designation of the catalog to query. The default is
"II/328/allwise", the current version of the AllWISE catalog.
Raises :exc:`~pwkit.PKError` if something unexpected happens that
doesn't itself result in an exception within :mod:`astroquery`.
You should probably prefer :meth:`fill_from_simbad` for objects that
are known to the CDS Simbad service, but not all objects in the
AllWISE catalog are so known.
If you use this function, you should `acknowledge AllWISE
<http://irsadist.ipac.caltech.edu/wise-allwise/>`_ and `Vizier
<http://cds.u-strasbg.fr/vizier-org/licences_vizier.html>`_.
Returns *self*.
"""
from astroquery.vizier import Vizier
import numpy.ma.core as ma_core
# We should match exactly one table and one row within that table, but
# for robustness we ignore additional results if they happen to
# appear. Strangely, querying for an invalid identifier yields a table
# with two rows that are filled with masked out data.
table_list = Vizier.query_constraints (catalog=catalog_ident, AllWISE=ident)
if not len (table_list):
raise PKError ('Vizier query returned no tables (catalog=%r AllWISE=%r)',
catalog_ident, ident)
table = table_list[0]
if not len (table):
raise PKError ('Vizier query returned empty %s table (catalog=%r AllWISE=%r)',
table.meta['name'], catalog_ident, ident)
row = table[0]
if isinstance (row['_RAJ2000'], ma_core.MaskedConstant):
raise PKError ('Vizier query returned flagged row in %s table; your AllWISE '
'identifier likely does not exist (it should be of the form '
'"J112254.70+255021.9"; catalog=%r AllWISE=%r)',
table.meta['name'], catalog_ident, ident)
# OK, we can actually do this.
self.ra = row['RA_pm'] * D2R
self.dec = row['DE_pm'] * D2R
if row['e_RA_pm'] > row['e_DE_pm']:
self.pos_u_maj = row['e_RA_pm'] * A2R
self.pos_u_min = row['e_DE_pm'] * A2R
self.pos_u_pa = halfpi
else:
self.pos_u_maj = row['e_DE_pm'] * A2R
self.pos_u_min = row['e_RA_pm'] * A2R
self.pos_u_pa = 0
self.pos_epoch = 55400. # hardcoded in the catalog
self.promo_ra = row['pmRA'] * 1. # need to floatify for precastro
self.promo_dec = row['pmDE'] * 1.
if row['e_pmRA'] > row['e_pmDE']:
self.promo_u_maj = row['e_pmRA'] * 1.
self.promo_u_min = row['e_pmDE'] * 1.
self.promo_u_pa = halfpi
else:
self.promo_u_maj = row['e_pmDE'] * 1.
self.promo_u_min = row['e_pmRA'] * 1.
self.promo_u_pa = 0.
return self # eases chaining
示例4: process_vdb
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_constraints [as 别名]
def process_vdb(vdbname, gfields, sun, ind, ra_interest, dec_interest, print_coord = True, print_head = True):
lcol = 12
fields = [] + gfields
fields.append('RAJ2000')
fields.append('DEJ2000')
v = Vizier(columns = fields, catalog = vdbname)
v.ROW_LIMIT = -1
result = v.query_constraints(catalog = vdbname, RAJ2000 = ra_interest, DEJ2000 = dec_interest)
#result[result.keys()[0]].pprint()
numobjs = len(result[0])
twelveoc = 12*60*60
tms = twelveoc*np.array([1., 3., 4.])
prline = '==========' + '=' + '============'
prhead = 'Date ' + ' ' + ' Time '
l = len(fields)
if not print_coord:
l -= 2
for i in xrange(l):
prline = prline + '=' + '='*lcol
tmp = fields[i]
if len(tmp) < lcol:
tmp = tmp + ' '*(lcol - len(tmp))
prhead = prhead + ' ' + tmp
prhead = prhead + ' ' + 'Dec distance'
prline = prline + '=' + '============'
if print_head:
print prline
print prhead
print prline
for i in xrange(numobjs):
ri = result[0][i].as_void()
ri= list(ri)
ri=ri[:-2]
[ra, dec] = [ri[-2], ri[-1]]
ra = parse_coord( ra, 'ra', ' ')
dec = parse_coord( dec, 'deg', ' ')
t, num = comp_time(sun[ind-1][1], sun[ind][1], sun[ind+1][1], ra)
t = t.f2s()
if num > 0:
t += 2*twelveoc
tmp = tms - t
sz = tmp[tmp > 0].size
if sz == 1:
idx = ind+1
elif sz == 2:
idx = ind
elif sz == 3:
idx = ind-1
t = coord(0, 0, t + twelveoc, 1, 'ra')
if idx == ind:
curdate = sun[idx][0]
tmp = str(curdate[0])
if len(tmp) < 2:
tmp = ' ' + tmp
date = '' + tmp + '/'
tmp = str(curdate[1])
if len(tmp) < 2:
tmp = ' ' + tmp
date = date + tmp + '/' + str(curdate[2])
dist = comp_dist(curdate[0], curdate[1], t, dec)
printer = '' + date + ' ' + str(t)
stri = [str(x) for x in ri[:-2]]
if print_coord:
stri = stri + [str(ra), str(dec)]
for x in stri:
if len(x) < lcol:
x = ' '*(lcol - len(x)) + x
printer = printer + ' ' + x
printer = printer + ' ' + str(dist)
print printer