4
4
import shutil
5
5
import pytest
6
6
from astroquery import log
7
-
7
+ from astroquery .utils .tap .model .taptable import TapTableMeta
8
+ from astroquery .utils .tap .model .tapcolumn import TapColumn
8
9
from astroquery .utils .commons import TableList
9
10
from astropy .io .fits .hdu .hdulist import HDUList
10
11
@@ -108,8 +109,8 @@ def test_esasky_get_spectra_obs_id(self):
108
109
missions = ["ISO-IR" , "Chandra" , "IUE" , "XMM-NEWTON" , "HST-IR" , "Herschel" , "HST-UV" , "HST-OPTICAL" ]
109
110
110
111
result = ESASkyClass .get_spectra (observation_ids = ["02101201" , "1005" , "LWR13178" , "0001730201" , "ibh706cqq" ,
111
- "1342253595" , "z1ax0102t" , "oeik2s020" ],
112
- missions = missions , download_dir = download_directory )
112
+ "1342253595" , "z1ax0102t" , "oeik2s020" ],
113
+ missions = missions , download_dir = download_directory )
113
114
114
115
for mission in missions :
115
116
file_path = os .path .join (download_directory , mission )
@@ -126,11 +127,11 @@ def test_esasky_get_spectra_obs_id(self):
126
127
shutil .rmtree (download_directory )
127
128
128
129
def test_esasky_query_region_maps (self ):
129
- result = ESASkyClass .query_region_maps ("M51" , "5 arcmin" )
130
+ result = ESASkyClass .query_region_maps (position = "M51" , radius = "5 arcmin" )
130
131
assert isinstance (result , TableList )
131
132
132
133
def test_esasky_query_object_maps (self ):
133
- result = ESASkyClass .query_object_maps ("M51" )
134
+ result = ESASkyClass .query_object_maps (position = "M51" )
134
135
assert isinstance (result , TableList )
135
136
136
137
@pytest .mark .bigdata
@@ -145,7 +146,7 @@ def test_esasky_get_images(self):
145
146
missions = [mission for mission in missions if mission not in
146
147
("HST-OPTICAL" , "HST-IR" , "HST-UV" , "XMM-OM-UV" , "INTEGRAL" , "SUZAKU" , "ALMA" , "AKARI" )]
147
148
148
- ESASkyClass .get_images ("M51" , missions = missions , download_dir = download_directory )
149
+ ESASkyClass .get_images (position = "M51" , missions = missions , download_dir = download_directory )
149
150
150
151
for mission in missions :
151
152
file_path = os .path .join (download_directory , mission )
@@ -161,7 +162,7 @@ def test_esasky_get_images_small(self):
161
162
# ISO is only ~ 163 kB
162
163
missions = ['ISO-IR' ]
163
164
164
- ESASkyClass .get_images ("M6" , radius = "12arcmin" , missions = missions , download_dir = download_directory )
165
+ ESASkyClass .get_images (position = "M6" , radius = "12arcmin" , missions = missions , download_dir = download_directory )
165
166
166
167
for mission in missions :
167
168
file_path = os .path .join (download_directory , mission )
@@ -175,19 +176,19 @@ def test_esasky_get_images_hst(self):
175
176
if not os .path .exists (download_directory ):
176
177
os .makedirs (download_directory )
177
178
178
- ESASkyClass .get_images ("M11" , radius = "2.1 deg" , missions = "HST-UV" , download_dir = download_directory )
179
+ ESASkyClass .get_images (position = "M11" , radius = "2.1 deg" , missions = "HST-UV" , download_dir = download_directory )
179
180
180
181
file_path = os .path .join (download_directory , "HST-UV" )
181
182
assert os .path .exists (file_path )
182
183
183
184
shutil .rmtree (download_directory )
184
185
185
186
def test_esasky_query_region_catalogs (self ):
186
- result = ESASkyClass .query_region_catalogs ("M51" , "5 arcmin" )
187
+ result = ESASkyClass .query_region_catalogs (position = "M51" , radius = "5 arcmin" )
187
188
assert isinstance (result , TableList )
188
189
189
190
def test_esasky_query_object_catalogs (self ):
190
- result = ESASkyClass .query_object_catalogs ("M51" )
191
+ result = ESASkyClass .query_object_catalogs (position = "M51" )
191
192
assert isinstance (result , TableList )
192
193
193
194
def test_esasky_get_maps (self ):
@@ -197,8 +198,8 @@ def test_esasky_get_maps(self):
197
198
198
199
file_path = os .path .join (download_directory , 'ISO-IR' )
199
200
200
- all_maps = ESASkyClass .query_object_maps ("M51" )
201
- iso_maps = ESASkyClass .query_object_maps ("M51" , missions = 'ISO-IR' )
201
+ all_maps = ESASkyClass .query_object_maps (position = "M51" )
202
+ iso_maps = ESASkyClass .query_object_maps (position = "M51" , missions = 'ISO-IR' )
202
203
# Remove a few maps, so the other list will have downloadable ones, too
203
204
iso_maps ['ISO-IR' ].remove_rows ([0 , 1 ])
204
205
ESASkyClass .get_maps (iso_maps , download_dir = download_directory )
@@ -211,11 +212,11 @@ def test_esasky_get_maps(self):
211
212
shutil .rmtree (download_directory )
212
213
213
214
def test_esasky_query_region_spectra (self ):
214
- result = ESASkyClass .query_region_spectra ("M51" , "5 arcmin" )
215
+ result = ESASkyClass .query_region_spectra (position = "M51" , radius = "5 arcmin" )
215
216
assert isinstance (result , TableList )
216
217
217
218
def test_esasky_query_object_spectra (self ):
218
- result = ESASkyClass .query_object_spectra ("M51" )
219
+ result = ESASkyClass .query_object_spectra (position = "M51" )
219
220
assert isinstance (result , TableList )
220
221
221
222
@pytest .mark .bigdata
@@ -242,7 +243,7 @@ def test_esasky_get_spectra_small(self):
242
243
243
244
missions = ['HST-IR' ]
244
245
245
- ESASkyClass .get_spectra ("M1" , radius = "9arcmin" , missions = missions , download_dir = download_directory )
246
+ ESASkyClass .get_spectra (position = "M1" , radius = "9arcmin" , missions = missions , download_dir = download_directory )
246
247
247
248
for mission in missions :
248
249
file_path = os .path .join (download_directory , mission )
@@ -257,15 +258,34 @@ def test_esasky_get_spectra_from_table(self):
257
258
258
259
file_path = os .path .join (download_directory , 'ISO-IR' )
259
260
260
- all_spectra = ESASkyClass .query_object_spectra ("M51" )
261
- iso_spectra = ESASkyClass .query_object_spectra ("M51" , missions = 'ISO-IR' )
261
+ all_spectra = ESASkyClass .query_object_spectra (position = "M51" )
262
+ iso_spectra = ESASkyClass .query_object_spectra (position = "M51" , missions = 'ISO-IR' )
262
263
# Remove a few maps, so the other list will have downloadable ones, too
263
264
iso_spectra ['ISO-IR' ].remove_rows ([0 , 1 ])
264
- ESASkyClass .get_spectra_from_table (iso_spectra , download_dir = download_directory )
265
+ ESASkyClass .get_spectra_from_table (query_table_list = iso_spectra , download_dir = download_directory )
265
266
assert len (os .listdir (file_path )) == len (all_spectra ['ISO-IR' ]) - 2
266
267
267
268
iso_spectra2 = dict ({'ISO-IR' : all_spectra ['ISO-IR' ][:2 ]})
268
- ESASkyClass .get_spectra_from_table (iso_spectra2 , download_dir = download_directory )
269
+ ESASkyClass .get_spectra_from_table (query_table_list = iso_spectra2 , download_dir = download_directory )
269
270
assert len (os .listdir (file_path )) == len (all_spectra ['ISO-IR' ])
270
271
271
272
shutil .rmtree (download_directory )
273
+
274
+ def test_query (self ):
275
+ result = ESASkyClass .query (query = "SELECT * from observations.mv_v_esasky_xmm_om_uv_fdw" )
276
+ assert len (result ) == 2000 # Default row limit is 2000
277
+
278
+ def test_get_tables (self ):
279
+ table_names = ESASkyClass .get_tables (only_names = True )
280
+ assert len (table_names ) > 70
281
+ tables = ESASkyClass .get_tables (only_names = False )
282
+ assert isinstance (tables [0 ], TapTableMeta )
283
+ assert len (table_names ) == len (tables )
284
+
285
+ def test_get_columns (self ):
286
+ column_names = ESASkyClass .get_columns (table_name = 'observations.mv_v_esasky_xmm_om_uv_fdw' , only_names = True )
287
+ assert len (column_names ) == 17
288
+
289
+ columns = ESASkyClass .get_columns (table_name = 'observations.mv_v_esasky_xmm_om_uv_fdw' , only_names = False )
290
+ assert isinstance (columns [0 ], TapColumn )
291
+ assert len (column_names ) == len (columns )
0 commit comments