Skip to content

Commit

Permalink
pyschism integration
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyburnett committed May 6, 2021
1 parent 605a34a commit 529fe92
Show file tree
Hide file tree
Showing 19 changed files with 544 additions and 193 deletions.
4 changes: 2 additions & 2 deletions client/initialize_adcirc.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def main():
fort13_path=mesh_directory / 'fort.13',
fort14_path=mesh_directory / 'fort.14',
modeled_start_time=modeled_start_time,
modeled_end_time=modeled_start_time + modeled_duration,
modeled_duration=modeled_duration,
modeled_timestep=modeled_timestep,
nems_interval=nems_interval,
nems_connections=None,
Expand All @@ -278,7 +278,7 @@ def main():
fort13_path=mesh_directory / 'fort.13',
fort14_path=mesh_directory / 'fort.14',
modeled_start_time=modeled_start_time,
modeled_end_time=modeled_start_time + modeled_duration,
modeled_duration=modeled_duration,
modeled_timestep=modeled_timestep,
tidal_spinup_duration=tidal_spinup_duration,
platform=platform,
Expand Down
21 changes: 17 additions & 4 deletions coupledmodeldriver/configure/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import nemspy
from nemspy import ModelingSystem
from nemspy.model.base import ModelEntry
from pyschism.server import ServerConfig

from coupledmodeldriver.platforms import Platform
from coupledmodeldriver.script import SlurmEmailType
Expand Down Expand Up @@ -212,6 +213,7 @@ class SlurmJSON(ConfigurationJSON):
'path_prefix': Path,
'extra_commands': [str],
'launcher': str,
'executable': Path,
'nodes': int,
}

Expand All @@ -230,6 +232,7 @@ def __init__(
path_prefix: Path = None,
extra_commands: [str] = None,
launcher: str = None,
executable: PathLike = None,
nodes: int = None,
**kwargs,
):
Expand All @@ -256,6 +259,7 @@ def __init__(
self['path_prefix'] = path_prefix
self['extra_commands'] = extra_commands
self['launcher'] = launcher
self['executable'] = executable
self['nodes'] = nodes

if self['email_type'] is None:
Expand Down Expand Up @@ -302,6 +306,15 @@ def from_adcircpy(cls, slurm_config: SlurmConfig):

instance['filename'] = slurm_config._filename

@property
def to_pyschism(self) -> ServerConfig:
return ServerConfig(
nproc=self.tasks,
symlink_outputs=None,
schism_binary=self['executable'],
mpi_launcher=self['launcher'],
)


class ModelDriverJSON(ConfigurationJSON):
name = 'ModelDriver'
Expand Down Expand Up @@ -364,7 +377,7 @@ class NEMSJSON(ConfigurationJSON):
field_types = {
'executable': Path,
'modeled_start_time': datetime,
'modeled_end_time': datetime,
'modeled_duration': timedelta,
'interval': timedelta,
'models': [ModelEntry],
'connections': [[str]],
Expand All @@ -376,7 +389,7 @@ def __init__(
self,
executable: PathLike,
modeled_start_time: datetime,
modeled_end_time: datetime,
modeled_duration: timedelta,
interval: timedelta = None,
models: [ModelEntry] = None,
connections: [[str]] = None,
Expand All @@ -392,7 +405,7 @@ def __init__(

self['executable'] = executable
self['modeled_start_time'] = modeled_start_time
self['modeled_end_time'] = modeled_end_time
self['modeled_duration'] = modeled_duration
self['interval'] = interval
self['models'] = models
self['connections'] = connections
Expand All @@ -403,7 +416,7 @@ def __init__(
def nemspy_modeling_system(self) -> ModelingSystem:
modeling_system = ModelingSystem(
start_time=self['modeled_start_time'],
end_time=self['modeled_end_time'],
end_time=self['modeled_start_time'] + self['modeled_duration'],
interval=self['interval'],
**{model.model_type.value.lower(): model for model in self['models']},
)
Expand Down
8 changes: 7 additions & 1 deletion coupledmodeldriver/configure/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
from nemspy.model.base import ModelEntry

from coupledmodeldriver.configure.base import ConfigurationJSON, ModelDriverJSON, NEMSCapJSON
from coupledmodeldriver.configure.forcings.base import ADCIRCPY_FORCING_CLASSES, ForcingJSON
from coupledmodeldriver.configure.forcings.base import (
ADCIRCPY_FORCING_CLASSES,
ForcingJSON,
PYSCHISM_FORCING_CLASSES,
)


class RunConfiguration(ABC):
Expand Down Expand Up @@ -157,4 +161,6 @@ def from_user_input(value: Any) -> ConfigurationJSON:
value = ConfigurationJSON.from_string(value)
elif isinstance(value, ADCIRCPY_FORCING_CLASSES):
value = ForcingJSON.from_adcircpy(value)
elif isinstance(value, PYSCHISM_FORCING_CLASSES):
value = ForcingJSON.from_pyschism(value)
return value
Loading

0 comments on commit 529fe92

Please sign in to comment.