wrfhydropy.CycleSimulation
- class wrfhydropy.CycleSimulation(init_times: list, restart_dirs: list, forcing_dirs: list = [], ncores: int = 1)[source]
Class for a WRF-Hydro CycleSimulation object. The Cycle Simulation object is used to orchestrate a set of ‘N’ WRF-Hydro simulations, referred to as ‘casts’, which only differ in their 1) restart times and 2) their forcings.
Methods
add(obj)Add an approparite object to an CycleSimulation, such as a Simulation, Job, or Scheduler.
compose([symlink_domain, force, ...])Cycle compose (directories and files to disk) :Parameters: * symlink_domain -- Symlink the domain files rather than copy * force -- Compose into directory even if not empty. This is considered bad practice but * is necessary in certain circumstances. * rm_casts_from_memory -- Most applications will remove the casts from the * ensemble object upon compose. Testing and other reasons may keep them around. * check_nlst_warn -- Allow the namelist checking/validation to only result in warnings. * This is also not great practice, but necessary in certain circumstances..
pickle(path)Pickle ensemble sim object to specified file path :Parameters: path -- The file path for pickle
rm_casts()Remove members from memory, replace with their paths.
run([n_concurrent, teams, teams_exe_cmd, ...])Run the cycle of simulations. Inputs: n_concurrent: int = 1, Only used for non-team runs. teams: bool = False, Use teams? teams_exe_cmd: str, The mpi-specific syntax needed. For example: 'mpirun --host {hostname} -np {nproc} {cmd}' teams_exe_cmd_nproc: int, The number of cores per model/wrf_hydro simulation to be run. teams_node_file: dict = None, Optional file that acts like a node file. It is not currently implemented but the key specifies the scheduler format that the file follows. An example pbs node file is in tests/data and this argument is used here to test without a sched. env: dict = None, optional envionment to pass to the run. teams_dict: dict, Skip the arguments if you already have a teams_dict to use (backwards compatibility) Outputs: 0 for success.
- __init__(init_times: list, restart_dirs: list, forcing_dirs: list = [], ncores: int = 1)[source]
Instantiate a Cycle object. :Parameters: * init_times – A required list of datetime.datetime objects which specify the
restart time of each cast in the cycle. (Same for deterministic and ensemble cycle simultions).
restart_dirs – Deterministic: a required list of either strings or pathlib.Path objects. Ensemble: a required list of lists. The outer list is for the cycles
“casts” requested in init_times. The inner list is for each ensemble member in the cast.
The following rules are applied to the individual entires: 1) A dot or a null string (are identical pathlib.Path objects and) mean
“do nothing” with respect to the default path in the domain.
An existing path/file is used/kept (a non-existent path is not, gives an error).
A negative integer in units hours, pointing to a previous cast in the cycle.
Other wise, value error raised.
forcing_dirs – optional Deterministic: list of either strings or pathlib.Path objects Ensemble: A list of lists, as for restart_dirs. See restart_dirs for usage rules.
ncores – integer number of cores for running parallelizable methods (not the casts themselves). For an ensemble cycle, setting this value > 1 will force the ensemble.ncores = 1.
Methods
__init__(init_times, restart_dirs[, ...])Instantiate a Cycle object. :Parameters: * init_times -- A required list of datetime.datetime objects which specify the restart time of each cast in the cycle. (Same for deterministic and ensemble cycle simultions). * restart_dirs -- Deterministic: a required list of either strings or pathlib.Path objects. Ensemble: a required list of lists. The outer list is for the cycles "casts" requested in init_times. The inner list is for each ensemble member in the cast. The following rules are applied to the individual entires: 1) A dot or a null string (are identical pathlib.Path objects and) mean "do nothing" with respect to the default path in the domain. 2) An existing path/file is used/kept (a non-existent path is not, gives an error). 3) A negative integer in units hours, pointing to a previous cast in the cycle. 4) Other wise, value error raised. * forcing_dirs -- optional Deterministic: list of either strings or pathlib.Path objects Ensemble: A list of lists, as for restart_dirs. See restart_dirs for usage rules. * ncores -- integer number of cores for running parallelizable methods (not the casts themselves). For an ensemble cycle, setting this value > 1 will force the ensemble.ncores = 1.
add(obj)Add an approparite object to an CycleSimulation, such as a Simulation, Job, or Scheduler.
compose([symlink_domain, force, ...])Cycle compose (directories and files to disk) :Parameters: * symlink_domain -- Symlink the domain files rather than copy * force -- Compose into directory even if not empty. This is considered bad practice but * is necessary in certain circumstances. * rm_casts_from_memory -- Most applications will remove the casts from the * ensemble object upon compose. Testing and other reasons may keep them around. * check_nlst_warn -- Allow the namelist checking/validation to only result in warnings. * This is also not great practice, but necessary in certain circumstances..
pickle(path)Pickle ensemble sim object to specified file path :Parameters: path -- The file path for pickle
rm_casts()Remove members from memory, replace with their paths.
run([n_concurrent, teams, teams_exe_cmd, ...])Run the cycle of simulations. Inputs: n_concurrent: int = 1, Only used for non-team runs. teams: bool = False, Use teams? teams_exe_cmd: str, The mpi-specific syntax needed. For example: 'mpirun --host {hostname} -np {nproc} {cmd}' teams_exe_cmd_nproc: int, The number of cores per model/wrf_hydro simulation to be run. teams_node_file: dict = None, Optional file that acts like a node file. It is not currently implemented but the key specifies the scheduler format that the file follows. An example pbs node file is in tests/data and this argument is used here to test without a sched. env: dict = None, optional envionment to pass to the run. teams_dict: dict, Skip the arguments if you already have a teams_dict to use (backwards compatibility) Outputs: 0 for success.
Attributes
castsa list of 'casts' which are the individual simulations in the cycle object.
ncoresinteger number of cores for running parallelizable methods.