The module provides functions for searching objects and tables, and to
fetch the data from the remote catalog. Currently the data fetching
supports the GAIA catalogues. Object searching is done using the
Simbad service.
Examples
1fromscludamimportQuery,search_object,search_table 2 3iden="ngc2527" 4 5# search object to get some general information 6object_info=search_object(iden) 7print(f"Object found in {object_info.coords}") 8object_info.table.write( 9f"examples/{iden}_object_metadata.txt",format="ascii",overwrite=True10)1112default_table=Query().table1314# search the default table information (gaia edr3)15tables=search_table(default_table)16first_table=tables[0]17print(f"name: {first_table.name}\n description: {first_table.description}\n")18first_table.columns.write(19f"examples/{default_table}_columns_metadata.txt",format="ascii",overwrite=True20)2122# create query around object23query=(24Query()25.select(26"ra",27"dec",28"ra_error",29"dec_error",30"ra_dec_corr",31"pmra",32"pmra_error",33"ra_pmra_corr",34"dec_pmra_corr",35"pmdec",36"pmdec_error",37"ra_pmdec_corr",38"dec_pmdec_corr",39"pmra_pmdec_corr",40"parallax",41"parallax_error",42"parallax_pmra_corr",43"parallax_pmdec_corr",44"ra_parallax_corr",45"dec_parallax_corr",46"phot_g_mean_mag",47)48.where_in_circle(iden,2.5)49.where(50[51("parallax",">",0.2),52("phot_g_mean_mag","<",18),53]54)55# low noise_sig means "do not rely on excess noise, do not check it"56# high noise_sig means "you should check that excess noise is small"57.where_arenou_criterion()58.where_aen_criterion()59)6061# count the number of rows that will be received if query is executed62count=query.count()63print(f'Stars found: {count["count_all"][0]}')6465# execute query and save data66data=query.get()67data.write(f"examples/{iden}_data.xml",format="votable",overwrite=True)
Options for each function and class in the example are described
in the documentation below.
cols (List[str], optional) – Columns to be included in the result, by default
[ “coordinates”, “parallax”, “propermotions”,
“velocity”, “dimensions”, “diameter”, ]
condition (Union[Condition, List[Condition]]) – Condition or list of Conditions to be added to the query.
Each Condition is a tuple of the form
(expression1, operator, expression2): (str, str, Union[str, Number])
Add a condition to the query to select objects within a circle.
The circle is drawn in the spherical coordinates space (ra, dec). It also adds
the dist (distance from the center) column to column list and adds orderby
distance to the query.
Parameters:
coords_or_name (Union[Coord, SkyCoord, str]) – Coordinates of the center of the circle or name of the identifier to be
searched using search_object.
radius (Union[int, float, astropy.units.quantity.Quantity]) – value of the radius of the circle. If int or float, its taken as degrees.
ra_name (str, optional) – ra column name, by default config.MAIN_GAIA_RA
dec_name (str, optional) – dec column name, by default config.MAIN_GAIA_DEC
It launches an asynchronous gaia job. It takes some time to execute the
query and parse the results. Parameters are passed through kwargs to
astroquery.gaia.Gaia.launch_job_async.
Parameters:
dump_to_file (bool) – If True, results will be stored in file, false by default.
output_file (str) – Name of the output file if dump_to_file is True.
It launches an asynchronous gaia job. It takes some time
to execute the query and parse the results. It only returns
a table with a single count_all column. Parameters are
passed through kwargs to astroquery.gaia.Gaia.launch_job_async.
Parameters:
dump_to_file (bool) – If True, results will be stored in file, false by default.
output_file (str) – Name of the output file if dump_to_file is True.
Search for objects in an area defined by dataframe.
search all simbad objects in an area
defined by a dataframe by the maxs and mins
of the columns in the dataframe with GAIA
colnames.
Parameters:
df (pd.DataFrame) – dataframe with GAIA data. Must contain
ra and dec columns. May also contain “pmra”, “pmdec”, “parallax”,
“phot_g_mean_mag”, “phot_rp_mean_mag”, “phot_bp_mean_mag”. Other
fields are ignored
allow_missing_values (bool, optional) – Allow simbad objects with missing value for the columns in the
dataframe to appear in the result table, by default True.
fields (list, optional) – extra simbad fields to add, apart from
["parallax","propermotions","diameter","fluxdata(G)","fluxdata(B)","fluxdata(R)"],
by default []
Returns:
Simbad result table. RA and DEC columns
are parsed into degrees with decimal places.
Return type:
astroquery.table.table.Table
Raises:
ValueError – No supported columns present in the dataframe.
Convert a simbad table colnames to a gaia table colnames.
Only supports translation for ‘RA’, ‘DEC’, ‘PMRA’, ‘PMDEC’,
‘PLX_VALUE’, ‘FLUX_G’, ‘FLUX_R’, ‘FLUX_B’. It also adds
‘bp_rp’ if ‘FLUX_B’ and ‘FLUX_R’ are present.