Skip to content

Commit 6933ec1

Browse files
authored
Merge pull request #3055 from snbianco/ASB-22801-jwst-mast-missions
Update MastMissions Documentation and Tests
2 parents 34474ff + 2a5156b commit 6933ec1

File tree

4 files changed

+162
-70
lines changed

4 files changed

+162
-70
lines changed

astroquery/mast/missions.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ def query_region_async(self, coordinates, *, radius=3*u.arcmin, limit=5000, offs
112112

113113
# basic params
114114
params = {'target': [f"{coordinates.ra.deg} {coordinates.dec.deg}"],
115-
'radius': radius.arcmin,
116-
'radius_units': 'arcminutes',
115+
'radius': radius.arcsec,
116+
'radius_units': 'arcseconds',
117117
'limit': limit,
118118
'offset': offset}
119119

@@ -180,8 +180,8 @@ def query_criteria_async(self, *, coordinates=None, objectname=None, radius=3*u.
180180
params = {"limit": self.limit, "offset": offset, 'select_cols': select_cols}
181181
if coordinates:
182182
params["target"] = [f"{coordinates.ra.deg} {coordinates.dec.deg}"]
183-
params["radius"] = radius.arcmin
184-
params["radius_units"] = 'arcminutes'
183+
params["radius"] = radius.arcsec
184+
params["radius_units"] = 'arcseconds'
185185

186186
if not self._service_api_connection.check_catalogs_criteria_params(criteria):
187187
raise InvalidQueryError("At least one non-positional criterion must be supplied.")

astroquery/mast/tests/test_mast.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def service_mockreturn(self, method="POST", url=None, data=None, timeout=10, use
119119
filename = data_path(DATA_FILES['z_survey'])
120120
else:
121121
filename = data_path(DATA_FILES['z_cutout_fit'])
122-
elif use_json and data['radius'] == 5:
122+
elif use_json and data['radius'] == 300:
123123
filename = data_path(DATA_FILES["mission_incorrect_results"])
124124
elif use_json:
125125
filename = data_path(DATA_FILES["mission_search_results"])

astroquery/mast/tests/test_mast_remote.py

+86-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from astropy.io import fits
1313
import astropy.units as u
1414

15-
from astroquery.mast import Observations, utils, Mast, Catalogs, Hapcut, Tesscut, Zcut
15+
from astroquery.mast import Observations, utils, Mast, Catalogs, Hapcut, Tesscut, Zcut, MastMissions
1616

1717
from ..utils import ResolverError
1818
from ...exceptions import (InputWarning, InvalidQueryError, MaxResultsWarning,
@@ -51,6 +51,91 @@ def test_resolve_object(self):
5151
ticobj_loc = utils.resolve_object("TIC 141914082")
5252
assert round(ticobj_loc.separation(SkyCoord("94.6175354 -72.04484622", unit='deg')).value, 4) == 0
5353

54+
###########################
55+
# MissionSearchClass Test #
56+
###########################
57+
58+
def test_missions_get_column_list(self):
59+
columns = MastMissions().get_column_list()
60+
assert len(columns) > 1
61+
assert isinstance(columns, Table)
62+
assert list(columns.columns.keys()) == ['name', 'data_type', 'description']
63+
64+
def test_missions_query_region_async(self):
65+
coords = SkyCoord(83.6287, 22.0147, unit="deg")
66+
response = MastMissions.query_region_async(coords, radius=1)
67+
assert isinstance(response, Response)
68+
assert response.status_code == 200
69+
70+
def test_missions_query_region(self):
71+
select_cols = ['sci_targname', 'sci_instrume']
72+
result = MastMissions.query_region("245.89675 -26.52575",
73+
radius=0.1,
74+
sci_instrume="WFC3, ACS",
75+
select_cols=select_cols
76+
)
77+
assert isinstance(result, Table)
78+
assert len(result) > 0
79+
assert (result['ang_sep'].data.data.astype('float') < 0.1).all()
80+
ins_strip = np.char.strip(result['sci_instrume'].data)
81+
assert ((ins_strip == 'WFC3') | (ins_strip == 'ACS')).all()
82+
assert all(c in list(result.columns.keys()) for c in select_cols)
83+
84+
def test_missions_query_object_async(self):
85+
response = MastMissions.query_object_async("M4", radius=0.1)
86+
assert isinstance(response, Response)
87+
assert response.status_code == 200
88+
89+
def test_missions_query_object(self):
90+
result = MastMissions.query_object("NGC6121",
91+
radius=6*u.arcsec,
92+
sci_pi_last_name='*LE*',
93+
sci_spec_1234='!F395N'
94+
)
95+
assert isinstance(result, Table)
96+
assert len(result) > 0
97+
assert "NGC6121" in result["sci_targname"]
98+
assert (result['ang_sep'].data.data.astype('float') < 0.1).all()
99+
assert (result['sci_pi_last_name'] == 'LEE').all()
100+
assert 'F395N' not in result['sci_spec_1234']
101+
102+
def test_missions_query_criteria_async(self):
103+
response = MastMissions.query_criteria_async(sci_pep_id=12557,
104+
sci_obs_type='SPECTRUM',
105+
sci_aec='S')
106+
assert isinstance(response, Response)
107+
assert response.status_code == 200
108+
109+
def test_missions_query_criteria(self):
110+
# Non-positional search
111+
with pytest.warns(MaxResultsWarning):
112+
result = MastMissions.query_criteria(sci_pep_id=12557,
113+
sci_obs_type='SPECTRUM',
114+
sci_aec='S',
115+
limit=3,
116+
select_cols=['sci_pep_id', 'sci_obs_type', 'sci_aec'])
117+
assert isinstance(result, Table)
118+
assert len(result) == 3
119+
assert (result['sci_pep_id'] == 12557).all()
120+
assert (result['sci_obs_type'] == 'SPECTRUM').all()
121+
assert (result['sci_aec'] == 'S').all()
122+
123+
# Positional criteria search
124+
result = MastMissions.query_criteria(objectname='NGC6121',
125+
radius=0.1,
126+
sci_start_time='<2012',
127+
sci_actual_duration='0..200'
128+
)
129+
assert len(result) == 3
130+
assert (result['ang_sep'].data.data.astype('float') < 0.1).all()
131+
assert (result['sci_start_time'] < '2012').all()
132+
assert ((result['sci_actual_duration'] >= 0) & (result['sci_actual_duration'] <= 200)).all()
133+
134+
# Raise error if a non-positional criterion is not supplied
135+
with pytest.raises(InvalidQueryError):
136+
MastMissions.query_criteria(coordinates="245.89675 -26.52575",
137+
radius=1)
138+
54139
###################
55140
# MastClass tests #
56141
###################

docs/mast/mast_missions.rst

+71-64
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ Mission-Specific Search Queries
77
===============================
88

99
These queries allow for searches based on mission-specific metadata for a given
10-
data collection. Currently it provides access to a broad set of Hubble Space
11-
Telescope (HST) metadata, including header keywords, proposal information, and
12-
observational parameters. The available metadata includes all information that
13-
was previously available in the original HST web search form, and are present in
14-
the current `Mission Search interface <https://mast.stsci.edu/search/ui/#/hst>`__.
10+
data collection. Currently, it provides access to a broad set of Hubble Space
11+
Telescope (HST) and James Webb Space Telescope (JWST) metadata, including header keywords,
12+
proposal information, and observational parameters.
1513

16-
**Note:** this API interface does not yet support data product download, only
17-
metadata earch access.
14+
**Note:** This API interface does not yet support data product downloads, only
15+
metadata search access.
1816

19-
An object of MastMissions class is instantiated with a default mission of 'hst' and
20-
default service set to 'search'.
17+
An object of the ``MastMissions`` class is instantiated with a default mission of ``'hst'`` and
18+
default service set to ``'search'``. The searchable metadata for Hubble encompasses all information that
19+
was previously accessible through the original HST web search form and is now available in
20+
the current `MAST HST Search Form <https://mast.stsci.edu/search/ui/#/hst>`__.
2121

2222
.. doctest-remote-data::
2323

@@ -28,89 +28,96 @@ default service set to 'search'.
2828
>>> missions.service
2929
'search'
3030

31-
The missions object can be used to search metadata using by sky position, or other criteria.
32-
The keyword arguments can be used to specify output characteristics like selec_cols and
33-
sort_by and conditions that filter on values like proposal id, pi last name etc.
34-
The available column names for a mission are returned by the
35-
`~astroquery.mast.MastMissionsClass.get_column_list` function.
31+
To search for JWST metadata, a ``MastMissions`` object is instantiated with a value of ``'jwst'`` for ``mission``.
32+
The searchable metadata for Webb encompasses all information that is available in
33+
the current `MAST JWST Search Form <https://mast.stsci.edu/search/ui/#/jwst>`__.
34+
35+
.. doctest-remote-data::
36+
37+
>>> from astroquery.mast import MastMissions
38+
>>> missions = MastMissions(mission='jwst')
39+
>>> missions.mission
40+
'jwst'
41+
42+
The ``missions`` object can be used to search metadata by object name, sky position, or other criteria.
43+
When writing queries, keyword arguments can be used to specify output characteristics and filter on
44+
values like instrument, exposure type, and principal investigator. The available column names for a
45+
mission are returned by the `~astroquery.mast.MastMissionsClass.get_column_list` function.
3646

3747
.. doctest-remote-data::
3848

3949
>>> from astroquery.mast import MastMissions
4050
>>> missions = MastMissions(mission='hst')
4151
>>> columns = missions.get_column_list()
4252

43-
For positional searches, the columns "ang_sep", "sci_data_set_name", "search_key" and "search_position"
44-
will always be included, in addition to any columns specified using "select_cols". For non-positional
45-
searches, "search_key" and "sci_data_set_name" will always be included, in addition to any columns
46-
specified using "select_cols".
53+
Metadata queries can be performed on a particular region in the sky. Passing in a set of coordinates to the
54+
`~astroquery.mast.MastMissionsClass.query_region` function returns datasets that fall within a
55+
certain radius value of that point. This type of search is also known as a cone search.
4756

48-
For a non positional search, ``select_cols`` would always include ``'search_key'`` and ``'sci_data_set_name'``.
57+
The ``select_cols`` keyword argument specifies a list of columns to be included in the response.
58+
The ``sort_by`` keyword argument specifies a column (or columns) to sort the results by.
4959

5060
.. doctest-remote-data::
5161

5262
>>> from astroquery.mast import MastMissions
5363
>>> from astropy.coordinates import SkyCoord
5464
>>> missions = MastMissions(mission='hst')
5565
>>> regionCoords = SkyCoord(210.80227, 54.34895, unit=('deg', 'deg'))
56-
>>> results = missions.query_region(regionCoords, radius=3, sci_pep_id=12556,
66+
>>> results = missions.query_region(regionCoords,
67+
... radius=3,
68+
... sci_pep_id=12556,
5769
... select_cols=["sci_stop_time", "sci_targname", "sci_start_time", "sci_status"],
5870
... sort_by=['sci_targname'])
5971
>>> results[:5] # doctest: +IGNORE_OUTPUT
6072
<Table masked=True length=5>
61-
sci_status sci_targname sci_data_set_name ang_sep sci_pep_id search_pos sci_pi_last_name search_key
62-
str6 str16 str9 str20 int64 str18 str6 str27
63-
---------- ---------------- ----------------- -------------------- ---------- ------------------ ---------------- ---------------------------
64-
PUBLIC NUCLEUS+HODGE602 OBQU010H0 0.017460048037303017 12556 210.80227 54.34895 GORDON 210.80227 54.34895OBQU010H0
65-
PUBLIC NUCLEUS+HODGE602 OBQU01050 0.017460048037303017 12556 210.80227 54.34895 GORDON 210.80227 54.34895OBQU01050
66-
PUBLIC NUCLEUS+HODGE602 OBQU01030 0.022143836477276503 12556 210.80227 54.34895 GORDON 210.80227 54.34895OBQU01030
67-
PUBLIC NUCLEUS+HODGE602 OBQU010F0 0.022143836477276503 12556 210.80227 54.34895 GORDON 210.80227 54.34895OBQU010F0
68-
PUBLIC NUCLEUS+HODGE602 OBQU010J0 0.04381046755938432 12556 210.80227 54.34895 GORDON 210.80227 54.34895OBQU010J0
69-
70-
for paging through the results, offset and limit can be used to specify the starting record and the number
71-
of returned records. the default values for offset and limit is 0 and 5000 respectively.
73+
search_pos sci_data_set_name sci_targname sci_start_time sci_stop_time ang_sep sci_status
74+
------------------ ----------------- ---------------- -------------------------- -------------------------- -------------------- ----------
75+
210.80227 54.34895 OBQU01050 NUCLEUS+HODGE602 2012-05-24T07:51:40.553000 2012-05-24T07:54:46.553000 0.017460048037303017 PUBLIC
76+
210.80227 54.34895 OBQU010H0 NUCLEUS+HODGE602 2012-05-24T09:17:38.570000 2012-05-24T09:20:44.570000 0.017460048037303017 PUBLIC
77+
210.80227 54.34895 OBQU01030 NUCLEUS+HODGE602 2012-05-24T07:43:20.553000 2012-05-24T07:46:26.553000 0.022143836477276503 PUBLIC
78+
210.80227 54.34895 OBQU010F0 NUCLEUS+HODGE602 2012-05-24T09:09:18.570000 2012-05-24T09:12:24.570000 0.022143836477276503 PUBLIC
79+
210.80227 54.34895 OBQU01070 NUCLEUS+HODGE602 2012-05-24T08:00:00.553000 2012-05-24T08:03:06.553000 0.04381046755938432 PUBLIC
7280

73-
.. doctest-remote-data::
81+
You may notice that the above query returned more columns than were specified in the ``select_cols``
82+
argument. For each mission, certain columns are automatically returned.
7483

75-
>>> from astroquery.mast import MastMissions
76-
>>> from astropy.coordinates import SkyCoord
77-
>>> missions = MastMissions()
78-
>>> results = missions.query_criteria(sci_start_time=">=2021-01-01 00:00:00",
79-
... select_cols=["sci_stop_time", "sci_targname", "sci_start_time", "sci_status", "sci_pep_id"],
80-
... sort_by=['sci_pep_id'], limit=1000, offset=1000) # doctest: +IGNORE_WARNINGS
81-
... # MaxResultsWarning('Maximum results returned, may not include all sources within radius.')
82-
>>> len(results)
83-
1000
84+
* *HST*: For positional searches, the columns ``ang_sep``, ``sci_data_set_name``, and ``search_pos``
85+
are always included in the query results. For non-positional searches, ``sci_data_set_name`` is always
86+
present.
8487

85-
Metadata queries can also be performed using object names with the
86-
~astroquery.mast.MastMissionsClass.query_object function.
88+
* *JWST*: For every query, the ``ArchiveFileID`` column is always returned.
89+
90+
Searches can also be run on target names with the `~astroquery.mast.MastMissionsClass.query_object`
91+
function.
8792

8893
.. doctest-remote-data::
8994

90-
>>> results = missions.query_object('M101', radius=3, select_cols=["sci_stop_time", "sci_targname", "sci_start_time", "sci_status"],
95+
>>> results = missions.query_object('M101',
96+
... radius=3,
97+
... select_cols=["sci_stop_time", "sci_targname", "sci_start_time", "sci_status"],
9198
... sort_by=['sci_targname'])
9299
>>> results[:5] # doctest: +IGNORE_OUTPUT
93100
<Table masked=True length=5>
94-
ang_sep search_pos sci_status search_key sci_stop_time sci_targname sci_start_time sci_data_set_name
95-
str20 str18 str6 str27 str26 str16 str26 str9
96-
------------------ ------------------ ---------- --------------------------- -------------------------- ------------ -------------------------- -----------------
97-
2.751140575012458 210.80227 54.34895 PUBLIC 210.80227 54.34895LDJI01010 2019-02-19T05:52:40.020000 +164.6+9.9 2019-02-19T00:49:58.010000 LDJI01010
98-
0.8000626246647815 210.80227 54.34895 PUBLIC 210.80227 54.34895J8OB02011 2003-08-27T08:27:34.513000 ANY 2003-08-27T07:44:47.417000 J8OB02011
99-
1.1261718338567348 210.80227 54.34895 PUBLIC 210.80227 54.34895J8D711J1Q 2003-01-17T00:50:22.250000 ANY 2003-01-17T00:42:06.993000 J8D711J1Q
100-
1.1454431087675097 210.80227 54.34895 PUBLIC 210.80227 54.34895JD6V01012 2017-06-15T18:33:25.983000 ANY 2017-06-15T18:10:12.037000 JD6V01012
101-
1.1457795862361977 210.80227 54.34895 PUBLIC 210.80227 54.34895JD6V01013 2017-06-15T20:08:44.063000 ANY 2017-06-15T19:45:30.023000 JD6V01013
102-
103-
Metadata queries can also be performed using non-positional parameters with the
104-
`~astroquery.mast.MastMissionsClass.query_criteria` function.
101+
search_pos sci_data_set_name sci_targname sci_start_time sci_stop_time ang_sep sci_status
102+
------------------ ----------------- ------------ -------------------------- -------------------------- ------------------ ----------
103+
210.80243 54.34875 LDJI01010 +164.6+9.9 2019-02-19T00:49:58.010000 2019-02-19T05:52:40.020000 2.7469653000840397 PUBLIC
104+
210.80243 54.34875 J8OB02011 ANY 2003-08-27T07:44:47.417000 2003-08-27T08:27:34.513000 0.8111299061221189 PUBLIC
105+
210.80243 54.34875 J8D711J1Q ANY 2003-01-17T00:42:06.993000 2003-01-17T00:50:22.250000 1.1297984178946574 PUBLIC
106+
210.80243 54.34875 JD6V01012 ANY 2017-06-15T18:10:12.037000 2017-06-15T18:33:25.983000 1.1541053362381077 PUBLIC
107+
210.80243 54.34875 JD6V01013 ANY 2017-06-15T19:45:30.023000 2017-06-15T20:08:44.063000 1.15442580192948 PUBLIC
108+
109+
For non-positional metadata queries, use the `~astroquery.mast.MastMissionsClass.query_criteria`
110+
function. For paging through results, the ``offset`` and ``limit`` keyword arguments can be used
111+
to specify the starting record and the number of returned records. The default values for ``offset``
112+
and ``limit`` are 0 and 5000, respectively.
105113

106114
.. doctest-remote-data::
107115

108-
>>> results = missions.query_criteria(sci_data_set_name="Z06G0101T", sci_pep_id="1455",
109-
... select_cols=["sci_stop_time", "sci_targname", "sci_start_time", "sci_status"],
110-
... sort_by=['sci_targname'])
111-
>>> results[:5] # doctest: +IGNORE_OUTPUT
112-
<Table masked=True length=5>
113-
search_key sci_stop_time sci_data_set_name sci_start_time sci_targname sci_status
114-
str9 str26 str9 str26 str19 str6
115-
---------- -------------------------- ----------------- -------------------------- ------------ ----------
116-
Z06G0101T 1990-05-13T11:02:34.567000 Z06G0101T 1990-05-13T10:38:09.193000 -- PUBLIC
116+
>>> results = missions.query_criteria(sci_start_time=">=2021-01-01 00:00:00",
117+
... select_cols=["sci_stop_time", "sci_targname", "sci_start_time", "sci_status", "sci_pep_id"],
118+
... sort_by=['sci_pep_id'],
119+
... limit=1000,
120+
... offset=1000) # doctest: +IGNORE_WARNINGS
121+
... # MaxResultsWarning('Maximum results returned, may not include all sources within radius.')
122+
>>> len(results)
123+
1000

0 commit comments

Comments
 (0)