Skip to content

Commit ac6461e

Browse files
authored
Merge pull request #790 from keflavich/alma_test_updates
Continued fixes to ALMA remote tests
2 parents a5da0d0 + f94a3fc commit ac6461e

File tree

4 files changed

+46
-27
lines changed

4 files changed

+46
-27
lines changed

astroquery/alma/core.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,10 @@ def stage_data(self, uids):
240240
log.debug("First response URL: {0}".format(response.url))
241241
if response.status_code == 405:
242242
if hasattr(self,'_last_successful_staging_log'):
243-
log.warn("Error 405 received. If you have previously staged "
244-
"the same UIDs, the result returned is probably "
245-
"correct, otherwise you may need to create a fresh "
246-
"astroquery.Alma instance.")
243+
log.warning("Error 405 received. If you have previously staged "
244+
"the same UIDs, the result returned is probably "
245+
"correct, otherwise you may need to create a fresh "
246+
"astroquery.Alma instance.")
247247
return self._last_successful_staging_log['result']
248248
else:
249249
raise HTTPError("Received an error 405: this may indicate you "

astroquery/alma/tests/test_alma_remote.py

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111

1212
from .. import Alma
1313

14-
all_colnames = ['Project code', 'Source name', 'RA', 'Dec', 'Band',
14+
all_colnames = {'Project code', 'Source name', 'RA', 'Dec', 'Band',
1515
'Frequency resolution', 'Integration', 'Release date',
1616
'Frequency support', 'Velocity resolution', 'Pol products',
1717
'Observation date', 'PI name', 'PWV', 'Member ous id',
1818
'Asdm uid', 'Project title', 'Project type', 'Scan intent',
19-
'Spatial resolution', 'Largest angular scale', 'QA0 Status',
20-
'QA2 Status', 'Project abstract']
19+
'Spatial resolution', 'Largest angular scale',
20+
'QA2 Status', 'Group ous id', 'Pub'}
2121

2222

2323
@remote_data
@@ -59,7 +59,7 @@ def test_SgrAstar(self, temp_dir):
5959
result_c = alma.query_region(c, 1 * u.deg)
6060
assert b'2011.0.00217.S' in result_c['Project code']
6161

62-
def test_m83(self, temp_dir):
62+
def test_m83(self, temp_dir, recwarn):
6363
alma = Alma()
6464
alma.cache_location = temp_dir
6565

@@ -72,14 +72,21 @@ def test_m83(self, temp_dir):
7272
assert len(link_list) >= 47
7373

7474
# test re-staging
75-
with pytest.raises(requests.HTTPError) as ex:
76-
link_list = alma.stage_data(uids)
77-
assert ex.value.args[0] == ('Received an error 405: this may indicate you have '
78-
'already staged the data. Try downloading the '
79-
'file URLs directly with download_files.')
80-
81-
82-
def test_stage_data(self, temp_dir):
75+
# (has been replaced with warning)
76+
#with pytest.raises(requests.HTTPError) as ex:
77+
# link_list = alma.stage_data(uids)
78+
#assert ex.value.args[0] == ('Received an error 405: this may indicate you have '
79+
# 'already staged the data. Try downloading the '
80+
# 'file URLs directly with download_files.')
81+
82+
# log.warning doesn't actually make a warning
83+
#link_list = alma.stage_data(uids)
84+
#w = recwarn.pop()
85+
#assert (str(w.message) == ('Error 405 received. If you have previously staged the '
86+
# 'same UIDs, the result returned is probably correct,'
87+
# ' otherwise you may need to create a fresh astroquery.Alma instance.'))
88+
89+
def test_stage_data(self, temp_dir, recwarn):
8390
alma = Alma()
8491
alma.cache_location = temp_dir
8592

@@ -100,11 +107,18 @@ def test_stage_data(self, temp_dir):
100107
os.path.split(result['URL'][0])[1])
101108

102109
# test re-staging
103-
with pytest.raises(requests.HTTPError) as ex:
104-
result = alma.stage_data([uid])
105-
assert ex.value.args[0] == ('Received an error 405: this may indicate you have '
106-
'already staged the data. Try downloading the '
107-
'file URLs directly with download_files.')
110+
#with pytest.raises(requests.HTTPError) as ex:
111+
# result = alma.stage_data([uid])
112+
#assert ex.value.args[0] == ('Received an error 405: this may indicate you have '
113+
# 'already staged the data. Try downloading the '
114+
# 'file URLs directly with download_files.')
115+
116+
# log.warning doesn't actually make a warning
117+
#result = alma.stage_data([uid])
118+
#w = recwarn.pop()
119+
#assert (str(w.message) == ('Error 405 received. If you have previously staged the '
120+
# 'same UIDs, the result returned is probably correct,'
121+
# ' otherwise you may need to create a fresh astroquery.Alma instance.'))
108122

109123

110124
def test_doc_example(self, temp_dir):
@@ -172,7 +186,7 @@ def test_cycle1(self, temp_dir):
172186
# A 2-row table may not be OK any more, but that's what it used to
173187
# be...
174188
assert len(uid_url_table_asdm) == 1
175-
assert len(uid_url_table_mous) == 2
189+
assert len(uid_url_table_mous) >= 2 # now is len=3 (Nov 17, 2016)
176190

177191
# URL should look like:
178192
# https://almascience.eso.org/dataPortal/requests/anonymous/944120962/ALMA/2012.1.00912.S_uid___A002_X5a9a13_X528_001_of_001.tar/2012.1.00912.S_uid___A002_X5a9a13_X528_001_of_001.tar

astroquery/alma/tests/test_alma_utils.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ def test_make_finder_chart():
7070
'Eta Carinae')
7171
image, catalog, hit_mask_public, hit_mask_private = result
7272

73-
assert len(catalog) >= 7
74-
assert 3 in hit_mask_public
73+
assert len(catalog) >= 6 # down to 6 on Nov 17, 2016
74+
assert 3 in [int(x) for x in hit_mask_public]
7575
# Feb 8 2016: apparently the 60s integration hasn't actually been released yet...
76-
assert hit_mask_public[3][256,256] >= 30.23
76+
if 3 in hit_mask_public:
77+
assert hit_mask_public[3][256,256] >= 30.23
78+
elif b'3' in hit_mask_public:
79+
assert hit_mask_public[b'3'][256,256] >= 30.23
80+
else:
81+
raise ValueError("hit_mask keys are not of any known type")

astroquery/alma/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,13 +441,13 @@ def make_finder_chart_from_image_and_catalog(image, catalog, save_prefix,
441441
fig.show_contour(fits.PrimaryHDU(data=hit_mask_public[band],
442442
header=image.header),
443443
levels=integration_time_contour_levels,
444-
colors=[band_colors_pub[band]] * len(integration_time_contour_levels),
444+
colors=[band_colors_pub[int(band)]] * len(integration_time_contour_levels),
445445
convention='calabretta')
446446
if band in hit_mask_private:
447447
fig.show_contour(fits.PrimaryHDU(data=hit_mask_private[band],
448448
header=image.header),
449449
levels=integration_time_contour_levels,
450-
colors=[band_colors_priv[band]] * len(integration_time_contour_levels),
450+
colors=[band_colors_priv[int(band)]] * len(integration_time_contour_levels),
451451
convention='calabretta')
452452

453453
fig.save('{0}_almafinderchart.png'.format(save_prefix))

0 commit comments

Comments
 (0)