Wildcard Handling with Astroquery.mast#


Learning Goals#

By the end of this tutorial, you will:

  • Use the wildcards available for astroquery.mast.Observations criteria queries

  • Broaden and refine astroquery.mast.Observations criteria queries

  • Fully utilize the instrument_name criteria, especially for JWST queries

  • Query for moving targets using target ephemeris and time criteria such as t_min and t_max

Introduction#

This Notebook demonstrates the use of wildcards in astroquery.mast.Observations criteria queries. The use of wildcards is encouraged for certain criteria types (namely, string object types) to ensure your query returns all results.

We will demonstrate 3 use-cases for wildcards when doing criteria queries and emphasize certain criteria where wildcard usage is highly encouraged, particularly for JWST queries. We will also use the last example to demonstrate the use of value ranges when working with float object criteria types.

The workflow for this notebook consists of:

  • Wildcard overview with astroquery.mast.Observations

    1. Wildcard Search with instrument_name

    2. Wildcard Search with instrument_name and proposal_id

    3. Wildcard Search a Time-sensitive Object with target_name and t_min

  • Resources

Imports#

import astropy.units as u
import matplotlib.pyplot as plt

from astropy.coordinates import SkyCoord
from astropy.table import Table, unique, vstack
from astropy.time import Time
from astroquery.mast import Observations

Wildcards with astroquery.mast.Observations#

The use of wildcards when making astroquery.mast.Observations queries can help ensure you retrieve all observations without leaving anything out. The available wildcards are % and *: % replaces a single character, while * replaces more than one character preceding, following, or in between the existing characters, depending on its placement. See the Observation Criteria Queries section in the astroquery.mast documentation for more information on the wildcards.

Wildcards are only available for certain criteria. string type objects accept wildcards, but float, integer, or any other objects do not accept wildcards.

Users may call the get_metadata method to see the list of query criteria and their data types. The criteria listed as string objects under the Data Type column are criteria that can be called with wildcards:

Observations.get_metadata("observations")
Table length=34
Column NameColumn LabelData TypeUnitsDescriptionExamples/Valid Values
str21str25str7str10str72str116
intentTypeObservation TypestringWhether observation is for science or calibration.Valid values: science, calibration
obs_collectionMissionstringCollectionE.g. SWIFT, PS1, HST, IUE
provenance_nameProvenance NamestringProvenance name, or source of dataE.g. TASOC, CALSTIS, PS1
instrument_nameInstrumentstringInstrument NameE.g. WFPC2/WFC, UVOT, STIS/CCD
projectProjectstringProcessing projectE.g. HST, HLA, EUVE, hlsp_legus
filtersFiltersstringInstrument filtersF469N, NUV, FUV, LOW DISP, MIRROR
wavelength_regionWavebandstringEnergy BandEUV, XRAY, OPTICAL
target_nameTarget NamestringTarget NameEx. COMET-67P-CHURYUMOV-GER-UPDATE
target_classificationTarget ClassificationstringType of targetEx. COMET;COMET BEING ORBITED BY THE ROSETTA SPACECRAFT;SOLAR SYSTEM
..................
s_regions_regionstringICRS ShapeSTC/S FootprintWill be ICRS circle or polygon. E.g. CIRCLE ICRS 17.71740689 -58.40043015 0.625
jpegURLjpegURLstringPreview Image URLhttps://archive.stsci.edu/hst/previews/N4QF/N4QF18090.jpg
distanceDistance (")floatarcsecAngular separation between searched coordinates and center of obsevation
obsidProduct Group IDintegerDatabase identifier for obs_idLong integer, e.g. 2007590987
dataRightsData RightsstringData Rightsvalid values: public,exclusive_access,restricted
mtFlagMoving TargetbooleanMoving Target FlagIf True, observation contains a moving target, if False or absent observation may or may not contain a moving target
srcDenNumber of Catalog ObjectsfloatNumber of cataloged objects found in observation
dataURLData URLstringData URL
proposal_typeProposal TypestringType of telescope proposalEg. 3PI, GO, GO/DD, HLA, GII, AIS
sequence_numberSequence NumberintegerSequence number, e.g. Kepler quarter or TESS sector

Case 1: Wildcard Search with instrument_name#

For our first example we will search for all NIRISS observations taken by a certain proposal/program PI. Our two query criteria are proposal_pi and instrument_name, which are both string object criteria. As such, both can be wildcarded for ease of use.

In fact, it is sometimes necessary to use wildcards when searching on instrument_name. Both HST and JWST use instrument configurations in this field to allow for more precise advanced searches (e.g. NIRISS/IMAGE and STIS/FUV-MAMA). When performing a “generic” search, you must include a wildcard or these more detailed results will be excluded.

We will demonstrate this by looking at the results for the query below:

observations = Observations.query_criteria(proposal_pi="Espinoza, Nestor",
                                           instrument_name="NIRISS*")
observations
Table masked=True length=139
intentTypeobs_collectionprovenance_nameinstrument_nameprojectfilterswavelength_regiontarget_nametarget_classificationobs_ids_ras_decdataproduct_typeproposal_picalib_levelt_mint_maxt_exptimeem_minem_maxobs_titlet_obs_releaseproposal_idproposal_typesequence_numbers_regionjpegURLdataURLdataRightsmtFlagsrcDenobsidobjID
str7str4str7str12str4str13str8str13str54str50float64float64str8str16int64float64float64float64float64float64str70float64str4str3int64str132str63str81str16boolfloat64str9str9
scienceJWSTAPTNIRISS/IMAGEJWSTF480MInfraredECLIPTIC-RA00--jw06658002001_xx101_00001_niriss9.3443875000000021.4307027777777779imageEspinoza, Nestor-1nannan42.9474600.05000.0SOSS background measurementsnan6658CAL1POLYGON 9.3627908779 1.41191833158 9.32563140264 1.41212306828 9.32600203261 1.44950520465 9.36315303494 1.44932680218----PUBLICFalsenan213026785403862655
scienceJWSTCALJWSTNIRISS/IMAGEJWSTCLEAR;GR700XDInfraredECLIPTIC-RA00Calibration; External flat fieldjw04479001002_03101_00001_nis9.3443875000000021.4307027777777779imageEspinoza, Nestor260265.5929271489660265.596530925926300.63600.02800.0SOSS background measurements60265.666828634479CAL--POLYGON 9.341983254 1.414141714 9.32592057 1.447640405 9.359713446 1.463651021 9.37579551 1.430171697mast:JWST/product/jw04479001002_03101_00001_nis_trapsfilled.jpgmast:JWST/product/jw04479001002_03101_00001_nis_rateints.fitsPUBLICFalsenan191961742408856181
scienceJWSTCALJWSTNIRISS/IMAGEJWSTCLEAR;GR700XDInfraredECLIPTIC-RA00Calibration; External flat fieldjw04479002009_03101_00001_nis9.3443875000000021.4307027777777779imageEspinoza, Nestor260265.74359959108660265.74720336805300.63600.02800.0SOSS background measurements60265.786435174479CAL--POLYGON 9.316621316 1.402125579 9.300558415 1.435624126 9.334350968 1.451635046 9.350433251 1.418155869mast:JWST/product/jw04479002009_03101_00001_nis_trapsfilled.jpgmast:JWST/product/jw04479002009_03101_00001_nis_rateints.fitsPUBLICFalsenan192102528408856581
scienceJWSTCALJWSTNIRISS/IMAGEJWSTCLEAR;GR700XDInfraredECLIPTIC-RA00Calibration; External flat fieldjw04479002002_03101_00001_nis9.3443875000000021.4307027777777779imageEspinoza, Nestor260265.6876715008160265.69127527778300.63600.02800.0SOSS background measurements60265.730011464479CAL--POLYGON 9.341983221 1.414141681 9.325920514 1.44764036 9.359713379 1.463650999 9.375795466 1.430171686mast:JWST/product/jw04479002002_03101_00001_nis_trapsfilled.jpgmast:JWST/product/jw04479002002_03101_00001_nis_rateints.fitsPUBLICFalsenan192013607408935017
scienceJWSTCALJWSTNIRISS/IMAGEJWSTCLEAR;GR700XDInfraredECLIPTIC-RA00Calibration; External flat fieldjw04479002008_03101_00001_nis9.3443875000000021.4307027777777779imageEspinoza, Nestor260265.7343440471160265.73794782408300.63600.02800.0SOSS background measurements60265.787048554479CAL--POLYGON 9.325075322 1.40613114 9.309012591 1.439629781 9.342805298 1.455640502 9.358887411 1.422161228mast:JWST/product/jw04479002008_03101_00001_nis_trapsfilled.jpgmast:JWST/product/jw04479002008_03101_00001_nis_rateints.fitsPUBLICFalsenan192102532408935023
scienceJWSTCALJWSTNIRISS/IMAGEJWSTCLEAR;GR700XDInfraredECLIPTIC-RA20Calibration; External flat fieldjw04479005004_02103_00001_nis27.65213333333333511.538361111111112imageEspinoza, Nestor260302.7240237792860302.72539072917107.368600.02800.0SOSS background measurements60302.969837914479CAL--POLYGON 27.630184308 11.515689331 27.617041473 11.550534444 27.652891551 11.563337498 27.666052471 11.528508455mast:JWST/product/jw04479005004_02103_00001_nis_trapsfilled.jpgmast:JWST/product/jw04479005004_02103_00001_nis_rateints.fitsPUBLICFalsenan199450721408935037
scienceJWSTCALJWSTNIRISS/IMAGEJWSTCLEAR;GR700XDInfraredECLIPTIC-RA20Calibration; External flat fieldjw04479003004_02101_00001_nis27.65213333333333511.538361111111112imageEspinoza, Nestor260302.64241126770560302.64377821759107.368600.02800.0SOSS background measurements60302.968761474479CAL--POLYGON 27.633429998 11.50696385 27.620287937 11.541809095 27.656137033 11.554611789 27.669297182 11.519782615mast:JWST/product/jw04479003004_02101_00001_nis_trapsfilled.jpgmast:JWST/product/jw04479003004_02101_00001_nis_rateints.fitsPUBLICFalsenan199450463408935038
scienceJWSTCALJWSTNIRISS/IMAGEJWSTCLEAR;GR700XDInfraredECLIPTIC-RA20Calibration; External flat fieldjw04479005001_02103_00001_nis27.65213333333333511.538361111111112imageEspinoza, Nestor260302.68773344363660302.689100393516107.368600.02800.0SOSS background measurements60302.969826344479CAL--POLYGON 27.660372577 11.516577392 27.647233355 11.551423829 27.68308489 11.564223272 27.696242197 11.529392904mast:JWST/product/jw04479005001_02103_00001_nis_trapsfilled.jpgmast:JWST/product/jw04479005001_02103_00001_nis_rateints.fitsPUBLICFalsenan199450725408935044
scienceJWSTCALJWSTNIRISS/IMAGEJWSTCLEAR;GR700XDInfraredECLIPTIC-RA20Calibration; External flat fieldjw04479003004_02103_00001_nis27.65213333333333511.538361111111112imageEspinoza, Nestor260302.64764978622460302.64901673611107.368600.02800.0SOSS background measurements60302.969467544479CAL--POLYGON 27.630184272 11.515689331 27.617041424 11.55053444 27.652891497 11.563337507 27.66605243 11.528508469mast:JWST/product/jw04479003004_02103_00001_nis_trapsfilled.jpgmast:JWST/product/jw04479003004_02103_00001_nis_rateints.fitsPUBLICFalsenan199450729408935047
...................................................................................................
scienceJWSTCALJWSTNIRISS/SOSSJWSTF480MInfraredBD+60-1753Star; A dwarfsjw01512002001_02101_00002_nis261.217877704840760.430788532908466imageEspinoza, Nestor259995.9818661689859995.981874594910.6834600.05000.0SOSS Wavelength and Trace59996.183055561512CAL--POLYGON 261.21846424 60.429977233 261.216255709 60.430400627 261.21709951 60.431483308 261.219308303 60.431059879mast:JWST/product/jw01512002001_02101_00002_nis_cal.jpgmast:JWST/product/jw01512002001_02101_00002_nis_cal.fitsPUBLICFalsenan117933634408972026
scienceJWSTCALJWSTNIRISS/SOSSJWSTF480MInfraredBD+60-1753Star; A dwarfsjw01512007001_02101_00002_nis261.217877704569360.430788532805536imageEspinoza, Nestor259995.9458602777859995.9458687037040.6834600.05000.0SOSS Wavelength and Trace59996.15833331512CAL--POLYGON 261.218461801 60.429976691 261.216254156 60.430401208 261.217100217 60.43148346 261.219308125 60.431058908mast:JWST/product/jw01512007001_02101_00002_nis_cal.jpgmast:JWST/product/jw01512007001_02101_00002_nis_cal.fitsPUBLICFalsenan117933630408972157
scienceJWSTCALJWSTNIRISS/SOSSJWSTF480MInfraredBD+60-1753Star; A dwarfsjw01512007001_02101_00001_nis261.2178777045628560.43078853280309imageEspinoza, Nestor259995.9450069444459995.945015370370.6834600.05000.0SOSS Wavelength and Trace59996.159004591512CAL--POLYGON 261.218582929 60.430031016 261.216375283 60.430455538 261.217221354 60.431537787 261.219429263 60.431113231mast:JWST/product/jw01512007001_02101_00001_nis_cal.jpgmast:JWST/product/jw01512007001_02101_00001_nis_cal.fitsPUBLICFalsenan117933624408972173
scienceJWSTCALJWSTNIRISS/SOSSJWSTF480MInfraredBD+60-1753Star; A dwarfsjw01512007001_02101_00004_nis261.217877704609260.43078853282068imageEspinoza, Nestor259995.9511580439859995.951166469910.6834600.05000.0SOSS Wavelength and Trace59996.1589121512CAL--POLYGON 261.218558602 60.430041782 261.216350954 60.430466301 261.21719702 60.431548551 261.219404932 60.431123997mast:JWST/product/jw01512007001_02101_00004_nis_cal.jpgmast:JWST/product/jw01512007001_02101_00004_nis_cal.fitsPUBLICFalsenan117933620408972189
scienceJWSTCALJWSTNIRISS/SOSSJWSTF480MInfraredBD+60-1753Star; A dwarfsjw01512007001_02101_00003_nis261.217877704575860.43078853280801imageEspinoza, Nestor259995.9467262037159995.946734629630.6834600.05000.0SOSS Wavelength and Trace59996.15833331512CAL--POLYGON 261.218423855 60.430081248 261.216216202 60.430505765 261.217062266 60.431588016 261.219270181 60.431163464mast:JWST/product/jw01512007001_02101_00003_nis_cal.jpgmast:JWST/product/jw01512007001_02101_00003_nis_cal.fitsPUBLICFalsenan117933626408972208
scienceJWSTCALJWSTNIRISS/SOSSJWSTCLEAR;GR700XDInfraredHAT-P-14Star; Exoplanet Systems; Exoplanets; F dwarfs; F starsjw01541-o001_t002_niriss_clear-gr700xd-substrip256260.1161771630844438.242156511096134spectrumEspinoza, Nestor359738.2612162559738.55248649305618855.408600.02800.0NIRISS Sensitivity and Stability for Transiting Exoplanet Observations59774.85416661541COM--POLYGON 260.16190084 38.23723653 260.11337623 38.23744814 260.11348554 38.24618148 260.16201952 38.24596704 260.16190084 38.23723653--mast:JWST/product/jw01541-o001_t002_niriss_clear-gr700xd-substrip256_x1dints.fitsPUBLICFalsenan213209384410291660
scienceJWSTCALJWSTNIRISS/SOSSJWSTCLEAR;GR700XDInfraredHAT-P-14Star; Exoplanet Systems; Exoplanets; F dwarfs; F starsjw01541001001_04102_00001-seg001_nis260.116177163368638.242156510427485imageEspinoza, Nestor259738.5539086689859738.55835982639329.64600.02800.0NIRISS Sensitivity and Stability for Transiting Exoplanet Observations59774.85416661541COM--POLYGON 260.071030426 38.2494554 260.119367245 38.246686364 260.11850644 38.23799955 260.070173177 38.240758867mast:JWST/product/jw01541001001_04102_00001-seg001_nis_ramp.jpgmast:JWST/product/jw01541001001_04102_00001-seg001_nis_rateints.fitsPUBLICFalsenan85700205410291724
scienceJWSTCALJWSTNIRISS/SOSSJWSTCLEAR;GR700XDInfraredCD-38-2551Star; G starsjw02113-o005_t001_niriss_clear-gr700xd-substrip25694.33630544540856-38.32344481007381spectrumEspinoza, Nestor360215.7568526273260216.2504900925932810.168600.02800.0Exploring the morning and evening limbs of a transiting exoplanet60582.963425882113GO--POLYGON 94.38208655 -38.32834702 94.33350101 -38.32815311 94.3336111 -38.31941978 94.38219433 -38.31961643 94.38208655 -38.32834702--mast:JWST/product/jw02113-o005_t001_niriss_clear-gr700xd-substrip256_x1dints.fitsEXCLUSIVE_ACCESSFalsenan188165781419720818
scienceJWSTCALJWSTNIRISS/SOSSJWSTCLEAR;GR700XDInfraredCD-38-2551Star; G starsjw02113005001_04103_00001-seg001_nis94.33630544130956-38.32344481509817imageEspinoza, Nestor260216.252828391260216.257597488424329.64600.02800.0Exploring the morning and evening limbs of a transiting exoplanet60582.576261422113GO--POLYGON 94.343932683 -38.287734535 94.342195697 -38.325771711 94.331098247 -38.325419041 94.332829036 -38.287380655mast:JWST/product/jw02113005001_04103_00001-seg001_nis_ramp.jpgmast:JWST/product/jw02113005001_04103_00001-seg001_nis_rateints.fitsEXCLUSIVE_ACCESSFalsenan178895888419793917
scienceJWSTCALJWSTNIRISS/SOSSJWSTCLEAR;GR700XDInfraredCD-38-2551Star; G starsjw02113005001_04101_00001-seg001_nis94.33630544945105-38.3234448051187spectrumEspinoza, Nestor260215.7743559722260215.774483148155.494600.02800.0Exploring the morning and evening limbs of a transiting exoplanet60582.584108712113GO--POLYGON 94.38208655 -38.32834702 94.33350101 -38.32815311 94.33361111 -38.31941977 94.38219434 -38.31961642 94.38208655 -38.32834702mast:JWST/product/jw02113005001_04101_00001-seg001_nis_ramp.jpgmast:JWST/product/jw02113005001_04101_00001-seg001_nis_x1dints.fitsEXCLUSIVE_ACCESSFalsenan178895938419794011

Our query returned many NIRISS observations led by the PI Dr. Espinoza. Let’s get all the unique values under the instrument_name column to see what our * wildcard picked up.

set(observations['instrument_name'])
{'NIRISS/IMAGE', 'NIRISS/SOSS'}

Our observations have the advanced labeling; had we simply set instrument_name = "NIRISS", we would have missed several observations. For more details on this advanced labeling, see the JWST Instrument Names page.

A note of caution: There is such a thing as too many wildcards#

You can be too generous with the wildcards, so be sure to exercise caution in their use. Too much ambiguity can lead to unintended results. Let’s take a look at our example below.

observations = Observations.query_criteria(proposal_pi='Espinoza, Nestor',
                                           instrument_name='NIR*') # Surely only one instrument begins with 'NIR'
set(observations['instrument_name'])
{'NIRISS/IMAGE', 'NIRISS/SOSS', 'NIRSPEC/SLIT'}

This query returns NIRSPEC/SLIT observations in addition to the NIRISS ones, which is not what we intended.

Case 2: Wildcard Search with instrument_name and proposal_id#

Let’s add an additional string criterion and wildcard into the mix. We’ll do this with the proposal_id field which, despite its numeric content, is encoded as a string.

Let’s query for a four digit proposal/program IDs that begin with 15.

observations = Observations.query_criteria(proposal_pi='Espinoza, Nestor',
                                           instrument_name='NIRISS*',
                                           proposal_id=['15%%']) # Only a four digit result will match this

set(observations['proposal_id']), set(observations['instrument_name'])
({'1512', '1541'}, {'NIRISS/IMAGE', 'NIRISS/SOSS'})

Resources#

The following is a list of resources that were referenced throughout the tutorial, as well as some additional references that you may find useful:

Citations#

If you use any of astroquery’s tools for published research, please cite the authors. Follow this link for more information about citing astroquery:

About This Notebook#

If you have comments or questions on this notebook, please contact us through the Archive Help Desk e-mail at archive@stsci.edu.

Author: Jenny V. Medina
Keywords: astroquery, wildcards, moving target
Last Updated: Jun 2023