Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new tide API for pyschism #160

Merged
merged 9 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions coupledmodeldriver/generate/schism/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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?

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
2008-08-23 00:00:00+00:00
0 50.0
0
1
75 0 0 0 0
!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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
/
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
2008-09-01 06:00:00+00:00
0 50.0
0
1
75 0 0 0 0
!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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,6 +17,7 @@
ics=2
nchi=-1
hmin_man=1.0
ncor=1
nws=-1
wtiminc=2.0
model_type_pahm=10
Expand All @@ -25,4 +26,6 @@
&SCHOUT
nhot=1
nhot_write=604800
iof_hydro(1)=1
iof_hydro(16)=1
/
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
2008-09-01 06:00:00+00:00
0 50.0
0
1
75 0 0 0 0
!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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,6 +17,7 @@
ics=2
nchi=-1
hmin_man=1.0
ncor=1
nws=-1
wtiminc=2.0
model_type_pahm=10
Expand All @@ -25,4 +26,6 @@
&SCHOUT
nhot=1
nhot_write=604800
iof_hydro(1)=1
iof_hydro(16)=1
/
Original file line number Diff line number Diff line change
@@ -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
!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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
/
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
/
7 changes: 5 additions & 2 deletions tests/data/reference/test_hera_schism_tidal/spinup/param.nml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
/
Loading