Skip to content

Commit

Permalink
added unittest for ncor (Coriolis)
Browse files Browse the repository at this point in the history
  • Loading branch information
cuill committed Sep 11, 2023
1 parent 4a7759f commit d1e583c
Showing 1 changed file with 88 additions and 0 deletions.
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 d1e583c

Please sign in to comment.