本文整理汇总了Python中astroquery.vizier.Vizier.ROW_LIMIT方法的典型用法代码示例。如果您正苦于以下问题:Python Vizier.ROW_LIMIT方法的具体用法?Python Vizier.ROW_LIMIT怎么用?Python Vizier.ROW_LIMIT使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类astroquery.vizier.Vizier
的用法示例。
在下文中一共展示了Vizier.ROW_LIMIT方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: query_nvss
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import ROW_LIMIT [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
示例2: galaxies_in_box
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import ROW_LIMIT [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
示例3: fetch_objects_in_box
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import ROW_LIMIT [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)
示例4: get_galaxy_s4g_one_component_info
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import ROW_LIMIT [as 别名]
def get_galaxy_s4g_one_component_info(name):
"""
This function ...
:param name:
:return:
"""
# The Vizier querying object
vizier = Vizier()
vizier.ROW_LIMIT = -1
# Get the "galaxies" table
result = vizier.query_object(name, catalog=["J/ApJS/219/4/galaxies"])
# No results?
if len(result) == 0: return None, None, None, None, None, None
# Get table
table = result[0]
# PA: [0.2/180] Outer isophote position angle
# e_PA: [0/63] Standard deviation in PA
# Ell: [0.008/1] Outer isophote ellipticity
# e_Ell: [0/0.3] Standard deviation in Ell
# PA1: Elliptical isophote position angle in deg
# n: Sersic index
# Re: effective radius in arcsec
# Tmag: total magnitude
s4g_name = table["Name"][0]
pa = Angle(table["PA"][0] - 90., "deg")
pa_error = Angle(table["e_PA"][0], "deg")
ellipticity = table["Ell"][0]
ellipticity_error = table["e_Ell"][0]
n = table["n"][0]
re = table["Re"][0] * u("arcsec")
mag = table["Tmag"][0]
# Return the results
return s4g_name, pa, ellipticity, n, re, mag
示例5: get_s4g_properties
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import ROW_LIMIT [as 别名]
def get_s4g_properties(self):
"""
This function ...
:return:
"""
# Inform the user
log.info("Querying the S4G catalog ...")
# The Vizier querying object
vizier = Vizier(columns=['Name', 'RAJ2000', 'DEJ2000', 'amaj', 'ell', 'Dmean', "e_Dmean", "PA"])
vizier.ROW_LIMIT = -1
# Get parameters from S4G catalog
result = vizier.query_object(self.galaxy_name, catalog=["J/PASP/122/1397/s4g"])
table = result[0]
# Galaxy name for S4G catalog
self.properties.name = table["Name"][0]
# Galaxy center from decomposition (?)
ra_center = table["RAJ2000"][0]
dec_center = table["DEJ2000"][0]
center = SkyCoordinate(ra=ra_center, dec=dec_center, unit="deg", frame='fk5')
self.properties.center = center
# Center position
#self.properties.center = SkyCoordinate(ra=self.info["RA"][0], dec=self.info["DEC"][0], unit="deg") # center position from DustPedia
# Distance
self.properties.distance = table["Dmean"][0] * u("Mpc")
self.properties.distance_error = table["e_Dmean"][0] * u("Mpc")
# Major axis, ellipticity, position angle
self.properties.major_arcsec = table["amaj"][0] * u("arcsec")
self.properties.major = (self.properties.distance * self.properties.major_arcsec).to("pc", equivalencies=dimensionless_angles())
# Ellipticity
self.properties.ellipticity = table["ell"][0]
self.properties.position_angle = Angle(table["PA"][0] + 90.0, u("deg"))
示例6: query_cat
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import ROW_LIMIT [as 别名]
def query_cat(catalog, min_ra, max_ra, min_dec, max_dec, columns=None,
column_filters=None):
"""
Use vizquery to get a reference catalog from vizier
"""
from astroquery.vizier import Vizier
import numpy as np
from astropy.coordinates import SkyCoord
# Build vizquery statement
width = int(np.ceil((max_ra-min_ra)*60))
height = int(np.ceil((max_dec-min_dec)*60))
center = SkyCoord((min_ra+max_ra)/2, (min_dec+max_dec)/2, unit='deg')
# If no column filters are specified, use the defaults
if column_filters is None:
if catalog.startswith('SDSS'):
column_filters = {
'cl': '=6',
'q_mode':'=+'
}
elif catalog.startswith('UKIDSS'):
column_filters = {
'cl': '=-1',
'm': '=1'
}
else:
column_filters = {}
# Query the catalog in Vizier
logger.info('columns:{0}'.format(columns))
v = Vizier(columns=columns, column_filters=column_filters,
catalog=catalog_info[catalog]['info']['vizier_id'])
v.ROW_LIMIT=200000
result = v.query_region(center, width='{0}m'.format(width*1.25),
height='{0}m'.format(height*1.25))
logger.warn(result[0].columns)
refcat = result[0]
return refcat
示例7: load
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import ROW_LIMIT [as 别名]
def load(self, ra=0.0, dec=90.0, radius=0.2, write=True, faintlimit=None):
# select the columns that should be downloaded from UCAC
catalog = 'UCAC4'
ratag = '_RAJ2000'
dectag = '_DEJ2000'
if catalog == 'UCAC4':
vcat = 'I/322A/out'
rmagtag = 'f.mag'
jmagtag = 'Jmag'
vmagtag = 'Vmag'
pmratag, pmdectag = 'pmRA', 'pmDE'
columns = ['_RAJ2000', '_DECJ2000', 'pmRA', 'pmDE', 'f.mag', 'Jmag', 'Vmag', 'UCAC4']
# create a query through Vizier
v = Vizier(catalog=vcat, columns=columns)
v.ROW_LIMIT = -1
# either reload an existing catalog file or download to create a new one
starsfilename = settings.intermediates + self.directory
starsfilename += "{catalog}ra{ra:.4f}dec{dec:.4f}rad{radius:.4f}".format(
catalog=catalog,
ra=ra,
dec=dec,
radius=radius) + '.npy'
try:
# try to load a raw catalog file
logger.info("loading a catalog of stars from {0}".format(starsfilename))
t = np.load(starsfilename)
except IOError:
logger.info('could not load stars')
# otherwise, make a new query
logger.info("querying {catalog} "
"for ra = {ra}, dec = {dec}, radius = {radius}".format(
catalog=catalog, ra=ra, dec=dec, radius=radius))
# load via astroquery
t = v.query_region(astropy.coordinates.ICRS(ra=ra, dec=dec,
unit=(astropy.units.deg, astropy.units.deg)),
radius='{:f}d'.format(radius), verbose=True)[0]
# save the queried table
np.save(starsfilename, t)
# define the table
self.table = astropy.table.Table(t)
ras = np.array(t[:][ratag])
decs = np.array(t[:][dectag])
pmra = np.array(t[:][pmratag])
pmdec = np.array(t[:][pmdectag])
rmag = np.array(t[:][rmagtag])
jmag = np.array(t[:][jmagtag])
vmag = np.array(t[:][vmagtag])
rbad = (np.isfinite(rmag) == False) * (np.isfinite(vmag))
rmag[rbad] = vmag[rbad]
rbad = (np.isfinite(rmag) == False) * (np.isfinite(jmag))
rmag[rbad] = jmag[rbad]
jbad = (np.isfinite(jmag) == False) * (np.isfinite(vmag))
jmag[jbad] = vmag[jbad]
jbad = (np.isfinite(jmag) == False) * (np.isfinite(rmag))
jmag[jbad] = rmag[jbad]
vbad = (np.isfinite(vmag) == False) * (np.isfinite(rmag))
vmag[vbad] = rmag[vbad]
vbad = (np.isfinite(vmag) == False) * (np.isfinite(jmag))
vmag[vbad] = jmag[vbad]
temperatures = relations.pickles(rmag - jmag)
imag = rmag - relations.davenport(rmag - jmag)
pmra[np.isfinite(pmra) == False] = 0.0
pmdec[np.isfinite(pmdec) == False] = 0.0
ok = np.isfinite(imag)
if faintlimit is not None:
ok *= imag <= faintlimit
logger.info("found {0} stars with {1} < V < {2}".format(np.sum(ok), np.min(rmag[ok]), np.max(rmag[ok])))
self.ra = ras[ok]
self.dec = decs[ok]
self.pmra = pmra[ok]
self.pmdec = pmdec[ok]
self.tmag = imag[ok]
self.temperature = temperatures[ok]
self.epoch = 2000.0
示例8: get_galaxy_info
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import ROW_LIMIT [as 别名]
def get_galaxy_info(name, position):
"""
This function ...
:param name:
:param position:
:return:
"""
# Obtain more information about this galaxy
try:
ned_result = Ned.query_object(name)
ned_entry = ned_result[0]
# Get a more common name for this galaxy (sometimes, the name obtained from NED is one starting with 2MASX .., use the PGC name in this case)
if ned_entry["Object Name"].startswith("2MASX "): gal_name = name
else: gal_name = ned_entry["Object Name"]
# Get the redshift
gal_redshift = ned_entry["Redshift"]
if isinstance(gal_redshift, np.ma.core.MaskedConstant): gal_redshift = None
# Get the type (G=galaxy, HII ...)
gal_type = ned_entry["Type"]
if isinstance(gal_type, np.ma.core.MaskedConstant): gal_type = None
except astroquery.exceptions.RemoteServiceError:
# Set attributes
gal_name = name
gal_redshift = None
gal_type = None
except astroquery.exceptions.TimeoutError:
# Set attributes
gal_name = name
gal_redshift = None
gal_type = None
except:
# Set attributes
gal_name = name
gal_redshift = None
gal_type = None
# Create a new Vizier object and set the row limit to -1 (unlimited)
viz = Vizier(keywords=["galaxies", "optical"])
viz.ROW_LIMIT = -1
# Query Vizier and obtain the resulting table
result = viz.query_object(name.replace(" ", ""), catalog=["VII/237"])
# Not found ... TODO: fix this ... this object was in the first query output
if len(result) == 0: return name, position, None, None, [], None, None, None, None, None, None
table = result[0]
# Get the correct entry (sometimes, for example for mergers, querying with the name of one galaxy gives two hits! We have to obtain the right one each time!)
if len(table) == 0: raise ValueError("The galaxy could not be found under this name")
elif len(table) == 1: entry = table[0]
else:
entry = None
# Some rows don't have names, if no match is found based on the name just take the row that has other names defined
rows_with_names = []
for row in table:
if row["ANames"]: rows_with_names.append(row)
# If only one row remains, take that one for the galaxy we are looking for
if len(rows_with_names) == 1: entry = rows_with_names[0]
# Else, loop over the rows where names are defined and look for a match
else:
for row in rows_with_names:
names = row["ANames"]
if name.replace(" ", "") in names or gal_name.replace(" ", "") in names:
entry = row
break
# If no matches are found, look for the table entry for which the coordinate matches the given position (if any)
if entry is None and position is not None:
for row in table:
if np.isclose(row["_RAJ2000"], position.ra.value) and np.isclose(row["_DEJ2000"], position.dec.value):
entry = row
break
# Note: another temporary fix
if entry is None: return name, position, None, None, [], None, None, None, None, None, None
# Get the right ascension and the declination
position = SkyCoordinate(ra=entry["_RAJ2000"], dec=entry["_DEJ2000"], unit="deg", frame="fk5")
# Get the names given to this galaxy
#.........这里部分代码省略.........
示例9: create_star_catalog
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import ROW_LIMIT [as 别名]
def create_star_catalog(frame, catalogs=None):
"""
This function ...
:return:
"""
# Initialize empty lists for the table columns
catalog_column = []
id_column = []
ra_column = []
dec_column = []
ra_error_column = []
dec_error_column = []
magnitude_columns = {}
magnitude_error_columns = {}
on_galaxy_column = []
confidence_level_column = []
# Get the range of right ascension and declination of this image
center, ra_span, dec_span = frame.coordinate_range
# Create a new Vizier object and set the row limit to -1 (unlimited)
viz = Vizier(keywords=["stars", "optical"])
viz.ROW_LIMIT = -1
# Loop over the different catalogs
for catalog in catalogs:
# Initialize a list to specify which of the stars added to the columns from other catalogs is already
# matched to a star of the current catalog
encountered = [False] * len(catalog_column)
# Inform the user
log.debug("Querying the " + catalog + " catalog")
# Query Vizier and obtain the resulting table
result = viz.query_region(center.to_astropy(), width=ra_span, height=dec_span, catalog=catalog)
table = result[0]
number_of_stars = 0
number_of_stars_in_frame = 0
number_of_new_stars = 0
magnitudes = {}
magnitude_errors = {}
# Get the magnitude in different bands
for name in table.colnames:
# If this column name does not end with "mag", skip it
if not name.endswith("mag"): continue
# If the column name contains more than one character before "mag", skip it
if len(name.split("mag")[0]) > 1: continue
# Get the name of the band
band = name.split("mag")[0]
# Create empty lists for the magnitudes and errors
magnitudes[band] = []
magnitude_errors[band] = []
# Loop over all entries in the table
for i in range(len(table)):
# -- General information --
# Get the ID of this star in the catalog
if catalog == "UCAC4": star_id = table["UCAC4"][i]
elif catalog == "NOMAD": star_id = table["NOMAD1"][i]
elif catalog == "II/246": star_id = table["_2MASS"][i]
else: raise ValueError("Catalogs other than 'UCAC4', 'NOMAD' or 'II/246' are currently not supported")
# -- Positional information --
# Get the position of the star as a SkyCoord object and as pixel coordinate
position = SkyCoordinate(ra=table["_RAJ2000"][i], dec=table["_DEJ2000"][i], unit="deg", frame="fk5")
pixel_position = position.to_pixel(frame.wcs)
# Get the right ascension and declination for the current star
star_ra = table["_RAJ2000"][i]
star_dec = table["_DEJ2000"][i]
number_of_stars += 1
# If this star does not lie within the frame, skip it
if not frame.contains(position): continue
number_of_stars_in_frame += 1
# Get the mean error on the right ascension and declination
if catalog == "UCAC4" or catalog == "NOMAD":
ra_error = table["e_RAJ2000"][i] * Unit("mas")
dec_error = table["e_DEJ2000"][i] * Unit("mas")
elif catalog == "II/246":
error_maj = table["errMaj"][i] * Unit("arcsec")
#.........这里部分代码省略.........
示例10: print
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import ROW_LIMIT [as 别名]
st = (sra-rad)
ntiles=0
while st <= sra+rad:
st = st + step
ntiles += 1
##########################################################
### Hipparcos
print('Querying Hipparcos')
t0 = time.time()
v = Vizier(columns=['_RAJ2000', '_DEJ2000','HIP', 'Plx', 'e_Plx', 'pmRA', 'e_pmRA', 'pmDE', 'e_pmDE', 'Hpmag', 'e_Hpmag'])
# for some reason we need this first to get more than 50 entries
Vizier.ROW_LIMIT = -1
v.ROW_LIMIT = -1
result = v.query_region(coord.ICRS(ra=sra, dec=sde, unit=(u.deg, u.deg)), radius=Angle(rad, "deg"), catalog='I/311')
#print(result)
#print(sra,sde,rad)
#pdb.set_trace()
table=result[0]
#table.colnames
#pdb.set_trace()
#x=np.array(table[:]['Plx'])
#y=np.array(table[:]['e_Plx'])
ra = np.array(table[:]['_RAJ2000'])
dec = np.array(table[:]['_DEJ2000'])
示例11: process_vdb
# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import ROW_LIMIT [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