Skip to content

Commit

Permalink
fix dataset download (3)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc2 committed May 16, 2024
1 parent 755c5ff commit 179fcad
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions benchmarks/mpas_ocean.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@

filenames = [grid_filename_480, data_filename_480, grid_filename_120, data_filename_120]

for filename in filenames:
if not os.path.isfile(current_path / filename):
# downloads the files from Cookbook repo, if they haven't been downloaded locally yet
url = f"https://github.com/ProjectPythia/unstructured-grid-viz-cookbook/raw/main/meshfiles/{filename}"
_, headers = urllib.request.urlretrieve(url, filename=current_path / filename)
def _check_file_download():
for filename in filenames:
if not os.path.isfile(current_path / filename):
# downloads the files from Cookbook repo, if they haven't been downloaded locally yet
url = f"https://github.com/ProjectPythia/unstructured-grid-viz-cookbook/raw/main/meshfiles/{filename}"
_, headers = urllib.request.urlretrieve(url, filename=current_path / filename)


file_path_dict = {"480km": [current_path / grid_filename_480, current_path / data_filename_480],
Expand All @@ -36,6 +37,7 @@ class Gradient:


def setup(self, resolution):
_check_file_download()
self.uxds = ux.open_dataset(file_path_dict[resolution][0], file_path_dict[resolution][1])

def teardown(self, resolution):
Expand All @@ -54,6 +56,7 @@ class Integrate:


def setup(self, resolution):
_check_file_download()
self.uxds = ux.open_dataset(file_path_dict[resolution][0], file_path_dict[resolution][1])

def teardown(self, resolution):
Expand All @@ -73,6 +76,7 @@ class GeoDataFrame:


def setup(self, resolution, exclude_antimeridian):
_check_file_download()
self.uxds = ux.open_dataset(file_path_dict[resolution][0], file_path_dict[resolution][1])

def teardown(self, resolution, exclude_antimeridian):
Expand All @@ -92,6 +96,7 @@ class ConnectivityConstruction:


def setup(self, resolution):
_check_file_download()
self.uxds = ux.open_dataset(file_path_dict[resolution][0], file_path_dict[resolution][1])

def teardown(self, resolution):
Expand Down

0 comments on commit 179fcad

Please sign in to comment.