From 6da5da0503175430f2e7db03d8f524256c73f4f6 Mon Sep 17 00:00:00 2001 From: "Soroosh.Mani" Date: Fri, 20 Oct 2023 11:52:02 -0400 Subject: [PATCH 1/9] Use new tide API for pyschism --- coupledmodeldriver/generate/schism/base.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/coupledmodeldriver/generate/schism/base.py b/coupledmodeldriver/generate/schism/base.py index fe4f0b30..c28df9fa 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 = None 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, + constituents=None, # we're overwriting Tides obj + database=None, # 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? From d35ae5896565ea719e6ddc602a9ee5438bf82a28 Mon Sep 17 00:00:00 2001 From: "Soroosh.Mani" Date: Fri, 20 Oct 2023 11:56:32 -0400 Subject: [PATCH 2/9] Use compatible pyschism version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d539667a..c83e344c 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.12' pytest = { version = '*', optional = true } pytest-cov = { version = '*', optional = true } pytest-socket = { version = '*', optional = true } From 92c6b171086f001ed00eb0ce598d36cee56a9706 Mon Sep 17 00:00:00 2001 From: "Soroosh.Mani" Date: Fri, 20 Oct 2023 11:57:39 -0400 Subject: [PATCH 3/9] Typo fix in pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c83e344c..44f81c1e 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 = >0.1.12' +pyschism = '>0.1.12' pytest = { version = '*', optional = true } pytest-cov = { version = '*', optional = true } pytest-socket = { version = '*', optional = true } From f1d242db4bc12c71fbcab34bd3ee5ca3ed4c81b4 Mon Sep 17 00:00:00 2001 From: "Soroosh.Mani" Date: Mon, 23 Oct 2023 14:07:01 -0400 Subject: [PATCH 4/9] Fix no tide BC --- coupledmodeldriver/generate/schism/base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/coupledmodeldriver/generate/schism/base.py b/coupledmodeldriver/generate/schism/base.py index c28df9fa..780d96c4 100644 --- a/coupledmodeldriver/generate/schism/base.py +++ b/coupledmodeldriver/generate/schism/base.py @@ -405,7 +405,7 @@ def base_mesh(self, base_mesh: Union[Hgrid, PathLike]): def pyschism_driver(self) -> ModelDriver: tides = None - tidal_flags = None + tidal_flags = [[0, 0, 0, 0]] # Needed for correct no tide BC meteo = None hydrology = None for pyschism_forcing in self.pyschism_forcings: @@ -424,8 +424,8 @@ def pyschism_driver(self) -> ModelDriver: vgrid=None, fgrid=None, # pyschism writes linear with depth for 2D flags=tidal_flags, - constituents=None, # we're overwriting Tides obj - database=None, # we're overwriting Tides obj + constituents=[], # we're overwriting Tides obj + database='tpxo', # we're overwriting Tides obj nws=meteo, source_sink=hydrology, ) From ca55ff3b9295463ba4a46b55a15c91aeb0ed0a1c Mon Sep 17 00:00:00 2001 From: "Soroosh.Mani" Date: Mon, 23 Oct 2023 14:14:45 -0400 Subject: [PATCH 5/9] Update test refs for latest pyschism --- .../test_hera_schism/runs/unperturbed/bctides.in | 10 +++++----- .../test_hera_schism/runs/unperturbed/param.nml | 7 +++++-- .../runs/unperturbed/bctides.in | 10 +++++----- .../runs/unperturbed/param.nml | 7 +++++-- .../runs/unperturbed/bctides.in | 10 +++++----- .../runs/unperturbed/param.nml | 7 +++++-- .../test_hera_schism_nwm/runs/unperturbed/param.nml | 7 +++++-- .../test_hera_schism_tidal/runs/unperturbed/param.nml | 7 +++++-- .../reference/test_hera_schism_tidal/spinup/param.nml | 7 +++++-- 9 files changed, 45 insertions(+), 27 deletions(-) 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/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 / From ba7826b01029268ac800704e9630df4e139a522b Mon Sep 17 00:00:00 2001 From: "Soroosh.Mani" Date: Mon, 23 Oct 2023 14:23:00 -0400 Subject: [PATCH 6/9] Using latest pyschism --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 44f81c1e..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 = '>0.1.12' +pyschism = '>0.1.13' pytest = { version = '*', optional = true } pytest-cov = { version = '*', optional = true } pytest-socket = { version = '*', optional = true } From 4be5640cf72469057c7222b580fdfa64c76b1996 Mon Sep 17 00:00:00 2001 From: "Soroosh.Mani" Date: Mon, 23 Oct 2023 14:56:28 -0400 Subject: [PATCH 7/9] Fix multi open boundary tidal bc --- coupledmodeldriver/generate/schism/base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/coupledmodeldriver/generate/schism/base.py b/coupledmodeldriver/generate/schism/base.py index 780d96c4..357357b6 100644 --- a/coupledmodeldriver/generate/schism/base.py +++ b/coupledmodeldriver/generate/schism/base.py @@ -405,13 +405,13 @@ def base_mesh(self, base_mesh: Union[Hgrid, PathLike]): def pyschism_driver(self) -> ModelDriver: tides = None - tidal_flags = [[0, 0, 0, 0]] # Needed for correct no tide BC + 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): tides = pyschism_forcing - tidal_flags = [[3, 3, 0, 0]] + tidal_flags = [3, 3, 0, 0] elif isinstance(pyschism_forcing, NWS): meteo = pyschism_forcing @@ -423,7 +423,7 @@ def pyschism_driver(self) -> ModelDriver: hgrid=self.pyschism_mesh, vgrid=None, fgrid=None, # pyschism writes linear with depth for 2D - flags=tidal_flags, + 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, From 368f6352f0d44e04ad797378e6e449bbc1c9d17d Mon Sep 17 00:00:00 2001 From: "Soroosh.Mani" Date: Mon, 23 Oct 2023 15:00:51 -0400 Subject: [PATCH 8/9] Fix test ref for nwm tide bc --- .../runs/unperturbed/bctides.in | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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 From a3fde0e7659fba2456e76af08d36c0807fd8c972 Mon Sep 17 00:00:00 2001 From: "Soroosh.Mani" Date: Mon, 23 Oct 2023 15:31:25 -0400 Subject: [PATCH 9/9] Fix elev IC (old pyschism fix not accounted for) --- .../reference/test_hera_schism_nwm/runs/unperturbed/elev.ic | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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