From 4a7759f3562b401e8caeded813b26614595ad683 Mon Sep 17 00:00:00 2001 From: cuill Date: Mon, 11 Sep 2023 12:30:55 -0400 Subject: [PATCH 1/2] added package appdirs to setup and ncor to param --- pyschism/driver.py | 1 + setup.py | 1 + 2 files changed, 2 insertions(+) diff --git a/pyschism/driver.py b/pyschism/driver.py index 9a6b6295..77fc3430 100644 --- a/pyschism/driver.py +++ b/pyschism/driver.py @@ -288,6 +288,7 @@ def __init__( # set opt self.param.opt.start_date = start_date self.param.opt.ics = 2 if self.config.hgrid.crs.is_geographic is True else 1 + self.param.opt.ncor = 1 if self.param.opt.ics == 2 else 0 self.param.opt.dramp = dramp self.param.opt.drampbc = drampbc self.param.opt.dramp_ss = dramp_ss diff --git a/setup.py b/setup.py index bf6942c5..1e301d49 100755 --- a/setup.py +++ b/setup.py @@ -129,6 +129,7 @@ def run(self): 'xarray', 'xmltodict', 'zarr', + 'appdirs', ], entry_points={'console_scripts': ['pyschism = pyschism.__main__:main']}, tests_require=['nose'], From d1e583ca061dc28d45d312349504442710aaf556 Mon Sep 17 00:00:00 2001 From: cuill Date: Mon, 11 Sep 2023 16:54:58 -0400 Subject: [PATCH 2/2] added unittest for ncor (Coriolis) --- tests/test_param_ncor.py | 88 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 tests/test_param_ncor.py diff --git a/tests/test_param_ncor.py b/tests/test_param_ncor.py new file mode 100644 index 00000000..198d5643 --- /dev/null +++ b/tests/test_param_ncor.py @@ -0,0 +1,88 @@ +#! /usr/bin/env python +from datetime import datetime, timedelta +import logging +import os +import pathlib +import shutil +import tarfile +import tempfile +import unittest +import urllib.request +import f90nml + +from pyschism import dates +from pyschism.mesh import Hgrid, Vgrid +from pyschism.driver import ModelConfig + + +logging.basicConfig(level=logging.INFO, force=True) + + +class ModelConfigurationTestCase(unittest.TestCase): + + def test_ncor_zero(self): + + hgrid=Hgrid.open('https://raw.githubusercontent.com/geomesh/test-data/main/NWM/hgrid.ll', crs='epsg:26918') + + config = ModelConfig( + hgrid, + ) + + # create reference dates + spinup_time = timedelta(days=0.) + start_date=datetime(2023,9,10) + + # create a coldstart object + coldstart = config.coldstart( + start_date=start_date, + end_date=start_date + timedelta(days=3.), + timestep=150., + dramp=spinup_time, + dramp_ss=spinup_time, + drampwind=spinup_time, + nspool=timedelta(hours=1), + elev=True, + dahv=True, + ) + + with tempfile.TemporaryDirectory() as tempdir: + coldstart.write(tempdir, overwrite=True) + + nml = f90nml.read(f'{tempdir}/param.nml') + assert('ncor' in nml['opt']) + assert(nml['opt']['ncor'] == 0) + + def test_ncor_one(self): + + hgrid=Hgrid.open('https://raw.githubusercontent.com/geomesh/test-data/main/NWM/hgrid.ll', crs='epsg:4326') + + config = ModelConfig( + hgrid, + ) + + # create reference dates + spinup_time = timedelta(days=0.) + start_date=datetime(2023,9,10) + + # create a coldstart object + coldstart = config.coldstart( + start_date=start_date, + end_date=start_date + timedelta(days=3.), + timestep=150., + dramp=spinup_time, + dramp_ss=spinup_time, + drampwind=spinup_time, + nspool=timedelta(hours=1), + elev=True, + dahv=True, + ) + + with tempfile.TemporaryDirectory() as tempdir: + coldstart.write(tempdir, overwrite=True) + + nml = f90nml.read(f'{tempdir}/param.nml') + assert('ncor' in nml['opt']) + assert(nml['opt']['ncor'] == 1) + +if __name__ == '__main__': + unittest.main()