Skip to content

Commit

Permalink
fix dataset download (4)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc2 committed May 16, 2024
1 parent 179fcad commit d2f4b99
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions benchmarks/mpas_ocean.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
data_filename_120 = "oQU120.data.nc"

filenames = [grid_filename_480, data_filename_480, grid_filename_120, data_filename_120]
local_filenames = []
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}"
local_filename, headers = urllib.request.urlretrieve(url)
local_filenames.append(local_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],
"120km": [current_path / grid_filename_120, current_path / data_filename_120]}
file_path_dict = {"480km": [local_filenames[0], local_filenames[1]],
"120km": [local_filenames[2], local_filenames[3]]}


class Gradient:
Expand All @@ -37,7 +37,6 @@ 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 @@ -56,7 +55,6 @@ 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 @@ -76,7 +74,6 @@ 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 @@ -96,7 +93,6 @@ 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 d2f4b99

Please sign in to comment.