Skip to content

Commit

Permalink
🐛 fix hurdat2 temp path bug where user defined value was never used (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsantana11 authored Aug 9, 2024
1 parent a9bc63c commit f3034ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions clouddrift/adapters/hurdat2.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,12 @@ def _get_download_requests(basin: _BasinOption, tmp_path: str):

if basin == "atlantic" or basin == "both":
file_name = _ATLANTIC_BASIN_URL.split("/")[-1]
fp = os.path.join(_DEFAULT_FILE_PATH, file_name)
fp = os.path.join(tmp_path, file_name)
download_requests.append((_ATLANTIC_BASIN_URL, fp, None))

if basin == "pacific" or basin == "both":
file_name = _PACIFIC_BASIN_URL.split("/")[-1]
fp = os.path.join(_DEFAULT_FILE_PATH, file_name)
fp = os.path.join(tmp_path, file_name)
download_requests.append((_PACIFIC_BASIN_URL, fp, None))
return download_requests

Expand All @@ -360,7 +360,7 @@ def to_raggedarray(
convert: bool = True,
) -> RaggedArray:
os.makedirs(
_DEFAULT_FILE_PATH, exist_ok=True
tmp_path, exist_ok=True
) # generate temp directory for hurdat related intermerdiary data
download_requests = _get_download_requests(basin, tmp_path)
download_with_progress(download_requests)
Expand Down
8 changes: 6 additions & 2 deletions clouddrift/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,11 @@ def glad(decode_times: bool = True) -> xr.Dataset:
return _dataset_filecache("glad.nc", decode_times, adapters.glad.to_xarray)


def hurdat2(basin: _BasinOption = "both", decode_times: bool = True) -> xr.DataArray:
def hurdat2(
basin: _BasinOption = "both",
decode_times: bool = True,
tmp_path: str = adapters.hurdat2._DEFAULT_FILE_PATH,
) -> xr.DataArray:
"""Returns the revised hurricane database (HURDAT2) as a ragged array xarray dataset.
The function will first look for the ragged array dataset on the local
Expand Down Expand Up @@ -281,7 +285,7 @@ def hurdat2(basin: _BasinOption = "both", decode_times: bool = True) -> xr.DataA
return _dataset_filecache(
f"hurdat2_{basin}.nc",
decode_times,
lambda: adapters.hurdat2.to_raggedarray(basin).to_xarray(),
lambda: adapters.hurdat2.to_raggedarray(basin, tmp_path).to_xarray(),
)


Expand Down

0 comments on commit f3034ad

Please sign in to comment.