Skip to content

Commit

Permalink
Merge pull request #68 from SorooshMani-NOAA/bugfix/besttrack
Browse files Browse the repository at this point in the history
Fix best track forcing issue due to dependency update
  • Loading branch information
cuill authored Apr 21, 2023
2 parents 820d93c + 00085bf commit 96aedc3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
4 changes: 3 additions & 1 deletion pyschism/forcing/nws/best_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def __init__(
storm: Union[str, PathLike, DataFrame, io.BytesIO],
start_date: datetime = None,
end_date: datetime = None,
hurricane_model: Union[str, HurricaneModel] = 'gahm'
hurricane_model: Union[str, HurricaneModel] = 'gahm',
*args,
**kwargs
):

self.model = hurricane_model
Expand Down
41 changes: 39 additions & 2 deletions tests/test_paramwind.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import tempfile
from datetime import timedelta, datetime
from pathlib import Path

from stormevents.nhc import VortexTrack

from pyschism.mesh import Hgrid
from pyschism.driver import ModelConfig
from pyschism.forcing.nws import BestTrackForcing


def test_paramwind():
def test_paramwind_from_stormname():

hgrid = Hgrid.open(
'https://raw.githubusercontent.com/geomesh/test-data/main/NWM/hgrid.ll'
Expand All @@ -30,7 +33,41 @@ def test_paramwind():
nspool=24,
)

driver.write(Path(__file__).parent / 'paramwind', overwrite=True)
with tempfile.TemporaryDirectory() as dn:
tmpdir = Path(dn)
driver.write(tmpdir / 'paramwind', overwrite=True)

def test_paramwind_from_file():
hgrid = Hgrid.open(
'https://raw.githubusercontent.com/geomesh/test-data/main/NWM/hgrid.ll'
)

track = VortexTrack.from_storm_name('Florence', 2018)


with tempfile.TemporaryDirectory() as dn:
tmpdir = Path(dn)
track.to_file(tmpdir / 'track.dat')

meteo = BestTrackForcing.from_nhc_bdeck(nhc_bdeck=tmpdir / 'track.dat')
config = ModelConfig(
hgrid=hgrid,
vgrid=None,
fgrid=None,
iettype=None,
ifltype=None,
nws=meteo,
)

driver = config.coldstart(
start_date=datetime(2018, 9, 8),
end_date=datetime(2018, 9, 18),
timestep=timedelta(seconds=150),
nspool=24,
)

driver.write(tmpdir / 'paramwind', overwrite=True)


if __name__ == '__main__':
test_paramwind()

0 comments on commit 96aedc3

Please sign in to comment.