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.mastmodule 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]
| name | data_type | description |
|---|---|---|
| str17 | str9 | str1594 |
| search_pos | string | Search Position (RA and Dec) |
| ArchiveFileID | integer | ArchiveFileID |
| fileSetName | string | Of 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 |
| productLevel | string | Product levels, 1b is an Uncal FITS file, 2a = Countrate exposure, 2b = calibrated exposure, 2c = cosmic-ray-flagged exposure, and 3 = combined data. |
| targprop | string | Proposer prefered name for the target |
| targname | string | Standard astronomical catalog name for the target |
| targ_ra | ra | Right Ascension (J2000), from 0 to 360, in degrees |
| targ_dec | dec | Declination (J2000), from -90 to +90, in degrees |
| instrume | string | Identifies the instrument used to acquire the data. |
| exp_type | string | Exposure 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
| ArchiveFileID | fileSetName | productLevel | targprop | targ_ra | targ_dec | instrume | exp_type | opticalElements | date_obs | duration | program | observtn | visit | publicReleaseDate | pi_name | proposal_type | proposal_cycle | targtype | access | cal_ver | ang_sep | s_region |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| int64 | str25 | str14 | str18 | float64 | float64 | str6 | str9 | str153 | str27 | float64 | int64 | int64 | int64 | str19 | str10 | str2 | int64 | str5 | str6 | str6 | float64 | str117 |
| 202227346 | jw01714001003_02101_00001 | 1b, 2a, 2b, 2c | CRAB-NEBULA | 83.63604958333333 | 22.01641666666667 | MIRI | MIR_IMAGE | F560W | 2023-02-24T02:49:57.2040000 | 138.752 | 1714 | 1 | 3 | 2024-02-24T13:38:23 | Temim, Tea | GO | 1 | FIXED | PUBLIC | 1.19.1 | 0.0 | POLYGON ICRS 83.620720664 22.002796071 83.654438843 22.001843601 83.655520407 22.033240536 83.621749133 22.034484397 |
| 202227407 | jw01714001003_02101_00002 | 1b, 2a, 2b, 2c | CRAB-NEBULA | 83.63604958333333 | 22.01641666666667 | MIRI | MIR_IMAGE | F560W | 2023-02-24T02:53:39.2200000 | 138.752 | 1714 | 1 | 3 | 2024-02-24T13:38:36 | Temim, Tea | GO | 1 | FIXED | PUBLIC | 1.19.1 | 0.0 | POLYGON ICRS 83.615681886 22.003125717 83.649400180 22.002174326 83.650480576 22.033571296 83.616709178 22.034814075 |
| 202227359 | jw01714001003_02101_00003 | 1b, 2a, 2b, 2c | CRAB-NEBULA | 83.63604958333333 | 22.01641666666667 | MIRI | MIR_IMAGE | F560W | 2023-02-24T02:57:23.9880000 | 138.752 | 1714 | 1 | 3 | 2024-02-24T13:36:13 | Temim, Tea | GO | 1 | FIXED | PUBLIC | 1.19.1 | 0.0 | POLYGON ICRS 83.616485032 22.007527317 83.650204366 22.006575751 83.651284987 22.037972715 83.617512546 22.039215670 |
| 202227230 | jw01714001003_02101_00004 | 1b, 2a, 2b, 2c | CRAB-NEBULA | 83.63604958333333 | 22.01641666666667 | MIRI | MIR_IMAGE | F560W | 2023-02-24T03:01:06.0030000 | 138.752 | 1714 | 1 | 3 | 2024-02-24T13:35:43 | Temim, Tea | GO | 1 | FIXED | PUBLIC | 1.19.1 | 0.0 | POLYGON ICRS 83.620343760 22.006724973 83.654062878 22.005772644 83.655144319 22.037169584 83.621372102 22.038413302 |
| 202227236 | jw01714001003_02103_00001 | 1b, 2a, 2b, 2c | CRAB-NEBULA | 83.63604958333333 | 22.01641666666667 | MIRI | MIR_IMAGE | F1130W | 2023-02-24T03:06:50.0870000 | 105.452 | 1714 | 1 | 3 | 2024-02-24T13:36:54 | Temim, Tea | GO | 1 | FIXED | PUBLIC | 1.19.1 | 0.0 | POLYGON 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) andtarg_dec(declination). By default, the query returns all datasets that fall within 3 arcminutes from the object’s coordinates. Let’s set theradiusparameter to be 1 arcminute instead.Say that we’re not interested in the first 4 results. We can assign
offsetto 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_colskeyword argument. TheArchiveFileIDcolumn 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
| ArchiveFileID | fileSetName | targprop | date_obs | s_region |
|---|---|---|---|---|
| int64 | str25 | str18 | str27 | str117 |
| 202227236 | jw01714001003_02103_00001 | CRAB-NEBULA | 2023-02-24T03:06:50.0870000 | POLYGON ICRS 83.620704104 22.002803649 83.654421963 22.001850980 83.655503419 22.033248128 83.621732711 22.034491896 |
| 202227212 | jw01714001003_02103_00002 | CRAB-NEBULA | 2023-02-24T03:09:58.8230000 | POLYGON ICRS 83.615665261 22.003133413 83.649383236 22.002181860 83.650463486 22.033579043 83.616692652 22.034821694 |
| 202225507 | jw01714001003_02103_00003 | CRAB-NEBULA | 2023-02-24T03:13:07.5590000 | POLYGON ICRS 83.616468314 22.007534974 83.650187330 22.006583256 83.651267794 22.037980433 83.617495916 22.039223250 |
| 202226882 | jw01714001003_02103_00004 | CRAB-NEBULA | 2023-02-24T03:16:18.9830000 | POLYGON ICRS 83.620327068 22.006732644 83.654045867 22.005780159 83.655127156 22.037177312 83.621355503 22.038420897 |
| 202226676 | jw01714001003_02105_00001 | CRAB-NEBULA | 2023-02-24T03:21:10.3800000 | POLYGON 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
| ArchiveFileID | fileSetName | productLevel | targprop | targ_ra | targ_dec | instrume | exp_type | opticalElements | date_obs | duration | program | observtn | visit | publicReleaseDate | pi_name | proposal_type | proposal_cycle | targtype | access | cal_ver | ang_sep | s_region |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| int64 | str36 | str14 | str25 | float64 | float64 | str7 | str17 | str89 | str27 | float64 | int64 | int64 | int64 | str19 | str25 | str6 | int64 | str7 | str6 | str6 | float64 | str121 |
| 216713031 | jw01995001002_02101_00001 | 1b, 2a, 2b, 2c | MESSIER-101 | 210.876465 | 54.36092777777778 | NIRCAM | NRC_IMAGE | F115W;CLEAR, F444W;CLEAR | 2023-05-30T15:53:41.4040000 | 311.366 | 1995 | 1 | 2 | 2024-05-30T23:57:44 | Freedman, Wendy L. | GO | 1 | FIXED | PUBLIC | 1.20.2 | 0.0 | POLYGON ICRS 210.911618011 54.374886063 210.929457447 54.360746186 210.953599146 54.370957412 210.936068288 54.385179847 |
| 216712862 | jw01995001002_02101_00002 | 1b, 2a, 2b, 2c | MESSIER-101 | 210.876465 | 54.36092777777778 | NIRCAM | NRC_IMAGE | F115W;CLEAR, F444W;CLEAR | 2023-05-30T16:00:29.4680000 | 311.366 | 1995 | 1 | 2 | 2024-05-30T23:55:45 | Freedman, Wendy L. | GO | 1 | FIXED | PUBLIC | 1.20.2 | 0.0 | POLYGON ICRS 210.866658537 54.378880493 210.904087983 54.349991526 210.953023924 54.371061598 210.917087526 54.400261542 |
| 216712749 | jw01995001002_02101_00003 | 1b, 2a, 2b, 2c | MESSIER-101 | 210.876465 | 54.36092777777778 | NIRCAM | NRC_IMAGE | F115W;CLEAR, F444W;CLEAR | 2023-05-30T16:07:06.6520000 | 311.366 | 1995 | 1 | 2 | 2024-05-30T23:55:43 | Freedman, Wendy L. | GO | 1 | FIXED | PUBLIC | 1.20.2 | 0.0 | POLYGON ICRS 210.892476657 54.390231609 210.910438658 54.375790692 210.934979706 54.386035265 210.917406143 54.400589853 |
| 216712650 | jw01995001003_02101_00001 | 1b, 2a, 2b, 2c | MESSIER-101 | 210.876465 | 54.36092777777778 | NIRCAM | NRC_IMAGE | F115W;CLEAR, F444W;CLEAR | 2023-05-30T16:23:18.8750000 | 311.366 | 1995 | 1 | 3 | 2024-05-30T23:49:52 | Freedman, Wendy L. | GO | 1 | FIXED | PUBLIC | 1.20.2 | 0.0 | POLYGON ICRS 210.795561580 54.357496515 210.813811095 54.343152271 210.838275439 54.353607849 210.820276117 54.368181350 |
| 216712089 | jw01995001003_02101_00002 | 1b, 2a, 2b, 2c | MESSIER-101 | 210.876465 | 54.36092777777778 | NIRCAM | NRC_IMAGE | F115W;CLEAR, F444W;CLEAR | 2023-05-30T16:29:56.1860000 | 311.366 | 1995 | 1 | 3 | 2024-05-30T23:42:15 | Freedman, Wendy L. | GO | 1 | FIXED | PUBLIC | 1.20.2 | 0.0 | POLYGON 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
| ArchiveFileID | fileSetName | instrume | exp_type | program | pi_name | s_region |
|---|---|---|---|---|---|---|
| int64 | str25 | str6 | str13 | int64 | str17 | str121 |
| 205632636 | jw01189010001_02101_00001 | NIRCAM | NRC_IMAGE | 1189 | Roellig, Thomas L | POLYGON ICRS 277.120925692 26.849950982 277.144958937 26.820792259 277.177196644 26.841516114 277.154135422 26.870965715 |
| 205632493 | jw01189010001_02101_00002 | NIRCAM | NRC_IMAGE | 1189 | Roellig, Thomas L | POLYGON ICRS 277.119751279 26.847595543 277.131677837 26.833163977 277.147709697 26.843518895 277.136071545 26.858021322 |
| 205632426 | jw01189010001_02101_00003 | NIRCAM | NRC_IMAGE | 1189 | Roellig, Thomas L | POLYGON ICRS 277.119330391 26.845316385 277.131256758 26.830884851 277.147288259 26.841239813 277.135650292 26.855742208 |
| 205632369 | jw01189010001_02101_00004 | NIRCAM | NRC_IMAGE | 1189 | Roellig, Thomas L | POLYGON ICRS 277.131544824 26.827633005 277.143285757 26.813434817 277.159064459 26.823749501 277.147557968 26.837987165 |
| 205632316 | jw01189010001_04101_00001 | NIRCAM | NRC_IMAGE | 1189 | Roellig, Thomas L | POLYGON 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
| ArchiveFileID | fileSetName | instrume | exp_type | program | pi_name | s_region |
|---|---|---|---|---|---|---|
| int64 | str36 | str7 | str17 | int64 | str17 | str121 |
| 205631161 | jw01189001001_02101_00001 | NIRSPEC | NRS_WATA | 1189 | Roellig, Thomas L | POLYGON ICRS 57.028706514 -60.379718934 57.029997036 -60.379034506 57.028628578 -60.378418468 57.027338587 -60.379103093 |
| 205631110 | jw01189001001_02101_00002 | NIRSPEC | NRS_TACONFIRM | 1189 | Roellig, Thomas L | POLYGON ICRS 57.028868052 -60.379725570 57.030158570 -60.379041140 57.028790110 -60.378425103 57.027500121 -60.379109730 |
| 205631240 | jw01189001001_04101_00001 | NIRSPEC | NRS_FIXEDSLIT | 1189 | Roellig, Thomas L | POLYGON ICRS 57.029098138 -60.378811466 57.027719263 -60.379546534 57.027799291 -60.379582617 57.029178187 -60.378847556 |
| 205631249 | jw01189001001_04101_00002 | NIRSPEC | NRS_FIXEDSLIT | 1189 | Roellig, Thomas L | POLYGON ICRS 57.029431441 -60.378633666 57.028052583 -60.379368738 57.028132612 -60.379404822 57.029511491 -60.378669756 |
| 205631152 | jw01189001001_04101_00003 | NIRSPEC | NRS_FIXEDSLIT | 1189 | Roellig, Thomas L | POLYGON 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
| ArchiveFileID | fileSetName | instrume | exp_type | program | pi_name | s_region |
|---|---|---|---|---|---|---|
| int64 | str36 | str7 | str17 | int64 | str17 | str121 |
| 205631240 | jw01189001001_04101_00001 | NIRSPEC | NRS_FIXEDSLIT | 1189 | Roellig, Thomas L | POLYGON ICRS 57.029098138 -60.378811466 57.027719263 -60.379546534 57.027799291 -60.379582617 57.029178187 -60.378847556 |
| 205631249 | jw01189001001_04101_00002 | NIRSPEC | NRS_FIXEDSLIT | 1189 | Roellig, Thomas L | POLYGON ICRS 57.029431441 -60.378633666 57.028052583 -60.379368738 57.028132612 -60.379404822 57.029511491 -60.378669756 |
| 205631152 | jw01189001001_04101_00003 | NIRSPEC | NRS_FIXEDSLIT | 1189 | Roellig, Thomas L | POLYGON ICRS 57.029845143 -60.378413088 57.028466303 -60.379148165 57.028546331 -60.379184248 57.029925192 -60.378449179 |
| 205631143 | jw01189001001_06101_00001 | NIRSPEC | NRS_FIXEDSLIT | 1189 | Roellig, Thomas L | POLYGON ICRS 57.029094706 -60.378814882 57.027715806 -60.379549981 57.027795835 -60.379586065 57.029174756 -60.378850973 |
| 205631125 | jw01189001001_06101_00002 | NIRSPEC | NRS_FIXEDSLIT | 1189 | Roellig, Thomas L | POLYGON ICRS 57.029428241 -60.378637024 57.028049357 -60.379372127 57.028129386 -60.379408211 57.029508291 -60.378673115 |
| 205631134 | jw01189001001_06101_00003 | NIRSPEC | NRS_FIXEDSLIT | 1189 | Roellig, Thomas L | POLYGON ICRS 57.029841922 -60.378416519 57.028463057 -60.379151626 57.028543086 -60.379187710 57.029921972 -60.378452609 |
| 205631080 | jw01189001001_08101_00001 | NIRSPEC | NRS_FIXEDSLIT | 1189 | Roellig, Thomas L | POLYGON ICRS 57.029093839 -60.378817409 57.027714791 -60.379552569 57.027794819 -60.379588653 57.029173888 -60.378853500 |
| 205631089 | jw01189001001_08101_00002 | NIRSPEC | NRS_FIXEDSLIT | 1189 | Roellig, Thomas L | POLYGON ICRS 57.029427587 -60.378639357 57.028048551 -60.379374519 57.028128579 -60.379410603 57.029507635 -60.378675448 |
| 205631071 | jw01189001001_08101_00003 | NIRSPEC | NRS_FIXEDSLIT | 1189 | Roellig, Thomas L | POLYGON ICRS 57.029841266 -60.378418864 57.028462251 -60.379154030 57.028542278 -60.379190114 57.029921315 -60.378454954 |
| 205631442 | jw01189002001_03102_00001 | MIRI | MIR_LRS-FIXEDSLIT | 1189 | Roellig, Thomas L | POLYGON 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
| ArchiveFileID | fileSetName | instrume | exp_type | program | pi_name | targtype | s_region |
|---|---|---|---|---|---|---|---|
| int64 | str25 | str4 | str17 | int64 | str21 | str6 | str125 |
| 202973358 | jw01191018001_03102_00001 | MIRI | MIR_LRS-FIXEDSLIT | 1191 | Stansberry, John A. | MOVING | POLYGON ICRS 27.119130631 -0.633808628 27.118993907 -0.633850603 27.119380875 -0.635104608 27.119517747 -0.635062267 |
| 202973325 | jw01191018001_03102_00002 | MIRI | MIR_LRS-FIXEDSLIT | 1191 | Stansberry, John A. | MOVING | POLYGON ICRS 27.118986627 -0.633313429 27.118849904 -0.633355404 27.119236871 -0.634609408 27.119373743 -0.634567068 |
| 203023813 | jw01191-o018_t002_miri | MIRI | MIR_LRS-FIXEDSLIT | 1191 | Stansberry, John A. | MOVING | POLYGON ICRS 27.118972938 -0.633282994 27.119534690 -0.635102738 27.119398030 -0.635144920 27.118836277 -0.633325175 |
| 216829955 | jw01254001001_03102_00001 | MIRI | MIR_LRS-FIXEDSLIT | 1254 | Parker, Alex Harrison | MOVING | POLYGON ICRS 200.084989101 21.875603741 200.084839511 21.875638116 200.084501536 21.874363824 200.084651465 21.874329687 |
| 216829964 | jw01254001001_03102_00002 | MIRI | MIR_LRS-FIXEDSLIT | 1254 | Parker, Alex Harrison | MOVING | POLYGON ICRS 200.085097655 21.876183716 200.084948065 21.876218091 200.084610087 21.874943800 200.084760016 21.874909662 |
| 216840623 | jw01254-o001_t001_miri | MIRI | MIR_LRS-FIXEDSLIT | 1254 | Parker, Alex Harrison | MOVING | POLYGON ICRS 200.085118413 21.876176207 200.084628149 21.874326917 200.084478505 21.874361082 200.084968767 21.876210372 |
| 201380977 | jw01273001001_04102_00001 | MIRI | MIR_LRS-FIXEDSLIT | 1273 | Lunine, Jonathan I. | MOVING | POLYGON ICRS 218.302364746 15.229464463 218.302216747 15.229456762 218.302291894 15.228146471 218.302440133 15.228154490 |
| 201379916 | jw01273001001_04102_00002 | MIRI | MIR_LRS-FIXEDSLIT | 1273 | Lunine, Jonathan I. | MOVING | POLYGON ICRS 218.302255562 15.230070428 218.302107563 15.230062728 218.302182711 15.228752436 218.302330951 15.228760456 |
| 201378586 | jw01273009001_04102_00001 | MIRI | MIR_LRS-FIXEDSLIT | 1273 | Lunine, Jonathan I. | MOVING | POLYGON ICRS 218.299827529 15.232021871 218.299679528 15.232014170 218.299754675 15.230703879 218.299902916 15.230711898 |
| 201378607 | jw01273009001_04102_00002 | MIRI | MIR_LRS-FIXEDSLIT | 1273 | Lunine, Jonathan I. | MOVING | POLYGON 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
| ArchiveFileID | fileSetName | date_obs | program | s_region |
|---|---|---|---|---|
| int64 | str25 | str27 | int64 | str117 |
| 215731832 | jw01173001001_02101_00001 | 2022-01-28T14:23:42.6180000 | 1173 | POLYGON ICRS 49.866526985 43.426041553 49.866521841 43.425150113 49.865098509 43.425154454 49.865103669 43.426045898 |
| 215731918 | jw01173002001_02101_00001 | 2022-01-28T14:36:10.1110000 | 1173 | POLYGON ICRS 49.834781123 43.401405192 49.833461500 43.417145218 49.855003580 43.418000890 49.856390566 43.402332025 |
| 215731590 | jw01173003001_02101_00001 | 2022-01-28T15:00:36.6550000 | 1173 | POLYGON ICRS 49.833309699 43.387232397 49.830574836 43.418875799 49.873651838 43.420534037 49.876269543 43.389175750 |
| 215731714 | jw01173004001_02101_00001 | 2022-01-28T15:09:07.1830000 | 1173 | POLYGON ICRS 49.871773665 43.425721414 49.871768435 43.424829974 49.870345111 43.424834387 49.870350357 43.425725831 |
| 215731607 | jw01173005001_02101_00001 | 2022-01-28T15:26:34.2270000 | 1173 | POLYGON ICRS 49.871781960 43.425717246 49.871776730 43.424825806 49.870353406 43.424830219 49.870358652 43.425721663 |
| 215731710 | jw01173006001_02101_00001 | 2022-01-28T15:34:23.4690000 | 1173 | POLYGON ICRS 49.871796487 43.425726630 49.871791257 43.424835190 49.870367933 43.424839603 49.870373179 43.425731048 |
| 215731494 | jw01173007001_02101_00001 | 2022-01-28T15:43:44.3010000 | 1173 | POLYGON 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
| ArchiveFileID | fileSetName | duration | program | s_region |
|---|---|---|---|---|
| int64 | str25 | float64 | int64 | str121 |
| 56863496 | jw01151001001_02101_00001 | 203.999 | 1151 | POLYGON ICRS 267.823568791 74.579914311 267.758823468 74.583483609 267.745046642 74.566390683 267.809916760 74.562619353 |
| 56863482 | jw01151001001_02101_00002 | 203.999 | 1151 | POLYGON ICRS 267.832636673 74.568022765 267.766940456 74.571687792 267.753017936 74.554394205 267.818800515 74.550472738 |
| 56863512 | jw01151001001_03101_00001 | 214.735 | 1151 | POLYGON ICRS 268.091803329 74.608826495 267.943092794 74.616030022 267.912318626 74.578289816 268.058609787 74.570410560 |
| 56863582 | jw01151001001_05101_00001 | 203.999 | 1151 | POLYGON ICRS 267.823569171 74.579914010 267.758823764 74.583483198 267.745047350 74.566390249 267.809917556 74.562619029 |
| 56863557 | jw01151001001_05101_00002 | 203.999 | 1151 | POLYGON ICRS 267.832637174 74.568022531 267.766940886 74.571687467 267.753018708 74.554393860 267.818801363 74.550472484 |
| 56863823 | jw01151001001_06101_00001 | 214.735 | 1151 | POLYGON ICRS 268.091803198 74.608826549 267.943092604 74.616029989 267.912318750 74.578289765 268.058609977 74.570410594 |
| 56863493 | jw01151001001_08101_00001 | 203.999 | 1151 | POLYGON ICRS 267.818105646 74.572500244 267.753393956 74.576073744 267.739607888 74.558981714 267.804444175 74.555206172 |
| 56875469 | jw01151020001_03101_00001 | 214.735 | 1151 | POLYGON ICRS 241.403250845 62.406808505 241.320362209 62.395214146 241.341730845 62.357890793 241.424148058 62.368600633 |
| 56875337 | jw01151021001_02102_00001 | 118.104 | 1151 | POLYGON ICRS 267.913114360 74.594280874 267.847798665 74.598304471 267.832287729 74.581187911 267.897484698 74.576921755 |
| ... | ... | ... | ... | ... |
| 56968123 | jw01155005001_0210a_00002 | 150.315 | 1155 | POLYGON ICRS 268.948931490 65.883692410 268.862026455 65.888823867 268.848510660 65.853853484 268.935616643 65.847844473 |
| 56968107 | jw01155005001_0210b_00001 | 150.315 | 1155 | POLYGON ICRS 268.943367232 65.865137421 268.900206631 65.867886945 268.893348799 65.850424281 268.936614729 65.847418646 |
| 56968099 | jw01155005001_0210b_00002 | 150.315 | 1155 | POLYGON ICRS 268.897309483 65.868076519 268.854801968 65.870734177 268.848044059 65.853472441 268.890674791 65.850613599 |
| 56967383 | jw01155007001_02102_00001 | 1191.781 | 1155 | POLYGON ICRS 268.953421618 65.883348262 268.910258263 65.885838025 268.903866273 65.868430578 268.947013758 65.865693295 |
| 56967393 | jw01155007001_02103_00001 | 1191.781 | 1155 | POLYGON ICRS 268.900582798 65.867357807 268.858088887 65.870023805 268.851308616 65.852766994 268.893929725 65.849900846 |
| 56967357 | jw01155007001_02104_00001 | 1191.781 | 1155 | POLYGON ICRS 268.907471989 65.885893297 268.865026422 65.888465047 268.858577317 65.871266296 268.901022967 65.868503644 |
| 56969123 | jw01155-o001_t018_nircam | 150.315 | 1155 | POLYGON ICRS 268.950105056 65.884072557 268.906939249 65.886554426 268.900565087 65.869142126 268.943721766 65.866414693 |
| 56968129 | jw01155-o003_t018_nircam | 246.946 | 1155 | POLYGON ICRS 268.897309446 65.868076445 268.854801924 65.870734081 268.848044068 65.853472341 268.890674808 65.850613522 |
| 56968698 | jw01155-o005_t018_nircam | 246.946 | 1155 | POLYGON ICRS 268.897309130 65.868076445 268.854801607 65.870734077 268.848043759 65.853472337 268.890674500 65.850613521 |
| 56969356 | jw01155-o007_t018_nircam | 4767.124 | 1155 | POLYGON 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
| ArchiveFileID | fileSetName | opticalElements | s_region |
|---|---|---|---|
| int64 | str25 | str12 | str121 |
| 215512747 | jw03435006001_16101_00002 | F100LP;G140M | POLYGON ICRS 202.479810587 47.194679926 202.481582645 47.194679926 202.481582645 47.195951365 202.479810587 47.195951365 |
| 215512621 | jw03435006001_24101_00002 | F170LP;G235M | POLYGON ICRS 202.479815830 47.194677897 202.481587846 47.194677897 202.481587846 47.195949206 202.479815830 47.195949206 |
| 215509694 | jw03435006001_32101_00002 | F170LP;G235M | POLYGON ICRS 202.479816081 47.194677948 202.481588097 47.194677948 202.481588097 47.195949257 202.479816081 47.195949257 |
| 215510113 | jw03435006001_40101_00002 | F290LP;G395M | POLYGON ICRS 202.479818837 47.194676959 202.481590938 47.194676959 202.481590938 47.195948412 202.479818837 47.195948412 |
| 215509514 | jw03435006001_48101_00002 | F290LP;G395M | POLYGON 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
| ArchiveFileID | fileSetName | targprop | targ_ra | targ_dec | s_region |
|---|---|---|---|---|---|
| int64 | str25 | str20 | float64 | float64 | str121 |
| 205533519 | jw01193026001_02101_00001 | VEGA | 279.2364266145171 | 38.78556769656323 | POLYGON ICRS 279.221700461 38.783440608 279.235112217 38.771692654 279.250086725 38.782192003 279.236789373 38.793944210 |
| 205533501 | jw01193026001_02101_00002 | VEGA | 279.2364266153141 | 38.7855676974483 | POLYGON ICRS 279.217873046 38.787051938 279.231286202 38.775304485 279.246260824 38.785804392 279.232962076 38.797556103 |
| 205533495 | jw01193026001_02101_00003 | VEGA | 279.2364266161172 | 38.78556769833999 | POLYGON ICRS 279.222621156 38.789548166 279.236033992 38.777800164 279.251009844 38.788299460 279.237711422 38.800051715 |
| 205533525 | jw01193026001_02101_00004 | VEGA | 279.2364266169163 | 38.78556769922733 | POLYGON ICRS 279.225040903 38.786403830 279.238452740 38.774655546 279.253428296 38.785154526 279.240130868 38.796907061 |
| 205519762 | jw01193027001_02101_00001 | VEGA-COPY-MIRI-CORON | 279.2364266191411 | 38.78556770169765 | POLYGON 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
| ArchiveFileID | fileSetName | targ_ra | instrume | exp_type | program | proposal_type | targtype | s_region |
|---|---|---|---|---|---|---|---|---|
| int64 | str25 | float64 | str4 | str9 | int64 | str3 | str5 | str117 |
| 205629426 | jw01189005001_02101_00006 | 74.72636096419268 | MIRI | MIR_IMAGE | 1189 | GTO | FIXED | POLYGON ICRS 74.725782945 64.586608267 74.715344452 64.580202182 74.730412964 64.575710032 74.740870424 64.582110094 |
| 205629438 | jw01189005001_02101_00007 | 74.72636096470079 | MIRI | MIR_IMAGE | 1189 | GTO | FIXED | POLYGON ICRS 74.724613042 64.588027121 74.714174271 64.581620957 74.729243755 64.577128922 74.739701494 64.583529063 |
| 205629432 | jw01189005001_02101_00008 | 74.72636096498769 | MIRI | MIR_IMAGE | 1189 | GTO | FIXED | POLYGON ICRS 74.724612505 64.588027111 74.714173725 64.581620950 74.729243203 64.577128911 74.739700951 64.583529050 |
| 205629361 | jw01189015001_02101_00001 | 74.72636283572133 | MIRI | MIR_IMAGE | 1189 | GTO | FIXED | POLYGON ICRS 74.684357400 64.625764236 74.649592863 64.598263434 74.713910257 64.583249516 74.749370524 64.610641874 |
| 205629354 | jw01189015001_02101_00002 | 74.72636283828368 | MIRI | MIR_IMAGE | 1189 | GTO | FIXED | POLYGON ICRS 74.685792422 64.625698617 74.651026321 64.598198198 74.715342662 64.583183572 74.750804481 64.610575539 |
| 205629326 | jw01189015001_02103_00001 | 74.7263628414447 | MIRI | MIR_IMAGE | 1189 | GTO | FIXED | POLYGON ICRS 74.684356352 64.625764153 74.649591534 64.598263417 74.713908773 64.583249378 74.749369319 64.610641668 |
| 205629307 | jw01189015001_02103_00002 | 74.72636284399516 | MIRI | MIR_IMAGE | 1189 | GTO | FIXED | POLYGON ICRS 74.685792234 64.625698686 74.651026069 64.598198283 74.715342373 64.583183629 74.750804256 64.610575580 |
| 205629290 | jw01189015001_02105_00001 | 74.7263628471562 | MIRI | MIR_IMAGE | 1189 | GTO | FIXED | POLYGON ICRS 74.684356397 64.625764293 74.649591578 64.598263558 74.713908817 64.583249519 74.749369363 64.610641809 |
| 205629265 | jw01189015001_02105_00002 | 74.72636284971881 | MIRI | MIR_IMAGE | 1189 | GTO | FIXED | POLYGON ICRS 74.685792376 64.625698852 74.651026242 64.598198442 74.715342562 64.583183802 74.750804414 64.610575759 |
| 205851968 | jw01189-o005_t002_miri | 74.72636096235495 | MIRI | MIR_IMAGE | 1189 | GTO | FIXED | POLYGON ICRS 74.723431952 64.589614888 74.709376918 64.580988713 74.729294948 64.575009120 74.743353205 64.583633401 |
| 205871775 | jw01189-o015_t002_miri | 74.72636283572133 | MIRI | MIR_IMAGE | 1189 | GTO | FIXED | POLYGON 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
