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=215
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
str7str4str7str12str4str13str8str14str54str50float64float64str8str16int64float64float64float64float64float64str70float64str4str3int64str132str80str81str16boolfloat64str9str9
scienceJWSTCALJWSTNIRISS/IMAGEJWSTCLEAR;GR700XDINFRAREDECLIPTIC-RA00Calibration; External flat fieldjw06658001003_02101_00001_nis9.3443875000000021.4307027777777779imageEspinoza, Nestor260530.7856818579960530.78704880787107.368600.02800.0CAL-NIS-307: SOSS background measurements60530.885277756658CAL--POLYGON 9.344550746 1.455702688 9.358224471 1.421160565 9.323392567 1.407557659 9.30969731 1.442081402mast:JWST/product/jw06658001003_02101_00001_nis_trapsfilled.jpgmast:JWST/product/jw06658001003_02101_00001_nis_rateints.fitsPUBLICFalsenan226985742636156275
scienceJWSTCALJWSTNIRISS/IMAGEJWSTCLEAR;GR700XDINFRAREDECLIPTIC-RA00Calibration; External flat fieldjw06658003004_02101_00001_nis9.3443875000000021.4307027777777779imageEspinoza, Nestor260530.88215582789460530.883522777774107.368600.02800.0CAL-NIS-307: SOSS background measurements60530.905671246658CAL--POLYGON 9.335836498 1.452299597 9.349510318 1.41775752 9.314678511 1.404154498 9.30098316 1.438678197mast:JWST/product/jw06658003004_02101_00001_nis_trapsfilled.jpgmast:JWST/product/jw06658003004_02101_00001_nis_rateints.fitsPUBLICFalsenan226985837636156315
scienceJWSTCALJWSTNIRISS/IMAGEJWSTCLEAR;GR700XDINFRAREDECLIPTIC-RA00Calibration; External flat fieldjw06658003002_02101_00001_nis9.3443875000000021.4307027777777779imageEspinoza, Nestor260530.86846622141560530.869833171295107.368600.02800.0CAL-NIS-307: SOSS background measurements60530.912106426658CAL--POLYGON 9.347931047 1.447052121 9.361604649 1.41250997 9.326772847 1.398907136 9.313077715 1.433430909mast:JWST/product/jw06658003002_02101_00001_nis_trapsfilled.jpgmast:JWST/product/jw06658003002_02101_00001_nis_rateints.fitsPUBLICFalsenan226985735636156336
scienceJWSTCALJWSTNIRISS/SOSSJWSTCLEAR;GR700XDINFRAREDCD-38-2551Star; G starsjw02113002001_02101_00001-seg001_nis94.33630545031605-38.323444804058404spectrumEspinoza, Nestor260215.7202297858860215.72644319444429.471600.02800.0Exploring the morning and evening limbs of a transiting exoplanet60845.280925872113GO--POLYGON 94.372810846 -38.289090732 94.37114681 -38.326216279 94.323531402 -38.324727658 94.325185848 -38.287610984mast:JWST/product/jw02113002001_02101_00001-seg001_nis_ramp.jpgmast:JWST/product/jw02113002001_02101_00001-seg001_nis_x1dints.fitsEXCLUSIVE_ACCESSFalsenan178895222636185607
scienceJWSTCALJWSTNIRISS/SOSSJWSTF480MINFRAREDBD+60-1753Star; A dwarfsjw01512010001_02101_00001_nis261.2178777057847660.43078853326643imageEspinoza, Nestor259996.10708085648459996.107089282410.6834600.05000.0SOSS Wavelength and Trace59996.468379671512CAL--POLYGON 261.218587306 60.430032501 261.216376898 60.430453506 261.21721589 60.431537097 261.219426562 60.431116057mast:JWST/product/jw01512010001_02101_00001_nis_cal.jpgmast:JWST/product/jw01512010001_02101_00001_nis_cal.fitsPUBLICFalsenan117933862636189446
scienceJWSTCALJWSTNIRISS/IMAGEJWSTCLEAR;GR700XDINFRAREDBD+60-1753Star; A dwarfsjw01512006001_03102_00001_nis261.2178777054549560.430788533141374imageEspinoza, Nestor259996.0620702546359996.064613773146164.82600.02800.0SOSS Wavelength and Trace59996.110925951512CAL--POLYGON 261.252753029 60.462639955 261.225211115 60.427085449 261.208745647 60.4302301 261.236255005 60.465792348mast:JWST/product/jw01512006001_03102_00001_nis_trapsfilled.jpgmast:JWST/product/jw01512006001_03102_00001_nis_rateints.fitsPUBLICFalsenan117933689636189451
scienceJWSTCALJWSTNIRISS/SOSSJWSTF480MINFRAREDBD+60-1753Star; A dwarfsjw01512010001_02101_00003_nis261.217877705797860.430788533271375imageEspinoza, Nestor259996.10881122685559996.108819652780.6834600.05000.0SOSS Wavelength and Trace59996.468263931512CAL--POLYGON 261.21842809 60.430081991 261.216217671 60.430502988 261.217056647 60.431586582 261.21926733 60.431165551mast:JWST/product/jw01512010001_02101_00003_nis_cal.jpgmast:JWST/product/jw01512010001_02101_00003_nis_cal.fitsPUBLICFalsenan117933863636189460
scienceJWSTCALJWSTNIRISS/SOSSJWSTF480MINFRAREDBD+60-1753Star; A dwarfsjw01512006001_02101_00003_nis261.2178777053960.43078853311674imageEspinoza, Nestor259996.0547201736159996.0547285995340.6834600.05000.0SOSS Wavelength and Trace59996.436527761512CAL--POLYGON 261.218428495 60.430081708 261.21621888 60.430503731 261.217059923 60.431586935 261.219269801 60.431164877mast:JWST/product/jw01512006001_02101_00003_nis_cal.jpgmast:JWST/product/jw01512006001_02101_00003_nis_cal.fitsPUBLICFalsenan117933690636189468
scienceJWSTCALJWSTNIRISS/SOSSJWSTF480MINFRAREDBD+60-1753Star; A dwarfsjw01512010001_02101_00004_nis261.217877705832860.43078853328465imageEspinoza, Nestor259996.1134549305659996.113463356480.6834600.05000.0SOSS Wavelength and Trace59996.468449111512CAL--POLYGON 261.218556578 60.43004605 261.216346162 60.430467047 261.217185139 60.431550641 261.219395818 60.431129609mast:JWST/product/jw01512010001_02101_00004_nis_cal.jpgmast:JWST/product/jw01512010001_02101_00004_nis_cal.fitsPUBLICFalsenan117933864636189471
...................................................................................................
scienceJWSTCALJWSTNIRISS/IMAGEJWSTCLEAR;GR700XDINFRAREDECLIPTIC-RA80Calibration; External flat fieldjw01541005001_02105_00001_nis124.1008916666666819.23126111111111imageEspinoza, Nestor259688.6305772531359688.634181030095300.63600.02800.0NIRISS Sensitivity and Stability for Transiting Exoplanet Observations59774.85416661541COM--POLYGON 124.085148743 19.218701569 124.093993665 19.254899234 124.132537371 19.246329833 124.123713719 19.21013701mast:JWST/product/jw01541005001_02105_00001_nis_trapsfilled.jpgmast:JWST/product/jw01541005001_02105_00001_nis_rateints.fitsPUBLICFalsenan79661727636536785
scienceJWSTCALJWSTNIRISS/IMAGEJWSTCLEAR;GR700XDINFRAREDECLIPTIC-RA80Calibration; External flat fieldjw01541005001_0210r_00001_nis124.1008916666666819.23126111111111imageEspinoza, Nestor259688.68771645451559688.69132023148300.63600.02800.0NIRISS Sensitivity and Stability for Transiting Exoplanet Observations59774.85416661541COM--POLYGON 124.07284721 19.21839799 124.081689382 19.25459625 124.120233664 19.246029444 124.111412762 19.209836026mast:JWST/product/jw01541005001_0210r_00001_nis_trapsfilled.jpgmast:JWST/product/jw01541005001_0210r_00001_nis_rateints.fitsPUBLICFalsenan79661746636536792
scienceJWSTCALJWSTNIRISS/IMAGEJWSTCLEAR;GR700XDINFRAREDECLIPTIC-RA80Calibration; External flat fieldjw01541005001_0210f_00001_nis124.1008916666666819.23126111111111imageEspinoza, Nestor259688.65653278553559688.6601365625300.63600.02800.0NIRISS Sensitivity and Stability for Transiting Exoplanet Observations59774.85416661541COM--POLYGON 124.078634483 19.217102483 124.087477844 19.253300468 124.126021524 19.244732468 124.117199434 19.208539324mast:JWST/product/jw01541005001_0210f_00001_nis_trapsfilled.jpgmast:JWST/product/jw01541005001_0210f_00001_nis_rateints.fitsPUBLICFalsenan79661763636536801
scienceJWSTCALJWSTNIRISS/IMAGEJWSTCLEAR;GR700XDINFRAREDECLIPTIC-RA80Calibration; External flat fieldjw01541005001_0210z_00001_nis124.1008916666666819.23126111111111imageEspinoza, Nestor259688.7084919984959688.71209577546300.63600.02800.0NIRISS Sensitivity and Stability for Transiting Exoplanet Observations59774.85416661541COM--POLYGON 124.069226757 19.216150803 124.078067971 19.252349246 124.116611924 19.243783236 124.10779198 19.207589636mast:JWST/product/jw01541005001_0210z_00001_nis_trapsfilled.jpgmast:JWST/product/jw01541005001_0210z_00001_nis_rateints.fitsPUBLICFalsenan79661781636536808
scienceJWSTCALJWSTNIRISS/IMAGEJWSTCLEAR;GR700XDINFRAREDECLIPTIC-RA80Calibration; External flat fieldjw01541005001_0210d_00001_nis124.1008916666666819.23126111111111imageEspinoza, Nestor259688.6513424267459688.6549462037300.63600.02800.0NIRISS Sensitivity and Stability for Transiting Exoplanet Observations59774.85416661541COM--POLYGON 124.077907696 19.214207662 124.086750759 19.250405679 124.125293793 19.241837815 124.116472001 19.205644639mast:JWST/product/jw01541005001_0210d_00001_nis_trapsfilled.jpgmast:JWST/product/jw01541005001_0210d_00001_nis_rateints.fitsPUBLICFalsenan79661804636536817
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.23723653mast:JWST/product/jw01541-o001_t002_niriss_clear-gr700xd-substrip256_x1dints.pngmast:JWST/product/jw01541-o001_t002_niriss_clear-gr700xd-substrip256_x1dints.fitsPUBLICFalsenan213209384637068410
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.fitsPUBLICFalsenan85700205637068577
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.32834702mast:JWST/product/jw02113-o005_t001_niriss_clear-gr700xd-substrip256_x1dints.pngmast:JWST/product/jw02113-o005_t001_niriss_clear-gr700xd-substrip256_x1dints.fitsPUBLICFalsenan188165781638680140
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.fitsPUBLICFalsenan178895888638699295
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.fitsPUBLICFalsenan178895938638699419

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'])
{np.str_('NIRISS/IMAGE'), np.str_('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'])
{np.str_('NIRISS/IMAGE'), np.str_('NIRISS/SOSS'), np.str_('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'])
({np.str_('1512'), np.str_('1541')},
 {np.str_('NIRISS/IMAGE'), np.str_('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