|
12 | 12 | from astropy.io import fits
|
13 | 13 | import astropy.units as u
|
14 | 14 |
|
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 |
16 | 16 |
|
17 | 17 | from ..utils import ResolverError
|
18 | 18 | from ...exceptions import (InputWarning, InvalidQueryError, MaxResultsWarning,
|
@@ -51,6 +51,91 @@ def test_resolve_object(self):
|
51 | 51 | ticobj_loc = utils.resolve_object("TIC 141914082")
|
52 | 52 | assert round(ticobj_loc.separation(SkyCoord("94.6175354 -72.04484622", unit='deg')).value, 4) == 0
|
53 | 53 |
|
| 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 | + |
54 | 139 | ###################
|
55 | 140 | # MastClass tests #
|
56 | 141 | ###################
|
|
0 commit comments