Skip to content

Commit 8b0dbd5

Browse files
Clara Brasseurjaymedina
authored andcommitted
adding moving tesscut tests
1 parent fd2a9cc commit 8b0dbd5

File tree

2 files changed

+99
-9
lines changed

2 files changed

+99
-9
lines changed

astroquery/mast/tests/test_mast.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,15 @@ def test_tesscut_get_sector(patch_post):
589589
assert sector_table['camera'][0] == 1
590590
assert sector_table['ccd'][0] == 3
591591

592+
# Exercising the search by moving target
593+
sector_table = mast.Tesscut.get_sectors(moving_target="Ceres")
594+
assert isinstance(sector_table, Table)
595+
assert len(sector_table) == 1
596+
assert sector_table['sectorName'][0] == "tess-s0001-1-3"
597+
assert sector_table['sector'][0] == 1
598+
assert sector_table['camera'][0] == 1
599+
assert sector_table['ccd'][0] == 3
600+
592601

593602
def test_tesscut_download_cutouts(patch_post, tmpdir):
594603

@@ -616,6 +625,13 @@ def test_tesscut_download_cutouts(patch_post, tmpdir):
616625
assert manifest["Local Path"][0][-4:] == "fits"
617626
assert os.path.isfile(manifest[0]['Local Path'])
618627

628+
# Exercising the search by moving target
629+
manifest = mast.Tesscut.download_cutouts(moving_target="Eleonora", size=5, path=str(tmpdir))
630+
assert isinstance(manifest, Table)
631+
assert len(manifest) == 1
632+
assert manifest["Local Path"][0][-4:] == "fits"
633+
assert os.path.isfile(manifest[0]['Local Path'])
634+
619635

620636
def test_tesscut_get_cutouts(patch_post, tmpdir):
621637

@@ -631,6 +647,13 @@ def test_tesscut_get_cutouts(patch_post, tmpdir):
631647
assert len(cutout_hdus_list) == 1
632648
assert isinstance(cutout_hdus_list[0], fits.HDUList)
633649

650+
# Exercising the search by object name
651+
cutout_hdus_list = mast.Tesscut.get_cutouts(moving_target="Eleonora", size=5)
652+
assert isinstance(cutout_hdus_list, list)
653+
assert len(cutout_hdus_list) == 1
654+
assert isinstance(cutout_hdus_list[0], fits.HDUList)
655+
656+
634657
######################
635658
# ZcutClass tests #
636659
######################

astroquery/mast/tests/test_mast_remote.py

Lines changed: 76 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
from astroquery.exceptions import NoResultsWarning
1515
from astroquery import mast
1616

17+
from ...exceptions import RemoteServiceError, MaxResultsWarning
18+
1719

1820
OBSID = '1647157'
1921

@@ -195,10 +197,13 @@ def test_observations_query_criteria_count(self):
195197

196198
# product functions
197199
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"])
199204
assert isinstance(responses, list)
200205

201-
responses = mast.Observations.get_product_list_async('2003738726,3000007760')
206+
responses = mast.Observations.get_product_list_async(test_obs[2:3])
202207
assert isinstance(responses, list)
203208

204209
observations = mast.Observations.query_object("M8", radius=".02 deg")
@@ -242,8 +247,12 @@ def test_observations_get_product_list(self):
242247
result = mast.Observations.get_product_list(observations[obsLocs])
243248
obs_collection = np.unique(list(result['obs_collection']))
244249
assert isinstance(result, Table)
250+
<<<<<<< HEAD
245251
assert len(obs_collection) == 1
246252
assert obs_collection[0] == 'IUE'
253+
=======
254+
assert len(result) > 10
255+
>>>>>>> adding moving tesscut tests
247256

248257
def test_observations_filter_products(self):
249258
observations = mast.Observations.query_object("M8", radius=".04 deg")
@@ -269,7 +278,7 @@ def test_observations_download_products(self, tmpdir):
269278
assert os.path.isfile(row['Local Path'])
270279

271280
# just get the curl script
272-
result = mast.Observations.download_products(test_obs_id,
281+
result = mast.Observations.download_products(test_obs[0]["obsid"],
273282
download_dir=str(tmpdir),
274283
curl_flag=True,
275284
productType=["SCIENCE"],
@@ -278,17 +287,18 @@ def test_observations_download_products(self, tmpdir):
278287
assert os.path.isfile(result['Local Path'][0])
279288

280289
# 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"])
282291
result2 = mast.Observations.download_products(result1[0])
283292
assert isinstance(result2, Table)
284293
assert os.path.isfile(result2['Local Path'][0])
285294
assert len(result2) == 1
286295

287296
def test_observations_download_file(self, tmpdir):
288297
test_obs_id = OBSID
298+
test_obs = mast.Observations.query_criteria(filters=["NUV","FUV"],objectname="M101")
289299

290300
# 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"])
292302
uri = products['dataURI'][0]
293303

294304
# download it
@@ -364,6 +374,10 @@ def test_catalogs_query_region(self):
364374
catalog="HSC",
365375
magtype=2)
366376
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+
367381
assert isinstance(result, Table)
368382
assert result[row]['NumImages'] == 1
369383
assert result[row]['TargetName'] == 'M15'
@@ -374,6 +388,10 @@ def test_catalogs_query_region(self):
374388
version=2,
375389
magtype=2)
376390
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)
377395
assert isinstance(result, Table)
378396
assert result[row]['NumImages'] == 11
379397
assert result[row]['TargetName'] == 'NGC7078'
@@ -666,13 +684,20 @@ def test_tesscut_get_sectors(self):
666684
assert sector_table['ccd'][0] > 0
667685

668686
# This should always return no results
687+
669688
with pytest.warns(NoResultsWarning):
670689
coord = SkyCoord(90, -66.5, unit="deg")
671690
sector_table = mast.Tesscut.get_sectors(coordinates=coord,
672691
radius=0)
673692
assert isinstance(sector_table, Table)
674693
assert len(sector_table) == 0
675694

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+
676701
sector_table = mast.Tesscut.get_sectors(objectname="M104")
677702
assert isinstance(sector_table, Table)
678703
assert len(sector_table) >= 1
@@ -681,6 +706,15 @@ def test_tesscut_get_sectors(self):
681706
assert sector_table['camera'][0] > 0
682707
assert sector_table['ccd'][0] > 0
683708

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+
684718
def test_tesscut_download_cutouts(self, tmpdir):
685719

686720
coord = SkyCoord(349.62609, -47.12424, unit="deg")
@@ -720,6 +754,14 @@ def test_tesscut_download_cutouts(self, tmpdir):
720754
for row in manifest:
721755
assert os.path.isfile(row['Local Path'])
722756

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+
723765
def test_tesscut_get_cutouts(self, tmpdir):
724766

725767
coord = SkyCoord(107.18696, -70.50919, unit="deg")
@@ -746,9 +788,15 @@ def test_tesscut_get_cutouts(self, tmpdir):
746788
assert len(cutout_hdus_list) >= 1
747789
assert isinstance(cutout_hdus_list[0], fits.HDUList)
748790

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+
###################
750798
# ZcutClass tests #
751-
######################
799+
###################
752800
def test_zcut_get_surveys(self):
753801

754802
coord = SkyCoord(189.49206, 62.20615, unit="deg")
@@ -766,6 +814,12 @@ def test_zcut_get_surveys(self):
766814
assert isinstance(survey_list, list)
767815
assert len(survey_list) == 0
768816

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+
769823
def test_zcut_download_cutouts(self, tmpdir):
770824

771825
coord = SkyCoord(34.47320, -5.24271, unit="deg")
@@ -777,7 +831,7 @@ def test_zcut_download_cutouts(self, tmpdir):
777831
for row in cutout_table:
778832
assert os.path.isfile(cutout_table[0]['Local Path'])
779833

780-
coord = SkyCoord(189.49206, 62.20615, unit="deg")
834+
coord = SkyCoord(189.28065571, 62.17415175, unit="deg")
781835

782836
cutout_table = mast.Zcut.download_cutouts(coordinates=coord, size=[200, 300], path=str(tmpdir))
783837
assert isinstance(cutout_table, Table)
@@ -809,6 +863,13 @@ def test_zcut_download_cutouts(self, tmpdir):
809863
assert isinstance(cutout_table, Table)
810864
assert len(cutout_table) == 0
811865

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+
812873
cutout_table = mast.Zcut.download_cutouts(coordinates=coord, cutout_format="jpg", path=str(tmpdir), stretch='asinh', invert=True)
813874
assert isinstance(cutout_table, Table)
814875
assert len(cutout_table) >= 1
@@ -818,7 +879,7 @@ def test_zcut_download_cutouts(self, tmpdir):
818879

819880
def test_zcut_get_cutouts(self):
820881

821-
coord = SkyCoord(189.49206, 62.20615, unit="deg")
882+
coord = SkyCoord(189.28065571, 62.17415175, unit="deg")
822883

823884
cutout_list = mast.Zcut.get_cutouts(coordinates=coord)
824885
assert isinstance(cutout_list, list)
@@ -836,3 +897,9 @@ def test_zcut_get_cutouts(self):
836897
survey='candels_gn_30mas')
837898
assert isinstance(cutout_list, list)
838899
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

Comments
 (0)