Skip to content

Commit ae76d2f

Browse files
Add list_catalogs, get_images, fix documentation issues.
1 parent a7ea904 commit ae76d2f

File tree

9 files changed

+1330
-288
lines changed

9 files changed

+1330
-288
lines changed

astroquery/ipac/irsa/most/__init__.py

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,9 @@ class Conf(_config.ConfigNamespace):
1717
server = _config.ConfigItem(
1818
'https://irsa.ipac.caltech.edu/cgi-bin/MOST/nph-most',
1919
'URL address of the MOST service.')
20-
catalog = _config.ConfigItem(
21-
'wise_merge',
22-
('Default catalog to query. See the drop-down menu at '
23-
'https://irsa.ipac.caltech.edu/applications/MOST/ for options.'))
24-
input_type = _config.ConfigItem(
25-
'name_input',
26-
'Default type of query to run. One of `name_input`, `naifid_input`, '
27-
'`mpc_input` or `manual_input` corresponding to Solar System Object '
28-
'Name, NAIF ID, MPC one-line element input type or manual input of '
29-
'orbital elements.'
30-
)
31-
output_mode = _config.ConfigItem(
32-
'Full',
33-
('Set the verbosity of returned results. See the drop-down menu at '
34-
'https://irsa.ipac.caltech.edu/applications/MOST/ for options.'))
35-
ephem_step = _config.ConfigItem(
36-
0.25,
37-
'Ephemeris step size (day).'
20+
interface_url = _config.ConfigItem(
21+
'https://irsa.ipac.caltech.edu/applications/MOST/',
22+
'URL address of the MOST application interface.'
3823
)
3924
timeout = _config.ConfigItem(
4025
120,
@@ -46,6 +31,7 @@ class Conf(_config.ConfigNamespace):
4631

4732
from .core import Most, MOSTClass
4833

49-
__all__ = ['Most', 'MOSTClass',
50-
'Conf', 'conf',
51-
]
34+
__all__ = [
35+
'Most', 'MOSTClass',
36+
'Conf', 'conf',
37+
]

astroquery/ipac/irsa/most/core.py

Lines changed: 277 additions & 113 deletions
Large diffs are not rendered by default.

astroquery/ipac/irsa/tests/data/MOST_VOTable.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</DEFINITIONS>
66
<RESOURCE name="MOST Output Tables">
77
<TABLE name="imgframes_matched_final_table.tbl">
8-
<PARAM name="output_url" datatype="char" arraysize="*" value="https://irsa.ipac.caltech.edu/workspace/TMP_XIBNAd_17194/MOST/pid5856"/>
8+
<PARAM name="output_url" datatype="char" arraysize="*" value="https://irsa.ipac.caltech.edu/workspace/TMP_noPis4_23270/MOST/pid9390"/>
99
<PARAM name="catalog" datatype="char" arraysize="*" value="wise_merge"/>
1010
<PARAM name="user_input_begin_time" datatype="char" arraysize="*" value="2014-05-01"/>
1111
<PARAM name="user_input_end_time" datatype="char" arraysize="*" value="2014-05-30"/>
@@ -18,7 +18,7 @@
1818
<PARAM name="semimajor_axis" datatype="char" arraysize="*" value=" 2.333774627713947"/>
1919
<PARAM name="mean_anomaly" datatype="char" arraysize="*" value="349.752560575505981"/>
2020
<PARAM name="magnitude_parameters" datatype="char" arraysize="*" value=" 7.34 0.00"/>
21-
<PARAM name="job_time_stamp" datatype="char" arraysize="*" value="Wed Feb 8 14:40:39 2023"/>
21+
<PARAM name="job_time_stamp" datatype="char" arraysize="*" value="Fri Mar 24 16:07:12 2023"/>
2222
<PARAM name="description" datatype="char" arraysize="*" value="MOST ODBC query result"/>
2323
<PARAM name="fixlen" datatype="char" arraysize="*" value="T"/>
2424
<FIELD name="ra_obj" datatype="double" unit=""/>

astroquery/ipac/irsa/tests/data/MOST_application.html

Lines changed: 869 additions & 0 deletions
Large diffs are not rendered by default.

astroquery/ipac/irsa/tests/data/MOST_full_with_tarballs.html

Lines changed: 56 additions & 57 deletions
Large diffs are not rendered by default.

astroquery/ipac/irsa/tests/data/MOST_regular.html

Lines changed: 39 additions & 39 deletions
Large diffs are not rendered by default.

astroquery/ipac/irsa/tests/data/most_imgframes_matched_final_table.tbl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
\output_url = "https://irsa.ipac.caltech.edu/workspace/TMP_XIBNAd_17194/MOST/pid26504"
1+
\output_url = "https://irsa.ipac.caltech.edu/workspace/TMP_noPis4_23270/MOST/pid2083"
22
\catalog = "wise_merge"
33
\user_input_begin_time = "2014-05-01"
44
\user_input_end_time = "2014-05-30"
@@ -11,7 +11,7 @@
1111
\semimajor_axis = " 2.333774627713947"
1212
\mean_anomaly = "349.752560575505981"
1313
\magnitude_parameters = " 7.34 0.00"
14-
\job_time_stamp = "Wed Feb 8 11:00:12 2023"
14+
\job_time_stamp = "Fri Mar 24 15:36:59 2023"
1515
\description = MOST ODBC query result
1616
\ odbc_dsn = postgres
1717
\ odbc_table = wise.neowiser_merge_p1bm_frm

astroquery/ipac/irsa/tests/data/most_results_table.tbl

Lines changed: 14 additions & 14 deletions
Large diffs are not rendered by default.

astroquery/ipac/irsa/tests/test_most.py

Lines changed: 64 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from astropy.utils.diff import report_diff_values
1212

1313

14-
DATA_FILES = {
14+
OUTPUTMODE_FILE_MAP = {
1515
"Regular": "MOST_regular.html",
1616
"Full": "MOST_full_with_tarballs.html",
1717
"VOTable": "MOST_VOTable.xml",
@@ -25,57 +25,66 @@ def data_path(filename):
2525
return os.path.join(data_dir, filename)
2626

2727

28-
@pytest.fixture
29-
def patch_get(request):
30-
mp = request.getfixturevalue("monkeypatch")
31-
mp.setattr(Most, '_request', get_mockreturn)
32-
return mp
33-
28+
def get_mocked_return(method=None, url=None, data=None, timeout=120, **kwargs):
29+
if "results.tbl" in url:
30+
url = "most_results_table.tbl"
31+
elif "imgframes_matched_final_table.tbl" in url:
32+
url = "most_imgframes_matched_final_table.tbl"
33+
elif "applications" in url:
34+
url = "MOST_application.html"
3435

35-
def get_mockreturn(method=None, url=None, data=None, timeout=120, **kwargs):
3636
if method == "GET":
3737
filename = data_path(url)
3838
else:
39-
filename = data_path(DATA_FILES[data["output_mode"]])
39+
filename = data_path(OUTPUTMODE_FILE_MAP[data["output_mode"]])
40+
4041
with open(filename, 'rb') as infile:
4142
content = infile.read()
43+
4244
return MockResponse(content, **kwargs)
4345

4446

45-
def test_validation(patch_get):
47+
@pytest.fixture
48+
def patch_get_regular(request):
49+
mp = request.getfixturevalue("monkeypatch")
50+
mp.setattr(Most, '_request', get_mocked_return)
51+
return mp
52+
53+
54+
def test_validation(patch_get_regular):
4655
with pytest.raises(ValueError):
47-
Most.query()
56+
Most.query_object()
4857

4958
with pytest.raises(ValueError):
50-
Most.query(catalog="wise_allsky_4band")
59+
Most.query_object(catalog="wise_allsky_4band")
5160

5261
# make sure no funny business happens with
5362
# overwriting of default values
54-
Most.query(
63+
Most.query_object(
5564
catalog="wise_allsky_4band",
5665
obj_name="Victoria"
5766
)
58-
Most.query(
67+
Most.query_object(
5968
catalog="wise_allsky_4band",
6069
obj_name="Victoria",
61-
input_type="name_input"
70+
input_mode="name_input"
6271
)
6372

6473
with pytest.raises(ValueError):
6574
# fails because insufficient orbital parameters specified
66-
Most.query(
75+
Most.query_object(
6776
catalog="wise_allsky_4band",
6877
output_mode="Brief",
69-
input_type="manual_input",
78+
input_mode="manual_input",
7079
obj_type="Asteroid",
7180
perih_dist=1.5,
7281
eccentricity=0.5
7382
)
7483

75-
Most.query(
84+
Most.query_object(
7685
catalog="wise_allsky_4band",
7786
output_mode="Brief",
78-
input_type="manual_input",
87+
input_mode="manual_input",
7988
obj_type="Asteroid",
8089
semimajor_axis=2.68,
8190
eccentricity=0.33,
@@ -84,45 +93,45 @@ def test_validation(patch_get):
8493
with pytest.raises(ValueError):
8594
# Comets require perihel_dist keyword
8695
# instead of smimajor_axis
87-
Most.query(
96+
Most.query_object(
8897
catalog="wise_allsky_4band",
8998
output_mode="Brief",
90-
input_type="manual_input",
99+
input_mode="manual_input",
91100
obj_type="Comet",
92101
semimajor_axis=2.68,
93102
eccentricity=0.33
94103
)
95104

96105
with pytest.raises(ValueError):
97106
# object type is case sensitive
98-
Most.query(
107+
Most.query_object(
99108
catalog="wise_allsky_4band",
100109
output_mode="Brief",
101-
input_type="manual_input",
110+
input_mode="manual_input",
102111
obj_type="comet",
103112
semimajor_axis=2.68,
104113
eccentricity=0.33
105114
)
106115

107116
with pytest.raises(ValueError):
108117
# missing mpc_data and obj_type
109-
Most.query(
118+
Most.query_object(
110119
catalog="wise_allsky_4band",
111120
output_mode="Brief",
112-
input_type="mpc_input"
121+
input_mode="mpc_input"
113122
)
114123

115-
Most.query(
124+
Most.query_object(
116125
catalog="wise_allsky_4band",
117126
output_mode="Brief",
118-
input_type="mpc_input",
127+
input_mode="mpc_input",
119128
obj_type="Asteroid",
120129
mpc_data="K10N010+2010+08+16.1477+1.494525+0.533798+153.4910+113.2118+12.8762+20100621+17.0+4.0+P/2010+N1+(WISE)+MPC+75712" # noqa: E501
121130
)
122131

123132

124-
def test_regular(patch_get):
125-
response = Most.query(obj_name="Victoria")
133+
def test_regular(patch_get_regular):
134+
response = Most.query_object(obj_name="Victoria")
126135

127136
assert "results" in response
128137
assert "metadata" in response
@@ -132,19 +141,19 @@ def test_regular(patch_get):
132141

133142
results = Table.read(data_path("most_results_table.tbl"), format="ipac")
134143
metadata = Table.read(data_path("most_imgframes_matched_final_table.tbl"), format="ipac")
135-
url = "https://irsa.ipac.caltech.edu/workspace/TMP_XIBNAd_17194/MOST/pid10499/ds9region/ds9_orbit_path.reg"
144+
url = "https://irsa.ipac.caltech.edu/workspace/TMP_noPis4_23270/MOST/pid30587/ds9region/ds9_orbit_path.reg"
136145

137146
silent_stream = io.StringIO()
138147
assert report_diff_values(results, response["results"], silent_stream)
139148
assert report_diff_values(metadata, response["metadata"], silent_stream)
140149
assert url == response["region"]
141150

142151

143-
def test_get_full_with_tarballs(patch_get):
144-
response = Most.query(
152+
def test_get_full_with_tarballs(patch_get_regular):
153+
response = Most.query_object(
145154
obj_name="Victoria",
146155
output_mode="Full",
147-
fits_region_files=True
156+
with_tarballs=True
148157
)
149158

150159
assert "results" in response
@@ -155,9 +164,9 @@ def test_get_full_with_tarballs(patch_get):
155164

156165
results = Table.read(data_path("most_results_table.tbl"), format="ipac")
157166
metadata = Table.read(data_path("most_imgframes_matched_final_table.tbl"), format="ipac")
158-
url = "https://irsa.ipac.caltech.edu/workspace/TMP_XIBNAd_17194/MOST/pid10499/ds9region/ds9_orbit_path.reg"
159-
region_tar = "https://irsa.ipac.caltech.edu/workspace/TMP_XIBNAd_17194/MOST/pid10499/ds9region_A850RA.tar"
160-
fits_tar = "https://irsa.ipac.caltech.edu/workspace/TMP_XIBNAd_17194/MOST/pid10499/fitsimage_A850RA.tar.gz"
167+
url = "https://irsa.ipac.caltech.edu/workspace/TMP_noPis4_23270/MOST/pid1957/ds9region/ds9_orbit_path.reg"
168+
region_tar = "https://irsa.ipac.caltech.edu/workspace/TMP_noPis4_23270/MOST/pid1957/ds9region_A850RA.tar"
169+
fits_tar = "https://irsa.ipac.caltech.edu/workspace/TMP_noPis4_23270/MOST/pid1957/fitsimage_A850RA.tar.gz"
161170

162171
silent_stream = io.StringIO()
163172
assert report_diff_values(results, response["results"], silent_stream)
@@ -167,8 +176,8 @@ def test_get_full_with_tarballs(patch_get):
167176
assert fits_tar == response["fits_tarball"]
168177

169178

170-
def test_votable(patch_get):
171-
response = Most.query(
179+
def test_votable(patch_get_regular):
180+
response = Most.query_object(
172181
output_mode="VOTable",
173182
obj_name="Victoria"
174183
)
@@ -178,8 +187,23 @@ def test_votable(patch_get):
178187
assert report_diff_values(response, vtbl, silent_stream)
179188

180189

181-
def test_gator(patch_get):
182-
response = Most.query(
190+
def test_list_catalogs(patch_get_regular):
191+
expected = [
192+
'2mass', 'spitzer_bcd', 'ptf', 'sofia', 'wise_merge', 'wise_allsky_4band',
193+
'wise_allsky_3band', 'wise_allsky_2band', 'wise_neowiser',
194+
'wise_neowiser_yr1', 'wise_neowiser_yr2', 'wise_neowiser_yr3',
195+
'wise_neowiser_yr4', 'wise_neowiser_yr5', 'wise_neowiser_yr6',
196+
'wise_neowiser_yr7', 'wise_neowiser_yr8', 'wise_neowiser_yr9', 'ztf',
197+
'wise_merge_int', 'wise_neowiser_int', 'wise_neowiser_yr10'
198+
]
199+
200+
response = Most.list_catalogs()
201+
202+
assert response == expected
203+
204+
205+
def test_gator(patch_get_regular):
206+
response = Most.query_object(
183207
output_mode="Gator",
184208
obj_name="Victoria"
185209
)

0 commit comments

Comments
 (0)