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
obs_idObservation IDstringObservation identifier, given by missionU24Z0101T, N4QF18030
..................
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=94
intentTypeobs_collectionprovenance_nameinstrument_nameprojectfilterswavelength_regiontarget_nametarget_classificationsequence_numberobs_ids_ras_decproposal_idproposal_pidataproduct_typecalib_levelt_mint_maxt_exptimeem_minem_maxobs_titlet_obs_releaseproposal_typedataRightsmtFlagobsidobjID
str7str4str7str12str4str13str8str13str54int64str50float64float64str4str16str8int64float64float64float64float64float64str70float64str3str16boolstr9str9
scienceJWSTCALJWSTNIRISS/IMAGEJWSTCLEAR;GR700XDInfraredBD+60-1753Star; A dwarfs--jw01512001001_03101_00001_nis261.217877704760460.4307885328781512Espinoza, Nestorimage259995.97115187559995.971279050935.494600.02800.0SOSS Wavelength and Trace59996.02417822CALPUBLICFalse117933676317525309
scienceJWSTCALJWSTNIRISS/SOSSJWSTF480MInfraredBD+60-1753Star; A dwarfs--jw01512002001_02101_00001_nis261.217877704834360.430788532906031512Espinoza, Nestorimage259995.9810135763959995.981022002310.6834600.05000.0SOSS Wavelength and Trace59996.18175925CALPUBLICFalse117933629317525330
scienceJWSTCALJWSTNIRISS/IMAGEJWSTCLEAR;GR700XDInfraredBD+60-1753Star; A dwarfs--jw01512001001_03102_00001_nis261.217877704776560.430788532884111512Espinoza, Nestorimage259995.9720777430659995.97462126157164.82600.02800.0SOSS Wavelength and Trace59996.02564814CALPUBLICFalse117933623317525334
scienceJWSTCALJWSTNIRISS/SOSSJWSTF480MInfraredBD+60-1753Star; A dwarfs--jw01512003001_02101_00003_nis261.217877704982160.430788532962071512Espinoza, Nestorimage259996.000616516259996.000624942130.6834600.05000.0SOSS Wavelength and Trace59996.22311345CALPUBLICFalse117933684317525350
scienceJWSTCALJWSTNIRISS/SOSSJWSTF480MInfraredBD+60-1753Star; A dwarfs--jw01512001001_02101_00001_nis261.217877704700160.430788532855141512Espinoza, Nestorimage259995.9632113657459995.963219791670.6834600.05000.0SOSS Wavelength and Trace59996.16189809CALPUBLICFalse117933677317525361
scienceJWSTCALJWSTNIRISS/SOSSJWSTF480MInfraredBD+60-1753Star; A dwarfs--jw01512002001_02101_00004_nis261.217877704882460.430788532924291512Espinoza, Nestorimage259995.9874009722259995.987409398150.6834600.05000.0SOSS Wavelength and Trace59996.18133101CALPUBLICFalse117933631317525364
scienceJWSTCALJWSTNIRISS/SOSSJWSTF480MInfraredBD+60-1753Star; A dwarfs--jw01512003001_02101_00002_nis261.217877704975660.430788532959631512Espinoza, Nestorimage259995.9997631828759995.99977160880.6834600.05000.0SOSS Wavelength and Trace59996.22358799CALPUBLICFalse117933685317525369
scienceJWSTCALJWSTNIRISS/SOSSJWSTF480MInfraredBD+60-1753Star; A dwarfs--jw01512002001_02101_00003_nis261.217877704847260.430788532910941512Espinoza, Nestorimage259995.9827313541759995.982739780090.6834600.05000.0SOSS Wavelength and Trace59996.18243051CALPUBLICFalse117933632317525397
scienceJWSTCALJWSTNIRISS/SOSSJWSTF480MInfraredBD+60-1753Star; A dwarfs--jw01512001001_02101_00002_nis261.217877704706560.430788532857581512Espinoza, Nestorimage259995.9640646990759995.9640731250.6834600.05000.0SOSS Wavelength and Trace59996.1616898CALPUBLICFalse117933622317525399
scienceJWSTCALJWSTNIRISS/SOSSJWSTF480MInfraredBD+60-1753Star; A dwarfs--jw01512003001_02101_00004_nis261.217877705017460.430788532975451512Espinoza, Nestorimage259996.0052950347259996.005303460650.6834600.05000.0SOSS Wavelength and Trace59996.22332179CALPUBLICFalse117933686317525416
.......................................................................................
scienceJWSTCALJWSTNIRISS/SOSSJWSTCLEAR;GR700XDInfraredHAT-P-14----jw01541001001_04101_00001-seg001_nis260.116173674233238.242164720538971541Espinoza, Nestorspectrum259738.2978802893559738.5524864930618855.408600.02800.0NIRISS Sensitivity and Stability for Transiting Exoplanet Observations59774.8541666COMPUBLICFalse85700117335565636
scienceJWSTCALJWSTNIRISS/SOSSJWSTCLEAR;GR700XDInfraredHAT-P-14Star; Exoplanet Systems; Exoplanets; F dwarfs; F stars--jw01541001001_04101_00001-seg004_nis260.116177163084438.242156511096131541Espinoza, Nestorspectrum259738.2978802893559738.5524864930618855.408600.02800.0NIRISS Sensitivity and Stability for Transiting Exoplanet Observations59774.8541666COMPUBLICFalse85700141335565664
scienceJWSTCALJWSTNIRISS/SOSSJWSTCLEAR;GR700XDInfraredHAT-P-14Star; Exoplanet Systems; Exoplanets; F dwarfs; F stars--jw01541001001_02101_00002-seg001_nis260.116177162730538.242156511928921541Espinoza, Nestorimage259738.2620806944559738.262091226850.954600.02800.0NIRISS Sensitivity and Stability for Transiting Exoplanet Observations59774.8541666COMPUBLICFalse85700160335565688
scienceJWSTCALJWSTNIRISS/SOSSJWSTCLEAR;GR700XDInfraredHAT-P-14Star; Exoplanet Systems; Exoplanets; F dwarfs; F stars--jw01541001001_02101_00001-seg001_nis260.116177162728738.242156511933341541Espinoza, Nestorimage259738.2612162559738.261226782410.954600.02800.0NIRISS Sensitivity and Stability for Transiting Exoplanet Observations59774.8541666COMPUBLICFalse85700178335565712
scienceJWSTCALJWSTNIRISS/SOSSJWSTCLEAR;GR700XDInfraredHAT-P-14Star; Exoplanet Systems; Exoplanets; F dwarfs; F stars--jw01541001001_04101_00001-seg003_nis260.116177163084438.242156511096131541Espinoza, Nestorspectrum259738.2978802893559738.5524864930618855.408600.02800.0NIRISS Sensitivity and Stability for Transiting Exoplanet Observations59774.8541666COMPUBLICFalse85700237335565746
scienceJWSTCALJWSTNIRISS/SOSSJWSTCLEAR;GR700XDInfraredHAT-P-14----jw01541001001_04101_00001-seg002_nis260.116173674233238.242164720538971541Espinoza, Nestorspectrum259738.2978802893559738.5524864930618855.408600.02800.0NIRISS Sensitivity and Stability for Transiting Exoplanet Observations59774.8541666COMPUBLICFalse85700224335565788
scienceJWSTCALJWSTNIRISS/SOSSJWSTCLEAR;GR700XDInfraredHAT-P-14Star; Exoplanet Systems; Exoplanets; F dwarfs; F stars--jw01541001001_04102_00001-seg001_nis260.116177163368638.242156510427481541Espinoza, Nestorimage259738.5539086689859738.55835982639329.64600.02800.0NIRISS Sensitivity and Stability for Transiting Exoplanet Observations59774.8541666COMPUBLICFalse85700205335565819
scienceJWSTCALJWSTNIRISS/SOSSJWSTCLEAR;GR700XDInfraredCD-38-2551Star; G stars--jw02113-o005_t001_niriss_clear-gr700xd-substrip25694.33630544540856-38.323444810073812113Espinoza, Nestorspectrum360215.7568526273260216.2504900925932810.168600.02800.0Exploring the morning and evening limbs of a transiting exoplanet60582.96342588GOEXCLUSIVE_ACCESSFalse188165781340693902
scienceJWSTCALJWSTNIRISS/SOSSJWSTCLEAR;GR700XDInfraredCD-38-2551Star; G stars--jw02113005001_04103_00001-seg001_nis94.33630544130956-38.323444815098172113Espinoza, Nestorimage260216.252828391260216.25759748842329.64600.02800.0Exploring the morning and evening limbs of a transiting exoplanet60582.57626142GOEXCLUSIVE_ACCESSFalse178895888340696498
scienceJWSTCALJWSTNIRISS/SOSSJWSTCLEAR;GR700XDInfraredCD-38-2551Star; G stars--jw02113005001_04101_00001-seg001_nis94.33630544945105-38.32344480511872113Espinoza, Nestorspectrum260215.7743559722260215.774483148155.494600.02800.0Exploring the morning and evening limbs of a transiting exoplanet60582.58410871GOEXCLUSIVE_ACCESSFalse178895938340696553

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