Skip to content

Commit

Permalink
resolve conflicts with main
Browse files Browse the repository at this point in the history
  • Loading branch information
cuill committed Sep 19, 2023
2 parents 956cdcd + 45795d2 commit 9b70c6a
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 1 deletion.
1 change: 1 addition & 0 deletions pyschism/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ def run(self):
'xarray',
'xmltodict',
'zarr',
'pylib-essentials',
'appdirs',
],
entry_points={'console_scripts': ['pyschism = pyschism.__main__:main']},
Expand Down
88 changes: 88 additions & 0 deletions tests/test_param_ncor.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 9b70c6a

Please sign in to comment.