Skip to content

Commit

Permalink
Merge pull request #79 from SorooshMani-NOAA/bugfix/driver
Browse files Browse the repository at this point in the history
Bugfix/driver
  • Loading branch information
cuill authored Jun 2, 2023
2 parents 95362e1 + 4a8ee35 commit 6b1fc20
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
11 changes: 9 additions & 2 deletions pyschism/forcing/bctides/bctides.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,20 @@ def write_sal3D():
from multiprocessing import Process

jobs = [
Process(target=f)
for f in (write_elev2D, write_uv3D, write_tem3D, write_sal3D)
Process(target=fn)
for fn, fl in (
(write_elev2D, elev2D),
(write_uv3D, uv3D),
(write_tem3D, tem3D),
(write_sal3D, sal3D)
) if fl
]
for job in jobs:
job.start()
for job in jobs:
job.join()
if any(j.exitcode != 0 for j in jobs):
raise RuntimeError("Some parallel writer jobs failed!")
else:
if elev2D:
write_elev2D()
Expand Down
44 changes: 43 additions & 1 deletion tests/test_bctides.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
import tempfile
import unittest
import urllib.request
from datetime import datetime, timedelta

from pyschism.cmd.bctides import add_bctides, BctidesCli
from pyschism.cmd.bctides import BctidesCli
from pyschism.driver import ModelConfig
from pyschism.forcing.bctides import iettype, ifltype
from pyschism.mesh import Hgrid


logging.basicConfig(level=logging.INFO, force=True)
Expand Down Expand Up @@ -106,6 +110,44 @@ def _test_bctides_cli_3d(self):
])
BctidesCli(args)

def test_simple_tidal_setup(self):
# Inputs: Modify As Needed!
start_date = "2018091000" #in YYYYMMDDHH format
end_date = "2018091600" #in YYYYMMDDHH format

tide_source = "tpxo"

dt = timedelta(seconds=150.)
nspool = timedelta(minutes=20.)

start_date = datetime.strptime(start_date, "%Y%m%d%H")
end_date = datetime.strptime(end_date, "%Y%m%d%H")
rnday = end_date - start_date

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

config = ModelConfig(
hgrid=hgrid,
iettype=iettype.Iettype3(database=tide_source),
ifltype=ifltype.Ifltype3(database=tide_source),
)

coldstart = config.coldstart(
start_date=start_date,
end_date=start_date + rnday,
timestep=dt,
nspool=timedelta(hours=1),
elev=True,
dahv=True,
)

with tempfile.TemporaryDirectory() as dn:
tmpdir = pathlib.Path(dn)
coldstart.write(tmpdir, overwrite=True)


if __name__ == '__main__':
unittest.main()

0 comments on commit 6b1fc20

Please sign in to comment.