33Mission-Specific Queries
44************************
55
6- The `~astroquery.mast.MastMissionsClass ` class allows for search queries based on mission-specific
6+ The `~astroquery.mast.MastMissionsClass ` class allows for search queries based on mission-specific
77metadata for a given data collection. This metadata includes header keywords, proposal information, and observational parameters.
88The following missions/products are currently available for search:
99
@@ -49,12 +49,12 @@ To search for JWST metadata, the ``mission`` attribute is reassigned to ``'JWST'
4949Querying Missions
5050==================
5151
52- The MastMissions interface provides three closely related query methods. All three methods return results as an `~astropy.table.Table `
53- and all three support column-based filtering, sorting, and result limiting. The primary difference between them is how positional
52+ The MastMissions interface provides three closely related query methods. All three methods return results as an `~astropy.table.Table `
53+ and all three support column-based filtering, sorting, and result limiting. The primary difference between them is how positional
5454constraints are specified.
5555
5656At a high level:
57- - `~astroquery.mast.MastMissionsClass.query_criteria ` is the most flexible method. It supports purely column-based queries,
57+ - `~astroquery.mast.MastMissionsClass.query_criteria ` is the most flexible method. It supports purely column-based queries,
5858 purely positional queries, or a combination of both.
5959
6060 - `~astroquery.mast.MastMissionsClass.query_region ` is a convenience wrapper for positional queries using coordinates.
@@ -78,7 +78,7 @@ using the `~astroquery.mast.MastMissionsClass.get_column_list` method.
7878
7979Keyword arguments can also be used to refine results further. The following parameters are available:
8080
81- - ``radius ``: For positional searches only. Only return results within a certain distance from an object or set of coordinates.
81+ - ``radius ``: For positional searches only. Only return results within a certain distance from an object or set of coordinates.
8282 Default is 3 arcminutes.
8383
8484- ``limit ``: The maximum number of results to return. Default is 5000.
@@ -99,25 +99,25 @@ Writing Queries
9999----------------
100100
101101The `~astroquery.mast.MastMissionsClass.query_criteria ` method supports both positional parameters and column-based filters.
102- Positional constraints are optional.
102+ Positional constraints are optional.
103103
104104Supported positional parameters include:
105105
106106 - ``coordinates `` : Sky coordinates around which to perform a cone search.
107107 - ``object_name `` : Name(s) of the object(s) around which to perform a cone search.
108108 - ``resolver `` : Resolver service to use for object name resolution.
109- - ``radius `` : Radius of the cone searches around the specified coordinates or object names. Can be defined as an `~astropy.units.Quantity `,
109+ - ``radius `` : Radius of the cone searches around the specified coordinates or object names. Can be defined as an `~astropy.units.Quantity `,
110110 a string with units (e.g., ``"10 arcsec" ``), or a numeric value interpreted as degrees.
111111
112- Multiple coordinates or objects may be queried in a single request. The ``coordinates `` and ``object_names `` parameters
112+ Multiple coordinates or objects may be queried in a single request. The ``coordinates `` and ``object_names `` parameters
113113accept a single value, an iterable of values, or a comma-separated string. When multiple values are provided for either parameter,
114114results matching *any * of the supplied positions are returned.
115115
116116.. doctest-remote-data ::
117117
118118 >>> from astropy.coordinates import SkyCoord
119119 >>> select_cols = [" sci_targname" , " sci_pep_id" , " sci_status" ]
120- >>> results = missions.query_criteria(coordinates = [SkyCoord(245.89675 , - 26.52575 , unit = ' deg' ), " 205.54842 28.37728" ],
120+ >>> results = missions.query_criteria(coordinates = [SkyCoord(245.89675 , - 26.52575 , unit = ' deg' ), " 205.54842 28.37728" ],
121121 ... object_names= [" M2" , " M9" ],
122122 ... radius= 0.1 ,
123123 ... select_cols= select_cols,
@@ -168,13 +168,13 @@ Criteria syntax supports several operations:
168168
169169- For numeric or date columns, select an inclusive range with the syntax ``'#..#' ``.
170170
171- - Wildcards are special characters used in search patterns to represent one or more unknown characters,
171+ - Wildcards are special characters used in search patterns to represent one or more unknown characters,
172172 allowing for flexible matching of strings. The wildcard character is ``* `` and it replaces any number
173173 of characters preceding, following, or in between existing characters, depending on its placement.
174174
175175.. note ::
176176
177- For the Roman mission, query methods also support the ``pass_id `` parameter as an alias for the ``pass `` column,
177+ For the Roman mission, query methods also support the ``pass_id `` parameter as an alias for the ``pass `` column,
178178 which refers to a single iteration of a pass plan. This is to avoid conflicts with the reserved Python keyword.
179179
180180.. doctest-remote-data ::
@@ -196,7 +196,7 @@ Criteria syntax supports several operations:
196196 N4A702010 GAL-CLUS-0026+1653-ARCC F110W IMAGE
197197 N4A705010 GAL-CLUS-0026+1653-ARCC F110W IMAGE
198198
199- The `~astroquery.mast.MastMissionsClass.query_region ` and `~astroquery.mast.MastMissionsClass.query_object ` methods are
199+ The `~astroquery.mast.MastMissionsClass.query_region ` and `~astroquery.mast.MastMissionsClass.query_object ` methods are
200200convenience wrappers around `~astroquery.mast.MastMissionsClass.query_criteria `:
201201
202202 - `~astroquery.mast.MastMissionsClass.query_region ` requires ``coordinates ``.
@@ -209,7 +209,7 @@ Both methods also accept column-based criteria, which are applied in the same wa
209209
210210 >>> regionCoords = SkyCoord(210.80227 , 54.34895 , unit = (' deg' , ' deg' ))
211211 >>> select_cols = [" sci_stop_time" , " sci_targname" , " sci_start_time" , " sci_status" ]
212- >>> results = missions.query_region(regionCoords,
212+ >>> results = missions.query_region(regionCoords,
213213 ... radius= 3 ,
214214 ... sci_pep_id= 12556 ,
215215 ... select_cols= select_cols,
@@ -226,8 +226,8 @@ Both methods also accept column-based criteria, which are applied in the same wa
226226
227227.. doctest-remote-data ::
228228
229- >>> results = missions.query_object(' M101' ,
230- ... radius= 3 ,
229+ >>> results = missions.query_object(' M101' ,
230+ ... radius= 3 ,
231231 ... select_cols= select_cols,
232232 ... sort_by= ' sci_targname' )
233233 >>> results[:5 ] # doctest: +IGNORE_OUTPUT
@@ -248,11 +248,11 @@ Getting Product Lists
248248----------------------
249249
250250Each observation returned from a MAST query can have one or more associated data products. Given
251- one or more datasets or dataset IDs, the `~astroquery.mast.MastMissionsClass.get_product_list ` function
251+ one or more datasets or dataset IDs, the `~astroquery.mast.MastMissionsClass.get_product_list ` function
252252will return a `~astropy.table.Table ` containing the associated data products.
253253
254- `~astroquery.mast.MastMissionsClass.get_product_list ` also includes an optional ``batch_size `` parameter,
255- which controls how many datasets are sent to the MAST service per request. This can be useful for managing
254+ `~astroquery.mast.MastMissionsClass.get_product_list ` also includes an optional ``batch_size `` parameter,
255+ which controls how many datasets are sent to the MAST service per request. This can be useful for managing
256256memory usage or avoiding timeouts when requesting product lists for large numbers of datasets.
257257If not provided, batch_size defaults to 1000.
258258
@@ -262,7 +262,7 @@ If not provided, batch_size defaults to 1000.
262262 ... sci_hlsp= ' >1' )
263263 >>> products = missions.get_product_list(datasets[:2 ], batch_size = 1000 )
264264 >>> print (products[:5 ]) # doctest: +IGNORE_OUTPUT
265- product_key access dataset ... category size type
265+ product_key access dataset ... category size type
266266 ---------------------------- ------ --------- ... ---------- --------- -------
267267 JBTAA0010_jbtaa0010_asn.fits PUBLIC JBTAA0010 ... AUX 11520 science
268268 JBTAA0010_jbtaa0010_drz.fits PUBLIC JBTAA0010 ... CALIBRATED 214655040 science
@@ -298,8 +298,8 @@ and any other of the product fields.
298298The **AND ** operation is applied between filters, and the **OR ** operation is applied within each filter set, except in the case of negated values.
299299
300300A filter value can be negated by prefiing it with ``! ``, meaning that rows matching that value will be excluded from the results.
301- When any negated value is present in a filter set, any positive values in that set are combined with **OR ** logic, and the negated
302- values are combined with **AND ** logic against the positives.
301+ When any negated value is present in a filter set, any positive values in that set are combined with **OR ** logic, and the negated
302+ values are combined with **AND ** logic against the positives.
303303
304304For example:
305305 - ``file_suffix=['A', 'B', '!C'] `` → (file_suffix != C) AND (file_suffix == A OR file_suffix == B)
@@ -318,28 +318,53 @@ The filter below returns FITS products that are "science" type **and** less than
318318 >>> filtered = missions.filter_products(products,
319319 ... extension= ' fits' ,
320320 ... type = ' science' ,
321- ... size= ' <=20000' ,
321+ ... size= ' <=20000' ,
322322 ... file_suffix= [' ASN' , ' JIF' ])
323323 >>> print (filtered) # doctest: +IGNORE_OUTPUT
324- product_key access dataset ... category size type
324+ product_key access dataset ... category size type
325325 ---------------------------- ------ --------- ... -------------- ----- -------
326326 JBTAA0010_jbtaa0010_asn.fits PUBLIC JBTAA0010 ... AUX 11520 science
327327 JBTAA0020_jbtaa0020_asn.fits PUBLIC JBTAA0020 ... AUX 11520 science
328328
329329
330+ Reading Data Products
331+ ======================
332+
333+ The `~astroquery.mast.MastMissionsClass.read_product ` function allows you to read a data product directly into memory as an `~astropy.io.fits.HDUList `
334+ or an `~asdf.AsdfFile ` object. The function accepts a product URI or a direct filename (for certain missions) as input.
335+
336+ Products from the Roman Space Telescope mission are returned as ASDF files and can be read into memory as `~asdf.AsdfFile ` objects.
337+ This requires the `~asdf ` and ``fsspec `` packages to be installed. Other optional packages for reading products may be required depending on the product
338+ type and file format. These packages are ``gwcs ``, ``lz4 ``, and ``roman_datamodels ``. To install astroquery with all optional dependencies,
339+ use ``pip install astroquery[all] ``.
340+
341+ Remember that this method returns an open file object, so it is the user's responsibility to close the file when finished. This can be done
342+ with a context manager or by calling the ``close() `` method on the returned object.
343+
344+ .. doctest-remote-data ::
345+ >>> obj = missions.read_product(" jbtaa0010_asn.fits" ) # doctest: +IGNORE_OUTPUT
346+ >>> print (type (obj))
347+ <class 'astropy.io.fits.hdu.hdulist.HDUList'>
348+ >>> obj.info() # doctest: +IGNORE_OUTPUT
349+ Filename: /Users/user/.astropy/cache/download/url/6555b8e890752df0de737940d3afb19d/contents
350+ No. Name Ver Type Cards Dimensions Format
351+ 0 PRIMARY 1 PrimaryHDU 44 ()
352+ 1 ASN 1 BinTableHDU 25 3R x 3C [14A, 14A, L]
353+ >>> obj.close()
354+
330355Downloding Data
331356===============
332357
333358Downloading Data Products
334359-------------------------
335360
336- The `~astroquery.mast.MastMissionsClass.download_products ` function accepts a table of products like the one above
337- and will download the products to your local machine. Products may also be provided as dataset IDs with product filters,
361+ The `~astroquery.mast.MastMissionsClass.download_products ` function accepts a table of products like the one above
362+ and will download the products to your local machine. Products may also be provided as dataset IDs with product filters,
338363or as JSON product metadata sent by the MAST subscription service (either as a local JSON file or as in-memory data).
339364
340365By default, products will be downloaded into the current working directory, in a subdirectory called ``mastDownload ``.
341- The full local filepaths will have the form ``mastDownload/<mission>/<Dataset ID>/file. `` You can change the download
342- directory using the ``download_dir `` parameter. If ``flat=True `` is specified, all files will be downloaded directly into the
366+ The full local filepaths will have the form ``mastDownload/<mission>/<Dataset ID>/file. `` You can change the download
367+ directory using the ``download_dir `` parameter. If ``flat=True `` is specified, all files will be downloaded directly into the
343368``download_dir `` without any subdirectories.
344369
345370.. doctest-remote-data ::
@@ -349,14 +374,14 @@ directory using the ``download_dir`` parameter. If ``flat=True`` is specified, a
349374 Downloading URL https://mast.stsci.edu/search/hst/api/v0.1/retrieve_product?product_name=JBTAA0020%2Fjbtaa0020_asn.fits to mastDownload/hst/JBTAA0020/jbtaa0020_asn.fits ... [Done]
350375 Downloading URL https://mast.stsci.edu/search/hst/api/v0.1/retrieve_product?product_name=JBTAA0020%2Fjbtaa0020_jif.fits to mastDownload/hst/JBTAA0020/jbtaa0020_jif.fits ... [Done]
351376 >>> print (manifest) # doctest: +IGNORE_OUTPUT
352- Local Path Status Message URL
377+ Local Path Status Message URL
353378 --------------------------------------------- -------- ------- ----
354379 mastDownload/hst/JBTAA0010/jbtaa0010_asn.fits COMPLETE None None
355380 mastDownload/hst/JBTAA0010/jbtaa0010_jif.fits COMPLETE None None
356381 mastDownload/hst/JBTAA0020/jbtaa0020_asn.fits COMPLETE None None
357382 mastDownload/hst/JBTAA0020/jbtaa0020_jif.fits COMPLETE None None
358383
359- The function also accepts dataset IDs and product filters as input for a more streamlined workflow.
384+ The function also accepts dataset IDs and product filters as input for a more streamlined workflow.
360385
361386.. doctest-remote-data ::
362387 >>> missions.download_products([' JBTAA0010' , ' JBTAA0020' ],
@@ -374,7 +399,7 @@ Downloading a Single File
374399To download a single data product file, use the `~astroquery.mast.MastMissionsClass.download_file ` function with
375400a MAST URI as input. Some missions (e.g., HST, JWST) accept direct filenames as input, but others require a fully-qualified ``mast: `` URI.
376401
377- The default is to download the file to the current working directory, but you can specify the download directory or filepath with
402+ The default is to download the file to the current working directory, but you can specify the download directory or filepath with
378403the ``local_path `` keyword argument.
379404
380405.. doctest-remote-data ::
0 commit comments