-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from JaimeCalzadaNOAA/develop
tidal dataset class inheritance
- Loading branch information
Showing
9 changed files
with
412 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
from adcircpy.forcing.tides.tpxo import TPXO | ||
from adcircpy.forcing.tides.hamtide import HAMTIDE | ||
from adcircpy.forcing.tides.tides import Tides | ||
|
||
# from pyschism.forcing.wind import WindForcing | ||
from adcircpy.forcing.tides.tpxo import TPXO | ||
|
||
__all__ = [ | ||
"Tides", | ||
'TPXO', | ||
'HAMTIDE' | ||
# "WindForcing", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
from abc import ABC, abstractmethod | ||
from os import PathLike | ||
|
||
import numpy as np | ||
|
||
|
||
class TidalDataset(ABC): | ||
CONSTITUENTS: [str] = NotImplementedError | ||
|
||
def __init__(self, path: PathLike = None): | ||
""" | ||
create a new tidal dataset object | ||
:param path: file path or URL pointing to dataset location | ||
""" | ||
|
||
self.path = str(path) if path is not None else None | ||
|
||
@abstractmethod | ||
def __call__( | ||
self, | ||
constituent: str, | ||
vertices: np.ndarray | ||
) -> (np.ndarray, np.ndarray): | ||
""" | ||
get tidal ampltidue and phase | ||
:param constituent: tidal constituent | ||
:param vertices: XY locations at which to sample (Mx2) | ||
:return: amplitude and phase arrays at given locations | ||
""" | ||
return self.get_amplitude(constituent, vertices), \ | ||
self.get_phase(constituent, vertices) | ||
|
||
@abstractmethod | ||
def get_amplitude( | ||
self, | ||
constituent: str, | ||
vertices: np.ndarray | ||
) -> np.ndarray: | ||
""" | ||
generate tidal ampltidue | ||
:param constituent: tidal constituent | ||
:param vertices: XY locations at which to sample (Mx2) | ||
:return: amplitude at given locations | ||
""" | ||
raise NotImplementedError | ||
|
||
@abstractmethod | ||
def get_phase( | ||
self, | ||
constituent: str, | ||
vertices: np.ndarray | ||
) -> np.ndarray: | ||
""" | ||
generate tidal phase | ||
:param constituent: tidal constituent | ||
:param vertices: XY locations at which to sample (Mx2) | ||
:return: phase at given locations | ||
""" | ||
raise NotImplementedError | ||
|
||
@property | ||
@abstractmethod | ||
def x(self) -> np.ndarray: | ||
""" | ||
:return: 1D array of X values of vertices | ||
""" | ||
raise NotImplementedError | ||
|
||
@property | ||
@abstractmethod | ||
def y(self) -> np.ndarray: | ||
""" | ||
:return: 1D array of Y values of vertices | ||
""" | ||
raise NotImplementedError | ||
|
||
@staticmethod | ||
def _assert_vertices(vertices: np.ndarray): | ||
""" | ||
:param vertices: list of XY locations | ||
:return: whether vertices are in XY format (Mx2) | ||
""" | ||
assert len(vertices.shape) == 2 and vertices.shape[1] == 2, \ | ||
'vertices must be of shape Mx2' |
Oops, something went wrong.