diff --git a/coupledmodeldriver/generate/schism/base.py b/coupledmodeldriver/generate/schism/base.py index fe4f0b30..357357b6 100644 --- a/coupledmodeldriver/generate/schism/base.py +++ b/coupledmodeldriver/generate/schism/base.py @@ -7,8 +7,6 @@ from pyschism.mesh import Hgrid from pyschism.server import SlurmConfig from pyschism.driver import ModelConfig, ModelDriver -from pyschism.forcing.bctides.iettype import TidalElevation -from pyschism.forcing.bctides.ifltype import TidalVelocity from pyschism.forcing.bctides.tides import Tides from pyschism.forcing.base import ModelForcing from pyschism.stations import Stations @@ -406,18 +404,14 @@ def base_mesh(self, base_mesh: Union[Hgrid, PathLike]): @property def pyschism_driver(self) -> ModelDriver: - tidal_elevation = None - tidal_velocity = None + tides = None + tidal_flags = [0, 0, 0, 0] # Needed for correct no tide BC meteo = None hydrology = None for pyschism_forcing in self.pyschism_forcings: if isinstance(pyschism_forcing, Tides): - - # NOTE: Create tidal BC and then replace the tidal database - tidal_elevation = TidalElevation() - tidal_elevation.tides = pyschism_forcing - tidal_velocity = TidalVelocity() - tidal_velocity.tides = pyschism_forcing + tides = pyschism_forcing + tidal_flags = [3, 3, 0, 0] elif isinstance(pyschism_forcing, NWS): meteo = pyschism_forcing @@ -429,11 +423,15 @@ def pyschism_driver(self) -> ModelDriver: hgrid=self.pyschism_mesh, vgrid=None, fgrid=None, # pyschism writes linear with depth for 2D - iettype=tidal_elevation, - ifltype=tidal_velocity, + flags=[tidal_flags for _ in self.pyschism_mesh.boundaries.open.itertuples()], + constituents=[], # we're overwriting Tides obj + database='tpxo', # we're overwriting Tides obj nws=meteo, source_sink=hydrology, ) + # Hacky way to set the resource for tide + if tides is not None: + config.bctides.tides = tides # TODO: What about other variable outputs? diff --git a/pyproject.toml b/pyproject.toml index d539667a..2a1d43bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ typepigeon = '^1.0.3' isort = { version = '*', optional = true } oitnb = { version = '*', optional = true } pooch = { version = '*', optional = true } -pyschism = '*' +pyschism = '>0.1.13' pytest = { version = '*', optional = true } pytest-cov = { version = '*', optional = true } pytest-socket = { version = '*', optional = true } diff --git a/tests/data/reference/test_hera_schism/runs/unperturbed/bctides.in b/tests/data/reference/test_hera_schism/runs/unperturbed/bctides.in index 2b5d594c..51f3fba8 100644 --- a/tests/data/reference/test_hera_schism/runs/unperturbed/bctides.in +++ b/tests/data/reference/test_hera_schism/runs/unperturbed/bctides.in @@ -1,5 +1,5 @@ -2008-08-23 00:00:00+00:00 -0 50.0 -0 -1 -75 0 0 0 0 \ No newline at end of file +!2008-08-23 00:00:00+00:00 UTC +0 50.0 !number of earth tidal potential, cut-off depth for applying tidal potential +0 !nbfr +1 !nope +75 0 0 0 0 !open bnd 1 \ No newline at end of file diff --git a/tests/data/reference/test_hera_schism/runs/unperturbed/param.nml b/tests/data/reference/test_hera_schism/runs/unperturbed/param.nml index ecb4e37a..28b47e99 100644 --- a/tests/data/reference/test_hera_schism/runs/unperturbed/param.nml +++ b/tests/data/reference/test_hera_schism/runs/unperturbed/param.nml @@ -2,10 +2,10 @@ ipre=0 ibc=1 ibtp=0 + rnday=14.5 + dt=2.0 nspool=1800 ihfskip=626400 - dt=2.0 - rnday=14.5 / &OPT @@ -17,9 +17,12 @@ ics=2 nchi=-1 hmin_man=1.0 + ncor=1 / &SCHOUT nhot=1 nhot_write=626400 + iof_hydro(1)=1 + iof_hydro(16)=1 / diff --git a/tests/data/reference/test_hera_schism_besttrack_fromfile/runs/unperturbed/bctides.in b/tests/data/reference/test_hera_schism_besttrack_fromfile/runs/unperturbed/bctides.in index 2ad0baf2..2d8ea3cc 100644 --- a/tests/data/reference/test_hera_schism_besttrack_fromfile/runs/unperturbed/bctides.in +++ b/tests/data/reference/test_hera_schism_besttrack_fromfile/runs/unperturbed/bctides.in @@ -1,5 +1,5 @@ -2008-09-01 06:00:00+00:00 -0 50.0 -0 -1 -75 0 0 0 0 \ No newline at end of file +!2008-09-01 06:00:00+00:00 UTC +0 50.0 !number of earth tidal potential, cut-off depth for applying tidal potential +0 !nbfr +1 !nope +75 0 0 0 0 !open bnd 1 \ No newline at end of file diff --git a/tests/data/reference/test_hera_schism_besttrack_fromfile/runs/unperturbed/param.nml b/tests/data/reference/test_hera_schism_besttrack_fromfile/runs/unperturbed/param.nml index 20df53da..ca6471d3 100644 --- a/tests/data/reference/test_hera_schism_besttrack_fromfile/runs/unperturbed/param.nml +++ b/tests/data/reference/test_hera_schism_besttrack_fromfile/runs/unperturbed/param.nml @@ -2,10 +2,10 @@ ipre=0 ibc=1 ibtp=0 + rnday=14.0 + dt=2.0 nspool=1800 ihfskip=604800 - dt=2.0 - rnday=14.0 / &OPT @@ -17,6 +17,7 @@ ics=2 nchi=-1 hmin_man=1.0 + ncor=1 nws=-1 wtiminc=2.0 model_type_pahm=10 @@ -25,4 +26,6 @@ &SCHOUT nhot=1 nhot_write=604800 + iof_hydro(1)=1 + iof_hydro(16)=1 / diff --git a/tests/data/reference/test_hera_schism_besttrack_fromnhccode/runs/unperturbed/bctides.in b/tests/data/reference/test_hera_schism_besttrack_fromnhccode/runs/unperturbed/bctides.in index 2ad0baf2..2d8ea3cc 100644 --- a/tests/data/reference/test_hera_schism_besttrack_fromnhccode/runs/unperturbed/bctides.in +++ b/tests/data/reference/test_hera_schism_besttrack_fromnhccode/runs/unperturbed/bctides.in @@ -1,5 +1,5 @@ -2008-09-01 06:00:00+00:00 -0 50.0 -0 -1 -75 0 0 0 0 \ No newline at end of file +!2008-09-01 06:00:00+00:00 UTC +0 50.0 !number of earth tidal potential, cut-off depth for applying tidal potential +0 !nbfr +1 !nope +75 0 0 0 0 !open bnd 1 \ No newline at end of file diff --git a/tests/data/reference/test_hera_schism_besttrack_fromnhccode/runs/unperturbed/param.nml b/tests/data/reference/test_hera_schism_besttrack_fromnhccode/runs/unperturbed/param.nml index 20df53da..ca6471d3 100644 --- a/tests/data/reference/test_hera_schism_besttrack_fromnhccode/runs/unperturbed/param.nml +++ b/tests/data/reference/test_hera_schism_besttrack_fromnhccode/runs/unperturbed/param.nml @@ -2,10 +2,10 @@ ipre=0 ibc=1 ibtp=0 + rnday=14.0 + dt=2.0 nspool=1800 ihfskip=604800 - dt=2.0 - rnday=14.0 / &OPT @@ -17,6 +17,7 @@ ics=2 nchi=-1 hmin_man=1.0 + ncor=1 nws=-1 wtiminc=2.0 model_type_pahm=10 @@ -25,4 +26,6 @@ &SCHOUT nhot=1 nhot_write=604800 + iof_hydro(1)=1 + iof_hydro(16)=1 / diff --git a/tests/data/reference/test_hera_schism_nwm/runs/unperturbed/bctides.in b/tests/data/reference/test_hera_schism_nwm/runs/unperturbed/bctides.in index fc299f30..0a5c15e1 100644 --- a/tests/data/reference/test_hera_schism_nwm/runs/unperturbed/bctides.in +++ b/tests/data/reference/test_hera_schism_nwm/runs/unperturbed/bctides.in @@ -1,9 +1,9 @@ -2008-08-23 00:00:00+00:00 -0 50.0 -0 -5 -79 0 0 0 0 -10 0 0 0 0 -2 0 0 0 0 -2 0 0 0 0 -7 0 0 0 0 \ No newline at end of file +!2008-08-23 00:00:00+00:00 UTC +0 50.0 !number of earth tidal potential, cut-off depth for applying tidal potential +0 !nbfr +5 !nope +79 0 0 0 0 !open bnd 1 +10 0 0 0 0 !open bnd 2 +2 0 0 0 0 !open bnd 3 +2 0 0 0 0 !open bnd 4 +7 0 0 0 0 !open bnd 5 \ No newline at end of file diff --git a/tests/data/reference/test_hera_schism_nwm/runs/unperturbed/elev.ic b/tests/data/reference/test_hera_schism_nwm/runs/unperturbed/elev.ic index c8a954c6..a461e89a 100644 --- a/tests/data/reference/test_hera_schism_nwm/runs/unperturbed/elev.ic +++ b/tests/data/reference/test_hera_schism_nwm/runs/unperturbed/elev.ic @@ -267,7 +267,7 @@ elevic EPSG:4326 265 -72.60697087 40.91124034 3.43926867 266 -72.14271112 40.82191054 0.00000000 267 -72.66261348 40.54336860 0.00000000 -268 -72.81594669 40.76073875 -0.03349329 +268 -72.81594669 40.76073875 0.00000000 269 -72.24874692 40.95997591 9.68430247 270 -72.20271029 40.91740784 0.00000000 271 -72.78140650 40.64811118 0.00000000 @@ -1496,7 +1496,7 @@ elevic EPSG:4326 1494 -72.55522788 40.99970979 12.06361505 1495 -72.22271391 40.63688446 0.00000000 1496 -72.34929113 41.00399390 0.00000000 -1497 -72.47454720 40.90074766 -0.00512758 +1497 -72.47454720 40.90074766 0.00000000 1498 -72.47955866 40.91279676 0.00000000 1 3 564 1286 1411 2 3 457 447 458 diff --git a/tests/data/reference/test_hera_schism_nwm/runs/unperturbed/param.nml b/tests/data/reference/test_hera_schism_nwm/runs/unperturbed/param.nml index 72a7e562..6090178f 100644 --- a/tests/data/reference/test_hera_schism_nwm/runs/unperturbed/param.nml +++ b/tests/data/reference/test_hera_schism_nwm/runs/unperturbed/param.nml @@ -2,10 +2,10 @@ ipre=0 ibc=1 ibtp=0 + rnday=14.5 + dt=2.0 nspool=1800 ihfskip=626400 - dt=2.0 - rnday=14.5 / &OPT @@ -17,10 +17,13 @@ ics=2 nchi=-1 hmin_man=1.0 + ncor=1 ic_elev=1 / &SCHOUT nhot=1 nhot_write=626400 + iof_hydro(1)=1 + iof_hydro(16)=1 / diff --git a/tests/data/reference/test_hera_schism_tidal/runs/unperturbed/param.nml b/tests/data/reference/test_hera_schism_tidal/runs/unperturbed/param.nml index 18e23e04..f0e74ec3 100644 --- a/tests/data/reference/test_hera_schism_tidal/runs/unperturbed/param.nml +++ b/tests/data/reference/test_hera_schism_tidal/runs/unperturbed/param.nml @@ -2,10 +2,10 @@ ipre=0 ibc=1 ibtp=0 + rnday=14.5 + dt=2.0 nspool=1800 ihfskip=626400 - dt=2.0 - rnday=14.5 / &OPT @@ -18,9 +18,12 @@ ihot=1 nchi=-1 hmin_man=1.0 + ncor=1 / &SCHOUT nhot=1 nhot_write=626400 + iof_hydro(1)=1 + iof_hydro(16)=1 / diff --git a/tests/data/reference/test_hera_schism_tidal/spinup/param.nml b/tests/data/reference/test_hera_schism_tidal/spinup/param.nml index 85df77a9..57b161cf 100644 --- a/tests/data/reference/test_hera_schism_tidal/spinup/param.nml +++ b/tests/data/reference/test_hera_schism_tidal/spinup/param.nml @@ -2,10 +2,10 @@ ipre=0 ibc=1 ibtp=0 + rnday=12.5 + dt=2.0 nspool=1800 ihfskip=540000 - dt=2.0 - rnday=12.5 / &OPT @@ -20,10 +20,13 @@ dramp_ss=12.5 nchi=-1 hmin_man=1.0 + ncor=1 drampwind=12.5 / &SCHOUT nhot=1 nhot_write=540000 + iof_hydro(1)=1 + iof_hydro(16)=1 /