Skip to content

Commit

Permalink
catch error with downloading datasets in Quest; template test case fo…
Browse files Browse the repository at this point in the history
…r multi dataset query
  • Loading branch information
RomiP committed Sep 25, 2023
1 parent cc6da09 commit 0de8716
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 29 deletions.
41 changes: 12 additions & 29 deletions icepyx/quest/quest.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,18 @@ def search_all(self):

for i in self.datasets.values():
print()
if isinstance(i, Query):
print("---ICESat-2---")
msg = i.avail_granules()
print(msg)
else:
print(i)
i.search_data()
try:
# querying ICESat-2 data
if isinstance(i, Query):
print("---ICESat-2---")
msg = i.avail_granules()
print(msg)
else: # querying all other data sets
print(i)
i.search_data()
except:
dataset_name = type(i).__name__
print("Error querying data from {0}".format(dataset_name))

# error handling? what happens when one of i fails...
def download_all(self, path=""):
Expand All @@ -155,25 +160,3 @@ def download_all(self, path=""):
print(i)

# DEVNOTE: see colocated data branch and phyto team files for code that expands quest functionality


# Todo: remove this later -- just here for debugging
if __name__ == "__main__":
bounding_box = [-150, 30, -120, 60]
date_range = ["2022-06-07", "2022-06-14"]
my_quest = Quest(spatial_extent=bounding_box, date_range=date_range)
# print(my_quest.spatial)
# print(my_quest.temporal)

# my_quest.add_argo(params=["down_irradiance412", "temperature"])
# print(my_quest.datasets["argo"].params)

my_quest.add_icesat2(product="ATL06")
# print(my_quest.datasets["icesat2"].product)

print(my_quest)

my_quest.search_all()

# this one still needs work for IS2 because of auth...
my_quest.download_all()
20 changes: 20 additions & 0 deletions icepyx/tests/test_quest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,26 @@ def test_add_is2(quest_instance):
# assert type(obs[exp_key]) == exp_type
# assert quest_instance.datasets[exp_key].params == params

# def test_add_multiple_datasets():
# bounding_box = [-150, 30, -120, 60]
# date_range = ["2022-06-07", "2022-06-14"]
# my_quest = Quest(spatial_extent=bounding_box, date_range=date_range)
#
# # print(my_quest.spatial)
# # print(my_quest.temporal)
#
# # my_quest.add_argo(params=["down_irradiance412", "temperature"])
# # print(my_quest.datasets["argo"].params)
#
# my_quest.add_icesat2(product="ATL06")
# # print(my_quest.datasets["icesat2"].product)
#
# print(my_quest)
#
# # my_quest.search_all()
# #
# # # this one still needs work for IS2 because of auth...
# # my_quest.download_all()

########## ALL DATASET METHODS TESTS ##########

Expand Down

0 comments on commit 0de8716

Please sign in to comment.