Astroquery: Exploring Metadata from the James Webb Space Telescope#


Learning Goals#

By the end of this tutorial, you will:

  • Understand how to use the astroquery.mast module to access metadata from the James Webb Space Telescope (JWST).

  • Run metadata queries based on coordinates, an object name, or non-positional criteria.

  • Use optional search parameters to further refine query results.

Table of Contents#

Introduction#

Welcome! This tutorial focuses on using the astroquery.mast module to search for metadata from the James Webb Space Telescope (JWST). Launched in December of 2021, JWST is an advanced space observatory designed for observations in the infrared light spectrum.

The Mikulski Archive for Space Telescopes (MAST) hosts publicly accessible data products from space telescopes like JWST. astroquery.mast provides access to a broad set of JWST metadata, including header keywords, proposal information, and observational parameters. The available metadata can also be found using the MAST JWST Search interface.

Please note that astroquery.mast.MastMissions and the MAST JWST Search API do not yet support data product downloads.

Imports#

This notebook uses the following packages:

  • astroquery.mast to query the MAST Archive

  • astropy.coordinates to assign coordinates of interest

from astroquery.mast import MastMissions
from astropy.coordinates import SkyCoord

Querying MAST for JWST Metadata#

Setup#

In order to make queries on JWST metadata, we will have to perform some setup. First, we will instantiate an object of the MastMissions class and assign its mission to be 'jwst'. Its service is set to the default of 'search'.

# Create MastMissions object and assign mission to 'jwst'
missions = MastMissions(mission='jwst')

print(f'Mission: {missions.mission}')
print(f'Service: {missions.service}')
Mission: jwst
Service: search

When writing queries, keyword arguments can be used to specify output characteristics (see the following section) and filter on values like instrument, exposure type, and proposal ID. The available column names for a mission are returned by the get_column_list function. Below, we will print out the name, data type, and description for the first 10 columns in JWST metadata.

# Get available columns for JWST mission
columns = missions.get_column_list()
columns[:10]
Table length=10
namedata_typedescription
str17str9str1594
search_posstringSearch Position (RA and Dec)
ArchiveFileIDintegerArchiveFileID
fileSetNamestringOf the form jwpppppooovvv_ggsaa_eeeee where ppppp - Program Number, ooo - Observation Number, vvv - Visit Number, gg - Visit Group, s - Parallel Sequence id (1 prime, 2-5 parallel), aa - Activity (base 36), and eeeee - Exposure Number, all padded by zeros where necessary. Source-based data set names are expressed as jwppppp-oOOO_tTTT_instrument, where: ppppp - Program number, OOO - observation number, TTT - target number, and instrument - Instrument name
productLevelstringProduct levels, 1b is an Uncal FITS file, 2a = Countrate exposure, 2b = calibrated exposure, 2c = cosmic-ray-flagged exposure, and 3 = combined data.
targpropstringProposer prefered name for the target
targnamestringStandard astronomical catalog name for the target
targ_raraRight Ascension (J2000), from 0 to 360, in degrees
targ_decdecDeclination (J2000), from -90 to +90, in degrees
instrumestringIdentifies the instrument used to acquire the data.
exp_typestringExposure type is used by DMS to direct Science Data Processing code (SDP) and calibration, as well as provide metadata for archive searches. For a given template the EXP_TYPE keyword value is obtained for each exposure from the EXPOSURE_TYPE exposure-level parameter in the Observatory Status File (OSF). In a few cases, additional information is required to set the value for the EXP_TYPE keyword

Optional Search Parameters#

Before we dive in to the actual queries, it’s important to know how we can refine our results with optional keyword arguments. The following parameters are available:

  • radius: For positional searches only. Only return results within a certain distance from an object or set of coordinates. Default is 3 arcminutes.

  • limit: The maximum number of results to return. Default is 5000.

  • offset: Skip the first n results. Useful for paging through results.

  • select_cols: A list of columns to be returned in the response.

As we walk through different types of queries, we will see these parameters in action!

Query by Object Name#

We’ve reached our first query! We can use object names to perform metadata queries using the query_object function.

To start, let’s query for the Messier 1 object, a supernova remnant in the Taurus constellation. You may know it better as the Crab Nebula!

# Query for Messier 1 ('M1')
results = missions.query_object('M1')

# Display the first 5 results
print(f'Total number of results: {len(results)}')
results[:5]
Total number of results: 249
Table masked=True length=5
ArchiveFileIDfileSetNameproductLeveltargproptarg_ratarg_decinstrumeexp_typeopticalElementsdate_obsdurationprogramobservtnvisitpublicReleaseDatepi_nameproposal_typeproposal_cycletargtypeaccesscal_verang_seps_region
int64str25str14str18float64float64str6str9str153str27float64int64int64int64str19str10str2int64str5str6str6float64str117
202227346jw01714001003_02101_000011b, 2a, 2b, 2cCRAB-NEBULA83.6360495833333322.01641666666667MIRIMIR_IMAGEF560W2023-02-24T02:49:57.2040000138.7521714132024-02-24T13:38:23Temim, TeaGO1FIXEDPUBLIC1.19.10.0POLYGON ICRS 83.620720664 22.002796071 83.654438843 22.001843601 83.655520407 22.033240536 83.621749133 22.034484397
202227407jw01714001003_02101_000021b, 2a, 2b, 2cCRAB-NEBULA83.6360495833333322.01641666666667MIRIMIR_IMAGEF560W2023-02-24T02:53:39.2200000138.7521714132024-02-24T13:38:36Temim, TeaGO1FIXEDPUBLIC1.19.10.0POLYGON ICRS 83.615681886 22.003125717 83.649400180 22.002174326 83.650480576 22.033571296 83.616709178 22.034814075
202227359jw01714001003_02101_000031b, 2a, 2b, 2cCRAB-NEBULA83.6360495833333322.01641666666667MIRIMIR_IMAGEF560W2023-02-24T02:57:23.9880000138.7521714132024-02-24T13:36:13Temim, TeaGO1FIXEDPUBLIC1.19.10.0POLYGON ICRS 83.616485032 22.007527317 83.650204366 22.006575751 83.651284987 22.037972715 83.617512546 22.039215670
202227230jw01714001003_02101_000041b, 2a, 2b, 2cCRAB-NEBULA83.6360495833333322.01641666666667MIRIMIR_IMAGEF560W2023-02-24T03:01:06.0030000138.7521714132024-02-24T13:35:43Temim, TeaGO1FIXEDPUBLIC1.19.10.0POLYGON ICRS 83.620343760 22.006724973 83.654062878 22.005772644 83.655144319 22.037169584 83.621372102 22.038413302
202227236jw01714001003_02103_000011b, 2a, 2b, 2cCRAB-NEBULA83.6360495833333322.01641666666667MIRIMIR_IMAGEF1130W2023-02-24T03:06:50.0870000105.4521714132024-02-24T13:36:54Temim, TeaGO1FIXEDPUBLIC1.19.10.0POLYGON ICRS 83.620704104 22.002803649 83.654421963 22.001850980 83.655503419 22.033248128 83.621732711 22.034491896

There were 250 total results, meaning that 250 JWST datasets were targeting the Crab Nebula. Now, let’s try refining our search a bit more.

  • Each dataset is associated with a celestial coordinate, given by targ_ra (right ascension) and targ_dec (declination). By default, the query returns all datasets that fall within 3 arcminutes from the object’s coordinates. Let’s set the radius parameter to be 1 arcminute instead.

  • Say that we’re not interested in the first 4 results. We can assign offset to skip a certain number of rows.

  • By default, a subset of recommended columns are returned for each query. However, we can specify exactly which columns to return using the select_cols keyword argument. The ArchiveFileID column is included automatically.

# Refined query for Messier 1 ('M1')
results = missions.query_object('M1',
                                radius=1,  # Search within a 1 arcminute radius
                                offset=4,  # Skip the first 4 results
                                select_cols=['fileSetName', 'targprop', 'date_obs'])  # Select certain columns

# Display the first 5 results
print(f'Total number of results: {len(results)}')
results[:5]
Total number of results: 161
Table masked=True length=5
ArchiveFileIDfileSetNametargpropdate_obss_region
int64str25str18str27str117
202227236jw01714001003_02103_00001CRAB-NEBULA2023-02-24T03:06:50.0870000POLYGON ICRS 83.620704104 22.002803649 83.654421963 22.001850980 83.655503419 22.033248128 83.621732711 22.034491896
202227212jw01714001003_02103_00002CRAB-NEBULA2023-02-24T03:09:58.8230000POLYGON ICRS 83.615665261 22.003133413 83.649383236 22.002181860 83.650463486 22.033579043 83.616692652 22.034821694
202225507jw01714001003_02103_00003CRAB-NEBULA2023-02-24T03:13:07.5590000POLYGON ICRS 83.616468314 22.007534974 83.650187330 22.006583256 83.651267794 22.037980433 83.617495916 22.039223250
202226882jw01714001003_02103_00004CRAB-NEBULA2023-02-24T03:16:18.9830000POLYGON ICRS 83.620327068 22.006732644 83.654045867 22.005780159 83.655127156 22.037177312 83.621355503 22.038420897
202226676jw01714001003_02105_00001CRAB-NEBULA2023-02-24T03:21:10.3800000POLYGON ICRS 83.620699810 22.002811293 83.654417696 22.001858643 83.655498939 22.033255860 83.621728466 22.034499565

Exercise 1#

Now it’s your turn! Try querying for the Whirlpool Galaxy object. Search within a radius of 1 arcminute, skip the first 300 results, and select the fileSetName and opticalElements columns.

# # Query for Whirlpool Galaxy
# results = missions.query_object(...)  # Write your query!

# # Display the first 5 results
# print(f'Total number of results: {len(results)}')
# results[:5]

Query by Region#

The missions object also allows us to query by a region in the sky. By passing in a set of coordinates to the query_region function, we can return datasets that fall within a certain radius value of that point. This type of search is also known as a cone search.

# Create coordinate object
coords = SkyCoord(210.80227, 54.34895, unit=('deg'))

# Query for results within 10 arcminutes of coords
results = missions.query_region(coords, radius=10)

# Display results
print(f'Total number of results: {len(results)}')
results[:5]
Total number of results: 478
Table masked=True length=5
ArchiveFileIDfileSetNameproductLeveltargproptarg_ratarg_decinstrumeexp_typeopticalElementsdate_obsdurationprogramobservtnvisitpublicReleaseDatepi_nameproposal_typeproposal_cycletargtypeaccesscal_verang_seps_region
int64str36str14str25float64float64str7str17str89str27float64int64int64int64str19str25str6int64str7str6str6float64str121
216713031jw01995001002_02101_000011b, 2a, 2b, 2cMESSIER-101210.87646554.36092777777778NIRCAMNRC_IMAGEF115W;CLEAR, F444W;CLEAR2023-05-30T15:53:41.4040000311.3661995122024-05-30T23:57:44Freedman, Wendy L.GO1FIXEDPUBLIC1.20.20.0POLYGON ICRS 210.911618011 54.374886063 210.929457447 54.360746186 210.953599146 54.370957412 210.936068288 54.385179847
216712862jw01995001002_02101_000021b, 2a, 2b, 2cMESSIER-101210.87646554.36092777777778NIRCAMNRC_IMAGEF115W;CLEAR, F444W;CLEAR2023-05-30T16:00:29.4680000311.3661995122024-05-30T23:55:45Freedman, Wendy L.GO1FIXEDPUBLIC1.20.20.0POLYGON ICRS 210.866658537 54.378880493 210.904087983 54.349991526 210.953023924 54.371061598 210.917087526 54.400261542
216712749jw01995001002_02101_000031b, 2a, 2b, 2cMESSIER-101210.87646554.36092777777778NIRCAMNRC_IMAGEF115W;CLEAR, F444W;CLEAR2023-05-30T16:07:06.6520000311.3661995122024-05-30T23:55:43Freedman, Wendy L.GO1FIXEDPUBLIC1.20.20.0POLYGON ICRS 210.892476657 54.390231609 210.910438658 54.375790692 210.934979706 54.386035265 210.917406143 54.400589853
216712650jw01995001003_02101_000011b, 2a, 2b, 2cMESSIER-101210.87646554.36092777777778NIRCAMNRC_IMAGEF115W;CLEAR, F444W;CLEAR2023-05-30T16:23:18.8750000311.3661995132024-05-30T23:49:52Freedman, Wendy L.GO1FIXEDPUBLIC1.20.20.0POLYGON ICRS 210.795561580 54.357496515 210.813811095 54.343152271 210.838275439 54.353607849 210.820276117 54.368181350
216712089jw01995001003_02101_000021b, 2a, 2b, 2cMESSIER-101210.87646554.36092777777778NIRCAMNRC_IMAGEF115W;CLEAR, F444W;CLEAR2023-05-30T16:29:56.1860000311.3661995132024-05-30T23:42:15Freedman, Wendy L.GO1FIXEDPUBLIC1.20.20.0POLYGON ICRS 210.795351462 54.357489588 210.813601198 54.343145441 210.838065375 54.353601149 210.820065827 54.368174554

395 JWST datasets fall within our cone search. In other words, their target coordinates are within 10 arcminutes of the coordinates that we defined.

Exercise 2:#

JWST has observed the star Vega, which has a right ascension of 279.23473 degrees and a declination of 38.78369 degrees. Use the query_region function to search for datasets within 15 arcminutes of Vega. Select the fileSetName, targprop, targ_ra, and targ_dec columns.

# # Vega coordinates
# vega = SkyCoord(_, _, unit=('deg'))  # Fill in with Vega's coordinates

# # Query for datasets around Vega
# results = missions.query_region(...)  # Write your query!

# # Display the first 5 results
# print(f'Total number of results: {len(results)}')
# results[:5]

Query by Criteria#

In some cases, we may want to run queries with non-positional parameters. To accomplish this, we use the query_criteria function.

For any of our query functions, we can filter our results by the value of columns in the dataset.

Let’s say that we only want observations from JWST’s Near Infrared Camera (NIRCam) instrument, and that we only want datasets connected to program number 1189.

# Query with column criteria
results = missions.query_criteria(instrume='NIRCAM',  # From Near Infrared Camera
                                  program=1189,
                                  select_cols=['fileSetName', 'instrume', 'exp_type', 'program', 'pi_name'])

# Display the first 5 results
print(f'Total number of results: {len(results)}')
results[:5]
Total number of results: 79
Table masked=True length=5
ArchiveFileIDfileSetNameinstrumeexp_typeprogrampi_names_region
int64str25str6str13int64str17str121
205632636jw01189010001_02101_00001NIRCAMNRC_IMAGE1189Roellig, Thomas LPOLYGON ICRS 277.120925692 26.849950982 277.144958937 26.820792259 277.177196644 26.841516114 277.154135422 26.870965715
205632493jw01189010001_02101_00002NIRCAMNRC_IMAGE1189Roellig, Thomas LPOLYGON ICRS 277.119751279 26.847595543 277.131677837 26.833163977 277.147709697 26.843518895 277.136071545 26.858021322
205632426jw01189010001_02101_00003NIRCAMNRC_IMAGE1189Roellig, Thomas LPOLYGON ICRS 277.119330391 26.845316385 277.131256758 26.830884851 277.147288259 26.841239813 277.135650292 26.855742208
205632369jw01189010001_02101_00004NIRCAMNRC_IMAGE1189Roellig, Thomas LPOLYGON ICRS 277.131544824 26.827633005 277.143285757 26.813434817 277.159064459 26.823749501 277.147557968 26.837987165
205632316jw01189010001_04101_00001NIRCAMNRC_IMAGE1189Roellig, Thomas LPOLYGON ICRS 277.120171897 26.849875466 277.132100171 26.835444596 277.148132310 26.845799169 277.136492187 26.860300978

To exclude and filter out a certain value from the results, we can prepend the value with !.

Let’s run the same query as above, but this time, we will filter out datasets coming from the NIRCam instrument.

# Filtered query, excluding NIRCam datasets
results = missions.query_criteria(program=1189,
                                  instrume='!NIRCAM',  # Exclude datasets from the NIRCam instrument
                                  select_cols=['fileSetName', 'instrume', 'exp_type', 'program', 'pi_name'])

# Display the first 5 results
print(f'Total number of results: {len(results)}')
results[:5]
Total number of results: 92
Table masked=True length=5
ArchiveFileIDfileSetNameinstrumeexp_typeprogrampi_names_region
int64str36str7str17int64str17str121
205631161jw01189001001_02101_00001NIRSPECNRS_WATA1189Roellig, Thomas LPOLYGON ICRS 57.028706514 -60.379718934 57.029997036 -60.379034506 57.028628578 -60.378418468 57.027338587 -60.379103093
205631110jw01189001001_02101_00002NIRSPECNRS_TACONFIRM1189Roellig, Thomas LPOLYGON ICRS 57.028868052 -60.379725570 57.030158570 -60.379041140 57.028790110 -60.378425103 57.027500121 -60.379109730
205631240jw01189001001_04101_00001NIRSPECNRS_FIXEDSLIT1189Roellig, Thomas LPOLYGON ICRS 57.029098138 -60.378811466 57.027719263 -60.379546534 57.027799291 -60.379582617 57.029178187 -60.378847556
205631249jw01189001001_04101_00002NIRSPECNRS_FIXEDSLIT1189Roellig, Thomas LPOLYGON ICRS 57.029431441 -60.378633666 57.028052583 -60.379368738 57.028132612 -60.379404822 57.029511491 -60.378669756
205631152jw01189001001_04101_00003NIRSPECNRS_FIXEDSLIT1189Roellig, Thomas LPOLYGON ICRS 57.029845143 -60.378413088 57.028466303 -60.379148165 57.028546331 -60.379184248 57.029925192 -60.378449179

We can also use wildcards for more advanced filtering. Let’s use the same query from above, but we will add an exposure type filter for fixed slits (FS) spectroscopy.

# Filtered query with wildcard
results = missions.query_criteria(program=1189,
                                  instrume='!NIRCAM',  # Exclude datasets from the NIRCam instrument
                                  exp_type='*FIXEDSLIT*', # Any exposure type that contains 'FIXEDSLIT'
                                  select_cols=['fileSetName', 'instrume', 'exp_type', 'program', 'pi_name'])

# Display the first 10 results
print(f'Total number of results: {len(results)}')
results[:10]
Total number of results: 38
Table masked=True length=10
ArchiveFileIDfileSetNameinstrumeexp_typeprogrampi_names_region
int64str36str7str17int64str17str121
205631240jw01189001001_04101_00001NIRSPECNRS_FIXEDSLIT1189Roellig, Thomas LPOLYGON ICRS 57.029098138 -60.378811466 57.027719263 -60.379546534 57.027799291 -60.379582617 57.029178187 -60.378847556
205631249jw01189001001_04101_00002NIRSPECNRS_FIXEDSLIT1189Roellig, Thomas LPOLYGON ICRS 57.029431441 -60.378633666 57.028052583 -60.379368738 57.028132612 -60.379404822 57.029511491 -60.378669756
205631152jw01189001001_04101_00003NIRSPECNRS_FIXEDSLIT1189Roellig, Thomas LPOLYGON ICRS 57.029845143 -60.378413088 57.028466303 -60.379148165 57.028546331 -60.379184248 57.029925192 -60.378449179
205631143jw01189001001_06101_00001NIRSPECNRS_FIXEDSLIT1189Roellig, Thomas LPOLYGON ICRS 57.029094706 -60.378814882 57.027715806 -60.379549981 57.027795835 -60.379586065 57.029174756 -60.378850973
205631125jw01189001001_06101_00002NIRSPECNRS_FIXEDSLIT1189Roellig, Thomas LPOLYGON ICRS 57.029428241 -60.378637024 57.028049357 -60.379372127 57.028129386 -60.379408211 57.029508291 -60.378673115
205631134jw01189001001_06101_00003NIRSPECNRS_FIXEDSLIT1189Roellig, Thomas LPOLYGON ICRS 57.029841922 -60.378416519 57.028463057 -60.379151626 57.028543086 -60.379187710 57.029921972 -60.378452609
205631080jw01189001001_08101_00001NIRSPECNRS_FIXEDSLIT1189Roellig, Thomas LPOLYGON ICRS 57.029093839 -60.378817409 57.027714791 -60.379552569 57.027794819 -60.379588653 57.029173888 -60.378853500
205631089jw01189001001_08101_00002NIRSPECNRS_FIXEDSLIT1189Roellig, Thomas LPOLYGON ICRS 57.029427587 -60.378639357 57.028048551 -60.379374519 57.028128579 -60.379410603 57.029507635 -60.378675448
205631071jw01189001001_08101_00003NIRSPECNRS_FIXEDSLIT1189Roellig, Thomas LPOLYGON ICRS 57.029841266 -60.378418864 57.028462251 -60.379154030 57.028542278 -60.379190114 57.029921315 -60.378454954
205631442jw01189002001_03102_00001MIRIMIR_LRS-FIXEDSLIT1189Roellig, Thomas LPOLYGON ICRS 57.029000075 -60.378579009 57.028710817 -60.378582026 57.028770560 -60.379893934 57.029060321 -60.379890607

To filter by multiple values for a single column, we use a string of the values delimited by commas.

To illustrate this, we will use a slightly different query. We query for datasets that have a fixed slits spectroscopy exposure type and targets with moving coordinates (targtype='MOVING'). We will add another filter to match three different last names for principal investigators (PIs).

# Filtered query with multiple values
results = missions.query_criteria(exp_type='*FIXEDSLIT*', # Any exposure type that contains 'FIXEDSLIT'
                                  targtype='MOVING',  # Only return moving targets
                                  pi_name='Stansberry, Parker, Lunine',  # Last name of PI can be any of these 3 values
                                  select_cols=['fileSetName', 'targtype', 'instrume', 'exp_type', 'program', 'pi_name'])

# Display the first 10 results
print(f'Total number of results: {len(results)}')
results[:10]
Total number of results: 15
Table masked=True length=10
ArchiveFileIDfileSetNameinstrumeexp_typeprogrampi_nametargtypes_region
int64str25str4str17int64str21str6str125
202973358jw01191018001_03102_00001MIRIMIR_LRS-FIXEDSLIT1191Stansberry, John A.MOVINGPOLYGON ICRS 27.119130631 -0.633808628 27.118993907 -0.633850603 27.119380875 -0.635104608 27.119517747 -0.635062267
202973325jw01191018001_03102_00002MIRIMIR_LRS-FIXEDSLIT1191Stansberry, John A.MOVINGPOLYGON ICRS 27.118986627 -0.633313429 27.118849904 -0.633355404 27.119236871 -0.634609408 27.119373743 -0.634567068
203023813jw01191-o018_t002_miriMIRIMIR_LRS-FIXEDSLIT1191Stansberry, John A.MOVINGPOLYGON ICRS 27.118972938 -0.633282994 27.119534690 -0.635102738 27.119398030 -0.635144920 27.118836277 -0.633325175
216829955jw01254001001_03102_00001MIRIMIR_LRS-FIXEDSLIT1254Parker, Alex HarrisonMOVINGPOLYGON ICRS 200.084989101 21.875603741 200.084839511 21.875638116 200.084501536 21.874363824 200.084651465 21.874329687
216829964jw01254001001_03102_00002MIRIMIR_LRS-FIXEDSLIT1254Parker, Alex HarrisonMOVINGPOLYGON ICRS 200.085097655 21.876183716 200.084948065 21.876218091 200.084610087 21.874943800 200.084760016 21.874909662
216840623jw01254-o001_t001_miriMIRIMIR_LRS-FIXEDSLIT1254Parker, Alex HarrisonMOVINGPOLYGON ICRS 200.085118413 21.876176207 200.084628149 21.874326917 200.084478505 21.874361082 200.084968767 21.876210372
201380977jw01273001001_04102_00001MIRIMIR_LRS-FIXEDSLIT1273Lunine, Jonathan I.MOVINGPOLYGON ICRS 218.302364746 15.229464463 218.302216747 15.229456762 218.302291894 15.228146471 218.302440133 15.228154490
201379916jw01273001001_04102_00002MIRIMIR_LRS-FIXEDSLIT1273Lunine, Jonathan I.MOVINGPOLYGON ICRS 218.302255562 15.230070428 218.302107563 15.230062728 218.302182711 15.228752436 218.302330951 15.228760456
201378586jw01273009001_04102_00001MIRIMIR_LRS-FIXEDSLIT1273Lunine, Jonathan I.MOVINGPOLYGON ICRS 218.299827529 15.232021871 218.299679528 15.232014170 218.299754675 15.230703879 218.299902916 15.230711898
201378607jw01273009001_04102_00002MIRIMIR_LRS-FIXEDSLIT1273Lunine, Jonathan I.MOVINGPOLYGON ICRS 218.299717915 15.232627744 218.299569914 15.232620043 218.299645062 15.231309752 218.299793303 15.231317771

For columns with numeric or date values, we can filter using comparison values:

  • <: Return values less than or before the given number/date

  • >: Return values greater than or after the given number/date

  • <=: Return values less than or equal to the given number/date

  • >=: Return values greater than or equal to the given number/date

As an example, let’s write a query to return all datasets with an observation date before February 1, 2022.

# Query using comparison operator
results = missions.query_criteria(date_obs='<2022-02-01',  # Must be observed before February 1, 2022
                                  select_cols=['fileSetName', 'program', 'date_obs'])

# Display results
print(f'Total number of results: {len(results)}')
results
Total number of results: 7
Table masked=True length=7
ArchiveFileIDfileSetNamedate_obsprograms_region
int64str25str27int64str117
215731832jw01173001001_02101_000012022-01-28T14:23:42.61800001173POLYGON ICRS 49.866526985 43.426041553 49.866521841 43.425150113 49.865098509 43.425154454 49.865103669 43.426045898
215731918jw01173002001_02101_000012022-01-28T14:36:10.11100001173POLYGON ICRS 49.834781123 43.401405192 49.833461500 43.417145218 49.855003580 43.418000890 49.856390566 43.402332025
215731590jw01173003001_02101_000012022-01-28T15:00:36.65500001173POLYGON ICRS 49.833309699 43.387232397 49.830574836 43.418875799 49.873651838 43.420534037 49.876269543 43.389175750
215731714jw01173004001_02101_000012022-01-28T15:09:07.18300001173POLYGON ICRS 49.871773665 43.425721414 49.871768435 43.424829974 49.870345111 43.424834387 49.870350357 43.425725831
215731607jw01173005001_02101_000012022-01-28T15:26:34.22700001173POLYGON ICRS 49.871781960 43.425717246 49.871776730 43.424825806 49.870353406 43.424830219 49.870358652 43.425721663
215731710jw01173006001_02101_000012022-01-28T15:34:23.46900001173POLYGON ICRS 49.871796487 43.425726630 49.871791257 43.424835190 49.870367933 43.424839603 49.870373179 43.425731048
215731494jw01173007001_02101_000012022-01-28T15:43:44.30100001173POLYGON ICRS 49.833398209 43.387251737 49.830663382 43.418895140 49.873740398 43.420553352 49.876358069 43.389195064

For numeric or date data types, we can also filter with ranges. This requires the following syntax: '#..#'.

Let’s write a query that uses range syntax to return datasets that belong to a program number between 1150 and 1155. We will also select for exposure durations that are greater than or equal to 100 seconds.

# Query using range operator
results = missions.query_criteria(program='1150..1155', # Program number between 1150 and 1155
                                  duration='>100',  # Exposure duration is greater than or equal to 100 seconds
                                  select_cols=['fileSetName', 'program', 'duration'])

# Display results
print(f'Total number of results: {len(results)}')
results
Total number of results: 77
Table masked=True length=77
ArchiveFileIDfileSetNamedurationprograms_region
int64str25float64int64str121
56863496jw01151001001_02101_00001203.9991151POLYGON ICRS 267.823568791 74.579914311 267.758823468 74.583483609 267.745046642 74.566390683 267.809916760 74.562619353
56863482jw01151001001_02101_00002203.9991151POLYGON ICRS 267.832636673 74.568022765 267.766940456 74.571687792 267.753017936 74.554394205 267.818800515 74.550472738
56863512jw01151001001_03101_00001214.7351151POLYGON ICRS 268.091803329 74.608826495 267.943092794 74.616030022 267.912318626 74.578289816 268.058609787 74.570410560
56863582jw01151001001_05101_00001203.9991151POLYGON ICRS 267.823569171 74.579914010 267.758823764 74.583483198 267.745047350 74.566390249 267.809917556 74.562619029
56863557jw01151001001_05101_00002203.9991151POLYGON ICRS 267.832637174 74.568022531 267.766940886 74.571687467 267.753018708 74.554393860 267.818801363 74.550472484
56863823jw01151001001_06101_00001214.7351151POLYGON ICRS 268.091803198 74.608826549 267.943092604 74.616029989 267.912318750 74.578289765 268.058609977 74.570410594
56863493jw01151001001_08101_00001203.9991151POLYGON ICRS 267.818105646 74.572500244 267.753393956 74.576073744 267.739607888 74.558981714 267.804444175 74.555206172
56875469jw01151020001_03101_00001214.7351151POLYGON ICRS 241.403250845 62.406808505 241.320362209 62.395214146 241.341730845 62.357890793 241.424148058 62.368600633
56875337jw01151021001_02102_00001118.1041151POLYGON ICRS 267.913114360 74.594280874 267.847798665 74.598304471 267.832287729 74.581187911 267.897484698 74.576921755
...............
56968123jw01155005001_0210a_00002150.3151155POLYGON ICRS 268.948931490 65.883692410 268.862026455 65.888823867 268.848510660 65.853853484 268.935616643 65.847844473
56968107jw01155005001_0210b_00001150.3151155POLYGON ICRS 268.943367232 65.865137421 268.900206631 65.867886945 268.893348799 65.850424281 268.936614729 65.847418646
56968099jw01155005001_0210b_00002150.3151155POLYGON ICRS 268.897309483 65.868076519 268.854801968 65.870734177 268.848044059 65.853472441 268.890674791 65.850613599
56967383jw01155007001_02102_000011191.7811155POLYGON ICRS 268.953421618 65.883348262 268.910258263 65.885838025 268.903866273 65.868430578 268.947013758 65.865693295
56967393jw01155007001_02103_000011191.7811155POLYGON ICRS 268.900582798 65.867357807 268.858088887 65.870023805 268.851308616 65.852766994 268.893929725 65.849900846
56967357jw01155007001_02104_000011191.7811155POLYGON ICRS 268.907471989 65.885893297 268.865026422 65.888465047 268.858577317 65.871266296 268.901022967 65.868503644
56969123jw01155-o001_t018_nircam150.3151155POLYGON ICRS 268.950105056 65.884072557 268.906939249 65.886554426 268.900565087 65.869142126 268.943721766 65.866414693
56968129jw01155-o003_t018_nircam246.9461155POLYGON ICRS 268.897309446 65.868076445 268.854801924 65.870734081 268.848044068 65.853472341 268.890674808 65.850613522
56968698jw01155-o005_t018_nircam246.9461155POLYGON ICRS 268.897309130 65.868076445 268.854801607 65.870734077 268.848043759 65.853472337 268.890674500 65.850613521
56969356jw01155-o007_t018_nircam4767.1241155POLYGON ICRS 268.954186883 65.883302799 268.865270829 65.889082353 268.851081068 65.852428662 268.939873462 65.846657355

Exercise 3#

It’s time to apply all that you’ve learned! Write a non-positional query based on the following:

  • Fixed targets (HINT: targtype='FIXED')

  • Instument is Mid-Infrared Instrument (MIRI) or Fine Guidance Sensor (FGS)

  • Proposal type should NOT include General Observers (GO)

  • Exposure type includes the string 'IMAGE'

  • Right ascension is between 70 and 75 degrees

  • Program number is less than 1200.

  • Skip the first 5 entries.

  • Select the following columns: fileSetName, targtype, instrume, proposal_type, exp_type, targ_ra, program

# # A non-positional query with column criteria
# results = missions.query_criteria(...)  # Write your query here!

# # Display results
# print(f'Total number of results: {len(results)}')
# results

Additional Resources#

Exercise Solutions#

Exercise 1#

# Query for Whirlpool Galaxy
results = missions.query_object('Whirlpool',
                                radius=1,  # Search radius of 1 arcminute
                                offset=300,  # Skip the first 300 rows
                                select_cols=['fileSetName', 'opticalElements'])

# Display the first 5 results
print(f'Total number of results: {len(results)}')
results[:5]
Total number of results: 93
Table masked=True length=5
ArchiveFileIDfileSetNameopticalElementss_region
int64str25str12str121
215512747jw03435006001_16101_00002F100LP;G140MPOLYGON ICRS 202.479810587 47.194679926 202.481582645 47.194679926 202.481582645 47.195951365 202.479810587 47.195951365
215512621jw03435006001_24101_00002F170LP;G235MPOLYGON ICRS 202.479815830 47.194677897 202.481587846 47.194677897 202.481587846 47.195949206 202.479815830 47.195949206
215509694jw03435006001_32101_00002F170LP;G235MPOLYGON ICRS 202.479816081 47.194677948 202.481588097 47.194677948 202.481588097 47.195949257 202.479816081 47.195949257
215510113jw03435006001_40101_00002F290LP;G395MPOLYGON ICRS 202.479818837 47.194676959 202.481590938 47.194676959 202.481590938 47.195948412 202.479818837 47.195948412
215509514jw03435006001_48101_00002F290LP;G395MPOLYGON ICRS 202.479819110 47.194676984 202.481591212 47.194676984 202.481591212 47.195948437 202.479819110 47.195948437

Exercise 2#

# Vega coordinates
vega = SkyCoord(279.23473, 38.78369, unit=('deg'))

# Query for datasets around Vega
results = missions.query_region(vega,
                                radius=15,  # Search radius of 15 arcminutes
                                select_cols=['fileSetName', 'targprop', 'targ_ra', 'targ_dec'])

# Display the first 5 results
print(f'Total number of results: {len(results)}')
results[:5]
Total number of results: 67
Table masked=True length=5
ArchiveFileIDfileSetNametargproptarg_ratarg_decs_region
int64str25str20float64float64str121
205533519jw01193026001_02101_00001VEGA279.236426614517138.78556769656323POLYGON ICRS 279.221700461 38.783440608 279.235112217 38.771692654 279.250086725 38.782192003 279.236789373 38.793944210
205533501jw01193026001_02101_00002VEGA279.236426615314138.7855676974483POLYGON ICRS 279.217873046 38.787051938 279.231286202 38.775304485 279.246260824 38.785804392 279.232962076 38.797556103
205533495jw01193026001_02101_00003VEGA279.236426616117238.78556769833999POLYGON ICRS 279.222621156 38.789548166 279.236033992 38.777800164 279.251009844 38.788299460 279.237711422 38.800051715
205533525jw01193026001_02101_00004VEGA279.236426616916338.78556769922733POLYGON ICRS 279.225040903 38.786403830 279.238452740 38.774655546 279.253428296 38.785154526 279.240130868 38.796907061
205519762jw01193027001_02101_00001VEGA-COPY-MIRI-CORON279.236426619141138.78556770169765POLYGON ICRS 279.224055115 38.786615630 279.232049315 38.779701619 279.241425932 38.786141398 279.233452935 38.793086039

Exercise 3#

# A non-positional query with column criteria
results = missions.query_criteria(targtype='FIXED',  # Fixed target
                                  instrume='MIRI, FGS',  # Select MIRI and FGS observations
                                  proposal_type='!GO',  # Not from a general observer proposal
                                  exp_type='*IMAGE*',  # Contains the string "IMAGE"
                                  targ_ra='70..75',  # Between 70 and 75
                                  program='<1200',  # Less than 1200
                                  offset=5,  # Skip the first 5 results
                                  select_cols=['fileSetName', 'targtype', 'instrume', 'proposal_type', 
                                               'exp_type', 'targ_ra', 'program'])

# Display results
print(f'Total number of results: {len(results)}')
results
Total number of results: 11
Table masked=True length=11
ArchiveFileIDfileSetNametarg_rainstrumeexp_typeprogramproposal_typetargtypes_region
int64str25float64str4str9int64str3str5str117
205629426jw01189005001_02101_0000674.72636096419268MIRIMIR_IMAGE1189GTOFIXEDPOLYGON ICRS 74.725782945 64.586608267 74.715344452 64.580202182 74.730412964 64.575710032 74.740870424 64.582110094
205629438jw01189005001_02101_0000774.72636096470079MIRIMIR_IMAGE1189GTOFIXEDPOLYGON ICRS 74.724613042 64.588027121 74.714174271 64.581620957 74.729243755 64.577128922 74.739701494 64.583529063
205629432jw01189005001_02101_0000874.72636096498769MIRIMIR_IMAGE1189GTOFIXEDPOLYGON ICRS 74.724612505 64.588027111 74.714173725 64.581620950 74.729243203 64.577128911 74.739700951 64.583529050
205629361jw01189015001_02101_0000174.72636283572133MIRIMIR_IMAGE1189GTOFIXEDPOLYGON ICRS 74.684357400 64.625764236 74.649592863 64.598263434 74.713910257 64.583249516 74.749370524 64.610641874
205629354jw01189015001_02101_0000274.72636283828368MIRIMIR_IMAGE1189GTOFIXEDPOLYGON ICRS 74.685792422 64.625698617 74.651026321 64.598198198 74.715342662 64.583183572 74.750804481 64.610575539
205629326jw01189015001_02103_0000174.7263628414447MIRIMIR_IMAGE1189GTOFIXEDPOLYGON ICRS 74.684356352 64.625764153 74.649591534 64.598263417 74.713908773 64.583249378 74.749369319 64.610641668
205629307jw01189015001_02103_0000274.72636284399516MIRIMIR_IMAGE1189GTOFIXEDPOLYGON ICRS 74.685792234 64.625698686 74.651026069 64.598198283 74.715342373 64.583183629 74.750804256 64.610575580
205629290jw01189015001_02105_0000174.7263628471562MIRIMIR_IMAGE1189GTOFIXEDPOLYGON ICRS 74.684356397 64.625764293 74.649591578 64.598263558 74.713908817 64.583249519 74.749369363 64.610641809
205629265jw01189015001_02105_0000274.72636284971881MIRIMIR_IMAGE1189GTOFIXEDPOLYGON ICRS 74.685792376 64.625698852 74.651026242 64.598198442 74.715342562 64.583183802 74.750804414 64.610575759
205851968jw01189-o005_t002_miri74.72636096235495MIRIMIR_IMAGE1189GTOFIXEDPOLYGON ICRS 74.723431952 64.589614888 74.709376918 64.580988713 74.729294948 64.575009120 74.743353205 64.583633401
205871775jw01189-o015_t002_miri74.72636283572133MIRIMIR_IMAGE1189GTOFIXEDPOLYGON ICRS 74.684751994 64.626106173 74.649340948 64.598343842 74.715356720 64.582844345 74.750814948 64.610590852

Citations#

If you use astroquery for published research, please cite the authors. Follow these links for more information about citing astroquery:

About this Notebook#

Author(s): Sam Bianco
Keyword(s): Tutorial, JWST, Astroquery, MastMissions
First published: June 2024
Last updated: June 2024


Top of Page Space Telescope Logo