14
14
from astroquery .exceptions import NoResultsWarning
15
15
from astroquery import mast
16
16
17
+ from ...exceptions import RemoteServiceError , MaxResultsWarning
18
+
17
19
18
20
OBSID = '1647157'
19
21
@@ -195,10 +197,13 @@ def test_observations_query_criteria_count(self):
195
197
196
198
# product functions
197
199
def test_observations_get_product_list_async (self ):
198
- responses = mast .Observations .get_product_list_async ('2003738726' )
200
+
201
+ test_obs = mast .Observations .query_criteria (filters = ["NUV" ,"FUV" ],objectname = "M101" )
202
+
203
+ responses = mast .Observations .get_product_list_async (test_obs [0 ]["obsid" ])
199
204
assert isinstance (responses , list )
200
205
201
- responses = mast .Observations .get_product_list_async ('2003738726,3000007760' )
206
+ responses = mast .Observations .get_product_list_async (test_obs [ 2 : 3 ] )
202
207
assert isinstance (responses , list )
203
208
204
209
observations = mast .Observations .query_object ("M8" , radius = ".02 deg" )
@@ -242,8 +247,12 @@ def test_observations_get_product_list(self):
242
247
result = mast .Observations .get_product_list (observations [obsLocs ])
243
248
obs_collection = np .unique (list (result ['obs_collection' ]))
244
249
assert isinstance (result , Table )
250
+ < << << << HEAD
245
251
assert len (obs_collection ) == 1
246
252
assert obs_collection [0 ] == 'IUE'
253
+ == == == =
254
+ assert len (result ) > 10
255
+ >> >> >> > adding moving tesscut tests
247
256
248
257
def test_observations_filter_products (self ):
249
258
observations = mast .Observations .query_object ("M8" , radius = ".04 deg" )
@@ -269,7 +278,7 @@ def test_observations_download_products(self, tmpdir):
269
278
assert os .path .isfile (row ['Local Path' ])
270
279
271
280
# just get the curl script
272
- result = mast .Observations .download_products (test_obs_id ,
281
+ result = mast .Observations .download_products (test_obs [ 0 ][ "obsid" ] ,
273
282
download_dir = str (tmpdir ),
274
283
curl_flag = True ,
275
284
productType = ["SCIENCE" ],
@@ -278,17 +287,18 @@ def test_observations_download_products(self, tmpdir):
278
287
assert os .path .isfile (result ['Local Path' ][0 ])
279
288
280
289
# check for row input
281
- result1 = mast .Observations .get_product_list (test_obs_id )
290
+ result1 = mast .Observations .get_product_list (test_obs [ 0 ][ "obsid" ] )
282
291
result2 = mast .Observations .download_products (result1 [0 ])
283
292
assert isinstance (result2 , Table )
284
293
assert os .path .isfile (result2 ['Local Path' ][0 ])
285
294
assert len (result2 ) == 1
286
295
287
296
def test_observations_download_file (self , tmpdir ):
288
297
test_obs_id = OBSID
298
+ test_obs = mast .Observations .query_criteria (filters = ["NUV" ,"FUV" ],objectname = "M101" )
289
299
290
300
# pull a single data product
291
- products = mast .Observations .get_product_list (test_obs_id )
301
+ products = mast .Observations .get_product_list (test_obs [ 0 ][ "obsid" ] )
292
302
uri = products ['dataURI' ][0 ]
293
303
294
304
# download it
@@ -364,6 +374,10 @@ def test_catalogs_query_region(self):
364
374
catalog = "HSC" ,
365
375
magtype = 2 )
366
376
row = np .where (result ['MatchID' ] == '78095437' )
377
+
378
+ with pytest .warns (MaxResultsWarning ):
379
+ result = mast .Catalogs .query_region ("322.49324 12.16683" , catalog = "HSC" , magtype = 2 )
380
+
367
381
assert isinstance (result , Table )
368
382
assert result [row ]['NumImages' ] == 1
369
383
assert result [row ]['TargetName' ] == 'M15'
@@ -374,6 +388,10 @@ def test_catalogs_query_region(self):
374
388
version = 2 ,
375
389
magtype = 2 )
376
390
row = np .where (result ['MatchID' ] == '82368728' )
391
+
392
+ with pytest .warns (MaxResultsWarning ):
393
+ result = mast .Catalogs .query_region ("322.49324 12.16683" , catalog = "HSC" ,
394
+ version = 2 , magtype = 2 )
377
395
assert isinstance (result , Table )
378
396
assert result [row ]['NumImages' ] == 11
379
397
assert result [row ]['TargetName' ] == 'NGC7078'
@@ -666,13 +684,20 @@ def test_tesscut_get_sectors(self):
666
684
assert sector_table ['ccd' ][0 ] > 0
667
685
668
686
# This should always return no results
687
+
669
688
with pytest .warns (NoResultsWarning ):
670
689
coord = SkyCoord (90 , - 66.5 , unit = "deg" )
671
690
sector_table = mast .Tesscut .get_sectors (coordinates = coord ,
672
691
radius = 0 )
673
692
assert isinstance (sector_table , Table )
674
693
assert len (sector_table ) == 0
675
694
695
+ coord = SkyCoord (90 , - 66.5 , unit = "deg" )
696
+ with pytest .warns (NoResultsWarning ):
697
+ sector_table = mast .Tesscut .get_sectors (coordinates = coord , radius = 0 )
698
+ assert isinstance (sector_table , Table )
699
+ assert len (sector_table ) == 0
700
+
676
701
sector_table = mast .Tesscut .get_sectors (objectname = "M104" )
677
702
assert isinstance (sector_table , Table )
678
703
assert len (sector_table ) >= 1
@@ -681,6 +706,15 @@ def test_tesscut_get_sectors(self):
681
706
assert sector_table ['camera' ][0 ] > 0
682
707
assert sector_table ['ccd' ][0 ] > 0
683
708
709
+ sector_table = mast .Tesscut .get_sectors (moving_target = "Stichius" )
710
+ assert isinstance (sector_table , Table )
711
+ assert len (sector_table ) >= 1
712
+ assert sector_table ['sectorName' ][0 ] == "tess-s0001-1-1"
713
+ assert sector_table ['sector' ][0 ] == 1
714
+ assert sector_table ['camera' ][0 ] == 1
715
+ assert sector_table ['ccd' ][0 ] == 1
716
+
717
+
684
718
def test_tesscut_download_cutouts (self , tmpdir ):
685
719
686
720
coord = SkyCoord (349.62609 , - 47.12424 , unit = "deg" )
@@ -720,6 +754,14 @@ def test_tesscut_download_cutouts(self, tmpdir):
720
754
for row in manifest :
721
755
assert os .path .isfile (row ['Local Path' ])
722
756
757
+ manifest = mast .Tesscut .download_cutouts (moving_target = "Eleonora" , sector = 6 , size = 5 , path = str (tmpdir ))
758
+ assert isinstance (manifest , Table )
759
+ assert len (manifest ) == 1
760
+ assert manifest ["Local Path" ][0 ][- 4 :] == "fits"
761
+ for row in manifest :
762
+ assert os .path .isfile (row ['Local Path' ])
763
+
764
+
723
765
def test_tesscut_get_cutouts (self , tmpdir ):
724
766
725
767
coord = SkyCoord (107.18696 , - 70.50919 , unit = "deg" )
@@ -746,9 +788,15 @@ def test_tesscut_get_cutouts(self, tmpdir):
746
788
assert len (cutout_hdus_list ) >= 1
747
789
assert isinstance (cutout_hdus_list [0 ], fits .HDUList )
748
790
749
- ######################
791
+ cutout_hdus_list = mast .Tesscut .get_cutouts (moving_target = "Eleonora" , sector = 6 , size = 5 )
792
+ assert isinstance (cutout_hdus_list , list )
793
+ assert len (cutout_hdus_list ) == 1
794
+ assert isinstance (cutout_hdus_list [0 ], fits .HDUList )
795
+
796
+
797
+ ###################
750
798
# ZcutClass tests #
751
- ######################
799
+ ###################
752
800
def test_zcut_get_surveys (self ):
753
801
754
802
coord = SkyCoord (189.49206 , 62.20615 , unit = "deg" )
@@ -766,6 +814,12 @@ def test_zcut_get_surveys(self):
766
814
assert isinstance (survey_list , list )
767
815
assert len (survey_list ) == 0
768
816
817
+ coord = SkyCoord (57.10523 , - 30.08085 , unit = "deg" )
818
+ with pytest .warns (NoResultsWarning ):
819
+ survey_list = mast .Zcut .get_surveys (coordinates = coord , radius = 0 )
820
+ assert isinstance (survey_list , list )
821
+ assert len (survey_list ) == 0
822
+
769
823
def test_zcut_download_cutouts (self , tmpdir ):
770
824
771
825
coord = SkyCoord (34.47320 , - 5.24271 , unit = "deg" )
@@ -777,7 +831,7 @@ def test_zcut_download_cutouts(self, tmpdir):
777
831
for row in cutout_table :
778
832
assert os .path .isfile (cutout_table [0 ]['Local Path' ])
779
833
780
- coord = SkyCoord (189.49206 , 62.20615 , unit = "deg" )
834
+ coord = SkyCoord (189.28065571 , 62.17415175 , unit = "deg" )
781
835
782
836
cutout_table = mast .Zcut .download_cutouts (coordinates = coord , size = [200 , 300 ], path = str (tmpdir ))
783
837
assert isinstance (cutout_table , Table )
@@ -809,6 +863,13 @@ def test_zcut_download_cutouts(self, tmpdir):
809
863
assert isinstance (cutout_table , Table )
810
864
assert len (cutout_table ) == 0
811
865
866
+ cutout_table = mast .Zcut .download_cutouts (coordinates = coord , survey = 'goods_north' , cutout_format = "jpg" , path = str (tmpdir ))
867
+ assert isinstance (cutout_table , Table )
868
+ assert len (cutout_table ) == 4
869
+ assert cutout_table ["Local Path" ][0 ][- 4 :] == ".jpg"
870
+ for row in cutout_table :
871
+ assert os .path .isfile (cutout_table [0 ]['Local Path' ])
872
+
812
873
cutout_table = mast .Zcut .download_cutouts (coordinates = coord , cutout_format = "jpg" , path = str (tmpdir ), stretch = 'asinh' , invert = True )
813
874
assert isinstance (cutout_table , Table )
814
875
assert len (cutout_table ) >= 1
@@ -818,7 +879,7 @@ def test_zcut_download_cutouts(self, tmpdir):
818
879
819
880
def test_zcut_get_cutouts (self ):
820
881
821
- coord = SkyCoord (189.49206 , 62.20615 , unit = "deg" )
882
+ coord = SkyCoord (189.28065571 , 62.17415175 , unit = "deg" )
822
883
823
884
cutout_list = mast .Zcut .get_cutouts (coordinates = coord )
824
885
assert isinstance (cutout_list , list )
@@ -836,3 +897,9 @@ def test_zcut_get_cutouts(self):
836
897
survey = 'candels_gn_30mas' )
837
898
assert isinstance (cutout_list , list )
838
899
assert len (cutout_list ) == 0
900
+
901
+ cutout_list = mast .Zcut .get_cutouts (coordinates = coord , survey = '3dhst_goods-n' )
902
+ assert isinstance (cutout_list , list )
903
+ assert len (cutout_list ) == 1
904
+ assert isinstance (cutout_list [0 ], fits .HDUList )
905
+
0 commit comments