Skip to content

Commit

Permalink
Merge pull request #41 from JaimeCalzadaNOAA/fix/windforcing_set_wtiminc
Browse files Browse the repository at this point in the history
fix setting interval
  • Loading branch information
zacharyburnett authored Jan 27, 2021
2 parents 1f0f094 + 157314e commit 3932141
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
14 changes: 14 additions & 0 deletions adcircpy/forcing/base.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
from abc import ABC, abstractmethod
from datetime import timedelta
from os import PathLike


class Forcing(ABC):
def __init__(self, interval: timedelta):
self.interval = interval

@abstractmethod
def write(self, directory: PathLike, overwrite: bool = False):
raise NotImplementedError

@property
def interval(self) -> timedelta:
return self.__interval

@interval.setter
def interval(self, interval: timedelta):
if not isinstance(interval, timedelta):
interval = timedelta(seconds=interval)
self.__interval = interval
2 changes: 1 addition & 1 deletion adcircpy/forcing/waves/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class WaveForcing(Forcing, ABC):
def __init__(self, nrs: int, interval_seconds: int):
super().__init__(interval_seconds)
self.NRS = nrs
self.RSTIMINC = interval_seconds

@abstractmethod
def write(self, directory: PathLike, overwrite: bool = False):
Expand Down
2 changes: 1 addition & 1 deletion adcircpy/forcing/winds/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class WindForcing(Forcing, ABC):
def __init__(self, nws: int, interval_seconds: int):
super().__init__(interval_seconds)
self.NWS = nws
self.WTIMINC = interval_seconds

@abstractmethod
def write(self, directory: PathLike, overwrite: bool = False):
Expand Down
4 changes: 2 additions & 2 deletions adcircpy/fort15.py
Original file line number Diff line number Diff line change
Expand Up @@ -987,15 +987,15 @@ def REFTIM(self):
@property
def WTIMINC(self):
if self.NWS not in [0, 1, 9, 11]:
return self.wind_forcing.WTIMINC
return int(self.wind_forcing.interval / timedelta(seconds=1))
else:
return 0

@property
def RSTIMINC(self):
if self.NRS in [1, 3, 4, 5]:
if self.wave_forcing is not None:
return self.wave_forcing.RSTIMINC
return int(self.wave_forcing.interval / timedelta(seconds=1))
else:
return self.WTIMINC
else:
Expand Down

0 comments on commit 3932141

Please sign in to comment.