Skip to content

Commit d697899

Browse files
Merge pull request #70 from JaimeCalzadaNOAA/develop
handle URL given to HAMTIDE, datetime given to `.start_date`
2 parents e8c74a2 + 5c32423 commit d697899

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

adcircpy/forcing/tides/hamtide.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ class HAMTIDE(TidalDataset):
1919
def __init__(self, hamtide_dataset_directory: PathLike = None):
2020
if hamtide_dataset_directory is None:
2121
hamtide_dataset_directory = self.OPENDAP_URL
22-
23-
if Path(hamtide_dataset_directory).exists():
24-
hamtide_dataset_directory = Path(hamtide_dataset_directory)
25-
if len(list(hamtide_dataset_directory.glob('*.nc'))) == 0:
26-
raise FileNotFoundError(f'no NetCDF files found at '
27-
f'"{hamtide_dataset_directory}"')
22+
else:
23+
try:
24+
if Path(hamtide_dataset_directory).exists():
25+
hamtide_dataset_directory = Path(hamtide_dataset_directory)
26+
if len(list(hamtide_dataset_directory.glob('*.nc'))) == 0:
27+
raise FileNotFoundError(f'no NetCDF files found at '
28+
f'"{hamtide_dataset_directory}"')
29+
except OSError:
30+
raise ValueError('given resource must be a local path')
2831

2932
super().__init__(hamtide_dataset_directory)
3033

adcircpy/fort15.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,6 +2271,8 @@ def _get_TOUTS__(self, output_type, physical_var):
22712271
start = start - self.forcing_start_date
22722272
else:
22732273
start = start - self.start_date
2274+
elif isinstance(start, datetime):
2275+
start = self.start_date - start
22742276

22752277
elif isinstance(start, type(None)):
22762278
if self._runtype == 'hotstart':
@@ -2279,7 +2281,7 @@ def _get_TOUTS__(self, output_type, physical_var):
22792281
else:
22802282
return 0
22812283

2282-
return start.total_seconds() / (60.0 * 60.0 * 24.0)
2284+
return start / timedelta(days=1)
22832285

22842286
def _get_TOUTF__(self, output_type, physical_var):
22852287
output = self._container[output_type][physical_var]
@@ -2298,7 +2300,7 @@ def _get_TOUTF__(self, output_type, physical_var):
22982300
else:
22992301
return 0
23002302
else:
2301-
raise NotImplementedError
2303+
raise NotImplementedError('specific spinup end time is not implemented')
23022304
else:
23032305
return 0
23042306

0 commit comments

Comments
 (0)