wrfhydropy.core package¶
Submodules¶
wrfhydropy.core.domain module¶
-
class
wrfhydropy.core.domain.Domain(domain_top_dir: str, domain_config: str, compatible_version: str = None, hydro_namelist_patch_file: str = 'hydro_namelist_patches.json', hrldas_namelist_patch_file: str = 'hrldas_namelist_patches.json')[source]¶ Bases:
objectClass for a WRF-Hydro domain, which constitutes all domain-specific files needed for a setup.
Methods
copy_files(self, dest_dir, symlink)Copy domain files to a new directory :Parameters: * dir – The destination directory for domain files * symlink – Symlink domain files instead of copy -
compatible_version= None¶ Source-code version for which the domain is to be used.
Type: str
-
copy_files(self, dest_dir:str, symlink:bool=True)[source]¶ Copy domain files to a new directory :Parameters: * dir – The destination directory for domain files
- symlink – Symlink domain files instead of copy
-
domain_config= None¶ Specified configuration for which the domain is to be used, e.g. ‘NWM_ana’
Type: str
-
forcing_dir= None¶ path to the forcing directory
Type: pathlib.Path
-
hydro_files= None¶ Files specified in hydro_nlist section of the domain namelist patches
Type: list
-
lsm_files= None¶ Files specified in noahlsm_offline section of the domain namelist patches
Type: list
-
nudging_dir= None¶ path to the nudging obs directory
Type: pathlib.Path
-
nudging_files= None¶ Files specified in nudging_nlist section of the domain namelist patches
Type: list
-
wrfhydropy.core.ensemble module¶
-
class
wrfhydropy.core.ensemble.EnsembleSimulation(ncores: int = 1)[source]¶ Bases:
objectClass for a WRF-Hydro EnsembleSimulation object. The Ensemble Simulation object is used to orchestrate a set of ‘N’ WRF-Hydro simulations. It requires members with pre-compiled models and there are set and get methods across the ensemble (member_diffs & set_member_diffs). Jobs and scheduler set on the EnsembleSimulation object are set on all the members.
Attributes: - N
member_diffsGet method for ensemble member differences.
Methods
add(self, obj, …)Add an approparite object to an EnsembleSimulation, such as a Simulation, Job, or Scheduler. compose(self, symlink_domain, force, …)Ensemble compose simulation directories and files :Parameters: * symlink_domain – Symlink the domain files rather than copy * force – Compose into directory even if not empty. pickle(self, path)Pickle ensemble sim object to specified file path :Parameters: path – The file path for pickle replicate_member(self, N, copy_members)restore_members(self, ens_dir, recursive)Restore members from disk, replace paths with the loaded pickle. rm_members(self)Remove members from memory, replace with their paths. run(self, n_concurrent, teams, …)Run the ensemble of simulations. set_member_diffs(self, att_tuple, values)Set method for ensemble member differences. collect -
N¶
-
add(self, obj:Union[list, wrfhydropy.core.schedulers.Scheduler, wrfhydropy.core.job.Job])[source]¶ Add an approparite object to an EnsembleSimulation, such as a Simulation, Job, or Scheduler. :Parameters: obj – the object to add.
-
compose(self, symlink_domain:bool=True, force:bool=False, check_nlst_warn:bool=False, rm_members_from_memory:bool=True)[source]¶ Ensemble compose simulation directories and files :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_members_from_memory – Most applications will remove the members 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.
-
jobs= None¶ a list containing Job objects
Type: list
-
member_diffs¶ Get method for ensemble member differences. Only differences are reported.
-
members= None¶ a list of simulations which are the members of the ensemble.
Type: list
-
ncores= None¶ integer number of cores for running parallelizable methods.
Type: ncores
-
pickle(self, path:str)[source]¶ Pickle ensemble sim object to specified file path :Parameters: path – The file path for pickle
-
restore_members(self, ens_dir:pathlib.Path=None, recursive:bool=True)[source]¶ Restore members from disk, replace paths with the loaded pickle.
-
run(self, n_concurrent:int=1, teams:bool=False, teams_exe_cmd:str=None, teams_exe_cmd_nproc:int=None, teams_node_file:dict=None, env:dict=None, teams_dict:dict=None)[source]¶ Run the ensemble 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)Returns: 0 for success.
-
wrfhydropy.core.ensemble.parallel_compose(arg_dict)[source]¶ Parallelizable function to compose an EnsembleSimuation.
-
wrfhydropy.core.ensemble.parallel_compose_addjobs(arg_dict)[source]¶ Parallelizable function to add jobs to EnsembleSimuation.
wrfhydropy.core.ensemble_tools module¶
-
class
wrfhydropy.core.ensemble_tools.DeepDiffEq(t1, t2, eq_types, ignore_order=False, report_repetition=False, significant_digits=None, exclude_paths={}, exclude_types={}, verbose_level=1, view='text', **kwargs)[source]¶ Bases:
deepdiff.diff.DeepDiffExtend Deep Diff to handle __eq__ for specified types.
Attributes: - json
Methods
cleanup(self)Remove empty keys from this object. clear()copy()fromkeys(iterable[, value])Returns a new dict with keys from iterable and values equal to value. get()items()keys()pop()If key is not found, d is returned if given, otherwise KeyError is raised popitem()2-tuple; but raise KeyError if D is empty. setdefault()update()If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k] values()from_json
-
wrfhydropy.core.ensemble_tools.dictify(obj)[source]¶ Recursively transform deepcopy sub __dicts__ of an object into dicts for dictionary traversal of a deepcopy of the object.
-
wrfhydropy.core.ensemble_tools.get_ens_dotfile_end_datetime(run_dir)[source]¶ Use the the .model_end_time files to get the current ensemble time.
-
wrfhydropy.core.ensemble_tools.get_sub_objs(obj)[source]¶ Identify which attributes of an object are objects with __dicts__.
wrfhydropy.core.ioutils module¶
-
class
wrfhydropy.core.ioutils.WrfHydroStatic[source]¶ Bases:
pathlib.PosixPathWRF-Hydro static data class
Attributes: anchorThe concatenation of the drive and root, or ‘’.
driveThe drive prefix (letter or UNC path), if any.
nameThe final path component, if any.
parentThe logical parent of the path.
parentsA sequence of this path’s logical parents.
partsAn object providing sequence-like access to the components in the filesystem path.
rootThe root of the path, if any.
stemThe final path component, minus its last suffix.
suffixThe final component’s last suffix, if any.
suffixesA list of the final component’s suffixes, if any.
Methods
absolute(self)Return an absolute version of this path. as_posix(self)Return the string representation of the path with forward (/) slashes. as_uri(self)Return the path as a ‘file’ URI. check_nans(self)Return dictionary of counts of NA values for each data variable chmod(self, mode)Change the permissions of the path, like os.chmod(). cwd()Return a new path pointing to the current working directory (as returned by os.getcwd()). exists(self)Whether this path exists. expanduser(self)Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser) glob(self, pattern)Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given pattern. group(self)Return the group name of the file gid. home()Return a new path pointing to the user’s home directory (as returned by os.path.expanduser(‘~’)). is_absolute(self)True if the path is absolute (has both a root and, if applicable, a drive). is_block_device(self)Whether this path is a block device. is_char_device(self)Whether this path is a character device. is_dir(self)Whether this path is a directory. is_fifo(self)Whether this path is a FIFO. is_file(self)Whether this path is a regular file (also True for symlinks pointing to regular files). is_reserved(self)Return True if the path contains one of the special names reserved by the system, if any. is_socket(self)Whether this path is a socket. is_symlink(self)Whether this path is a symbolic link. iterdir(self)Iterate over the files in this directory. joinpath(self, \*args)Combine this path with one or several arguments, and return a new path representing either a subpath (if all arguments are relative paths) or a totally different path (if one of the arguments is anchored). lchmod(self, mode)Like chmod(), except if the path points to a symlink, the symlink’s permissions are changed, rather than its target’s. lstat(self)Like stat(), except if the path points to a symlink, the symlink’s status information is returned, rather than its target’s. match(self, path_pattern)Return True if this path matches the given pattern. mkdir(self[, mode, parents, exist_ok])Create a new directory at this given path. open(self)Open a WrfHydroStatic object :Parameters: self owner(self)Return the login name of the file owner. read_bytes(self)Open the file in bytes mode, read it, and close the file. read_text(self[, encoding, errors])Open the file in text mode, read it, and close the file. relative_to(self, \*other)Return the relative path to another path identified by the passed arguments. rename(self, target)Rename this path to the given path. replace(self, target)Rename this path to the given path, clobbering the existing destination if it exists. resolve(self[, strict])Make the path absolute, resolving all symlinks on the way and also normalizing it (for example turning slashes into backslashes under Windows). rglob(self, pattern)Recursively yield all existing files (of any kind, including directories) matching the given pattern, anywhere in this subtree. rmdir(self)Remove this directory. samefile(self, other_path)Return whether other_path is the same or not as this file (as returned by os.path.samefile()). stat(self)Return the result of the stat() system call on this path, like os.stat() does. symlink_to(self, target[, target_is_directory])Make this path a symlink pointing to the given path. touch(self[, mode, exist_ok])Create this file with the given access mode, if it doesn’t exist. unlink(self)Remove this file or link. with_name(self, name)Return a new path with the file name changed. with_suffix(self, suffix)Return a new path with the file suffix changed. write_bytes(self, data)Open the file in bytes mode, write to it, and close the file. write_text(self, data[, encoding, errors])Open the file in text mode, write to it, and close the file.
-
class
wrfhydropy.core.ioutils.WrfHydroTs[source]¶ Bases:
listWRF-Hydro netcdf timeseries data class
Methods
append()check_nans(self)Return dictionary of counts of NA values for each data variable summed across files clear()copy()count()extend()index()Raises ValueError if the value is not present. insert()L.insert(index, object) – insert object before index open(self, chunks, forecast)Open a WrfHydroTs object :Parameters: * self * chunks – chunks argument passed on to xarray.DataFrame.chunk() method * forecast – If forecast the reference time dimension is retained, if not then * reference_time dimension is set to a dummy value (1970-01-01) * and analysis pop()Raises IndexError if list is empty or index is out of range. remove()Raises ValueError if the value is not present. reverse()L.reverse() – reverse IN PLACE sort()-
check_nans(self)[source]¶ Return dictionary of counts of NA values for each data variable summed across files
-
open(self, chunks:dict=None, forecast:bool=True)[source]¶ Open a WrfHydroTs object :Parameters: * self
- chunks – chunks argument passed on to xarray.DataFrame.chunk() method
- forecast – If forecast the reference time dimension is retained, if not then
- reference_time dimension is set to a dummy value (1970-01-01)
- and analysis
Returns: An xarray mfdataset object concatenated on dimension ‘Time’.
-
-
wrfhydropy.core.ioutils.check_file_nans(dataset_or_path:Union[str, pathlib.Path, xarray.core.dataset.Dataset], n_cores:int=1) → Union[pandas.core.frame.DataFrame, NoneType][source]¶ Opens the specified netcdf file and checks all data variables for NA values. NA assigned according to xarray __FillVal parsing. See xarray.Dataset documentation :Parameters: dataset_or_path – The path to the netcdf dataset file, or a dataset itself
Returns: string summary of nans if present
-
wrfhydropy.core.ioutils.check_input_files(hydro_namelist:dict, hrldas_namelist:dict, sim_dir:str, ignore_restarts:bool=False, check_nlst_warn:bool=False)[source]¶ Given hydro and hrldas namelists and a directory, check that all files listed in the namelist exist in the specified directory. :Parameters: * hydro_namelist – A wrfhydropy hydro_namelist dictionary
- hrldas_namelist – A wrfhydropy hydro_namelist dictionary
- file_str – A wrfhydropy hrldas_namelist dictionary
- sim_dir – The path to the directory containing input files.
- ignore_restarts – Ignore restart files.
- check_nlst_warn – Allow the namelist checking/validation to only result in warnings.
-
wrfhydropy.core.ioutils.nwm_forcing_to_ldasin(nwm_forcing_dir:Union[pathlib.Path, str], ldasin_dir:Union[pathlib.Path, str], range:str, copy:bool=False, forc_type=1)[source]¶ Convert nwm dir and naming format to wrf-hydro read format. :Parameters: * nwm_forcing_dir – the pathlib.Path or str for the source dir or a list of source
directories. If a pathlib.Path object or str is provided, it is assume that this single directory contains nwm.YYYYMMDDHH downloaded from NOMADS and that their subdirectory structure is unchanged. If a list of pathlib.Path (or str) is provided, these should be the desired nwm.YYYYMMDD to translate with no changed to their subdirectory structure.- ldasin_dir – the pathlib.Path or str for a new NONEXISTANT output dir.
- range – str range as on nomads in: analysis_assim, analysis_assim_extend, analysis_assim_hawaii, medium_range, short_range, short_range_hawaii
- copy – True or false. Default is false creates symlinks.
- forc_type – 1 (hour) or 2 (minute) formats are supported.
Returns: None on success.
-
wrfhydropy.core.ioutils.open_dart_dataset(paths:list, chunks:dict=None, spatial_indices:list=None, drop_variables:list=None, npartitions:int=None, attrs_keep:list=None) → xarray.core.dataset.Dataset[source]¶ - Open a multi-file ensemble wrf-hydro output dataset
- Args:
- paths: List ,iterable, or generator of file paths to wrf-hydro netcdf output files
- chunks: chunks argument passed on to xarray DataFrame.chunk() method preprocess_member: A function that identifies the member from the file or filename. attrs_keep: A list of the global attributes to be retained.
- Returns:
- An xarray dataset of dask arrays chunked by chunk_size along the feature_id dimension concatenated along the time and member dimensions.
-
wrfhydropy.core.ioutils.open_ensemble_dataset(paths:list, chunks:dict=None, preprocess_member:<built-in function callable>=<function preprocess_dart_member at 0x7fc120080510>, attrs_keep:list=None) → xarray.core.dataset.Dataset[source]¶ Open a multi-file ensemble wrf-hydro output dataset :Parameters: * paths – List ,iterable, or generator of file paths to wrf-hydro netcdf output files
- chunks – chunks argument passed on to xarray DataFrame.chunk() method
- preprocess_member – A function that identifies the member from the file or filename.
- attrs_keep – A list of the global attributes to be retained.
Returns: An xarray dataset of dask arrays chunked by chunk_size along the feature_id dimension concatenated along the time and member dimensions.
-
wrfhydropy.core.ioutils.open_nwm_dataset(paths:list, chunks:dict=None, attrs_keep:list=['featureType', 'proj4', 'station_dimension', 'esri_pe_string', 'Conventions', 'model_version'], spatial_indices:list=None, drop_variables:list=None, npartitions:int=None, profile:int=False) → xarray.core.dataset.Dataset[source]¶
-
wrfhydropy.core.ioutils.open_wh_dataset(paths:list, chunks:dict=None, forecast:bool=True) → xarray.core.dataset.Dataset[source]¶ Open a multi-file wrf-hydro output dataset :Parameters: * paths – List ,iterable, or generator of file paths to wrf-hydro netcdf output files
- chunks – chunks argument passed on to xarray DataFrame.chunk() method
- forecast – If forecast the reference time dimension is retained, if not then
- reference_time dimension is set to a dummy value (1970-01-01)
- and analysis
Returns: An xarray dataset of dask arrays chunked by chunk_size along the feature_id dimension concatenated along the time and reference_time dimensions
-
wrfhydropy.core.ioutils.preprocess_dart_data(path, chunks:dict=None, spatial_indices:list=None, drop_variables:list=None) → xarray.core.dataset.Dataset[source]¶
-
wrfhydropy.core.ioutils.preprocess_nwm_data(path, spatial_indices:list=None, drop_variables:list=None) → xarray.core.dataset.Dataset[source]¶
wrfhydropy.core.job module¶
-
class
wrfhydropy.core.job.Job(job_id: str, model_start_time: Union[str, datetime.datetime] = None, model_end_time: Union[str, datetime.datetime] = None, restart_freq_hr: Union[int, dict] = None, output_freq_hr: Union[int, dict] = None, restart: bool = True, restart_file_time: Union[str, datetime.datetime, dict] = None, restart_dir: Union[str, pathlib.Path, dict] = None, exe_cmd: str = None, entry_cmd: str = None, exit_cmd: str = None)[source]¶ Bases:
objectA Job represents run-time specific information for a given WRF-Hydro run. A Simulation consists of one or more jobs. For example, adding multiple Jobs can be used to split a Simulation into multiple runs to limit the wall-clock duration of each individual run.
Attributes: - hrldas_namelist
- hrldas_times
- hydro_namelist
- hydro_times
job_dirPath: Path to the run directory
model_end_timedatetime: The model time at the end of the execution.
model_start_timedatetime: The model time at the start of the execution.
Methods
clone(self, N)Clone a job object N-times using deepcopy. pickle(self, path)Pickle job object to specified file path :Parameters: path – The file path for pickle -
clone(self, N) → list[source]¶ Clone a job object N-times using deepcopy. :Parameters: N – The number of time to clone the Job
Returns: A list of Job objects
-
exit_status= None¶ The exit status of the model job parsed from WRF-Hydro diag files
Type: int
-
hrldas_namelist¶
-
hrldas_times¶
-
hydro_namelist¶
-
hydro_times¶
-
job_dir¶ Path to the run directory
Type: Path
-
job_id= None¶ The job id.
Type: str
-
model_end_time¶ The model time at the end of the execution.
Type: datetime
-
model_start_time¶ The model time at the start of the execution.
Type: datetime
-
output_freq_hr_hrldas= None¶ Hrldas output write frequency in hours.
Type: int
-
output_freq_hr_hydro= None¶ Hydro output write frequency in hours.
Type: int
-
pickle(self, path:str)[source]¶ Pickle job object to specified file path :Parameters: path – The file path for pickle
-
restart= None¶ Start model from a restart.
Type: bool
-
restart_file_time= None¶ Time on the restart file to use, if different from model_start_time. The path in any supplied restart file path in the namelists is preserved while modifying the date and time.
Type: np.datetime
-
restart_freq_hr_hrldas= None¶ Hrldas restart write frequency in hours.
Type: int
-
restart_freq_hr_hydro= None¶ Hydro restart write frequency in hours.
Type: int
wrfhydropy.core.model module¶
-
class
wrfhydropy.core.model.Model(source_dir: str, model_config: str, hydro_namelist_config_file: str = None, hrldas_namelist_config_file: str = None, compile_options_config_file: str = None, compiler: str = 'gfort', pre_compile_cmd: str = None, compile_options: dict = None)[source]¶ Bases:
objectClass for a WRF-Hydro model, which consitutes the model source code and compiled binary.
Methods
compile(self, compile_dir)Compiles WRF-Hydro using specified compiler and compile options. copy_files(self, dest_dir, symlink)Copy domain files to new directory :Parameters: * dest_dir – The destination directory for files * symlink – Symlink files instead of copy -
compile(self, compile_dir:pathlib.Path) → str[source]¶ Compiles WRF-Hydro using specified compiler and compile options. :Parameters: compile_dir – A non-existant directory to use for compilation.
Returns: Success of compilation and compile directory used. Sets additional attributes to WrfHydroModel
-
compile_dir= None¶ pathlib.Path object pointing to the compile directory.
Type: pathlib.Path
-
compile_log= None¶ The subprocess object generated at compile.
Type: CompletedProcess
-
compiler= None¶ The compiler chosen at compile time.
Type: str
-
configure_log= None¶ The subprocess object generated at configure.
Type: CompletedProcess
-
copy_files(self, dest_dir:str, symlink:bool=True)[source]¶ Copy domain files to new directory :Parameters: * dest_dir – The destination directory for files
- symlink – Symlink files instead of copy
-
git_hash= None¶ The git revision hash if seld.source_dir is a git repository
Type: str
-
model_config= None¶ Specified configuration for which the model is to be used, e.g. ‘nwm_ana’
Type: str
-
object_id= None¶ A unique id to join object to compile directory.
Type: str
-
pre_compile_cmd= None¶ Command string to be executed prior to model compilation, e.g. to load modules
Type: str
-
source_dir= None¶ pathlib.Path object for source code directory.
Type: pathlib.Path
-
version= None¶ Source code version from .version file stored with the source code.
Type: str
-
wrf_hydro_exe= None¶ pathlib.Path to wrf_hydro.exe file generated at compile-time.
Type: pathlib.Path
-
wrfhydropy.core.namelist module¶
-
class
wrfhydropy.core.namelist.JSONNamelist(file_path: str)[source]¶ Bases:
objectClass for a WRF-Hydro JSON namelist containing one more configurations
Methods
get_config(self, config)Get a namelist for a given configuration.
-
class
wrfhydropy.core.namelist.Namelist[source]¶ Bases:
dictClass for a WRF-Hydro namelist
Methods
clear()copy()fromkeys(iterable[, value])Returns a new dict with keys from iterable and values equal to value. get()items()keys()patch(self, patch)Recursively patch a namelist with key values from another namelist :Parameters: patch – A Namelist or dict object containing the patches pop()If key is not found, d is returned if given, otherwise KeyError is raised popitem()2-tuple; but raise KeyError if D is empty. setdefault()update()If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k] values()write(self, path[, mode])Write a namelist to file as a fortran-compatible namelist :Parameters: path – The file path
-
wrfhydropy.core.namelist.dict_merge(dct:dict, merge_dct:dict) → dict[source]¶ Recursive dict merge. Inspired by :meth:
dict.update(), instead of updating only top-level keys, dict_merge recurses down into dicts nested to an arbitrary depth, updating keys. Themerge_dctis merged intodct. :Parameters: * dct – dict onto which the merge is executed- merge_dct – dct merged into dct
Returns: The merged dict
-
wrfhydropy.core.namelist.diff_namelist(old_namelist:Union[wrfhydropy.core.namelist.Namelist, str], new_namelist:Union[wrfhydropy.core.namelist.Namelist, str], **kwargs) → dict[source]¶ Diff two Namelist objects or fortran 90 namelist files and return a dictionary of differences.
Parameters: - old_namelist – String containing path to the first namelist file, referred to as ‘old’ in
- outputs.
- new_namelist – String containing path to the second namelist file, referred to as ‘new’ in
- outputs.
- **kwargs – Additional arguments passed onto deepdiff.DeepDiff method
Returns: The differences between the two namelists
wrfhydropy.core.outputdiffs module¶
-
class
wrfhydropy.core.outputdiffs.OutputDataDiffs(candidate_output: wrfhydropy.core.simulation.SimulationOutput, reference_output: wrfhydropy.core.simulation.SimulationOutput, nccmp_options: list = None, exclude_vars: list = None, exclude_atts: list = None, xrcmp_n_cores: int = 0)[source]¶ Bases:
object-
channel_rt= None¶ List of pandas dataframes if possible or subprocess objects containing nudging restart file diffs
Type: list
-
channel_rt_grid= None¶ List of pandas dataframes if possible or subprocess objects containing nudging restart file diffs
Type: list
-
chanobs= None¶ List of pandas dataframes if possible or subprocess objects containing nudging restart file diffs
Type: list
-
diff_counts= None¶ Counts of diffs by restart type
Type: dict
-
gwout= None¶ List of pandas dataframes if possible or subprocess objects containing nudging restart file diffs
Type: list
-
lakeout= None¶ List of pandas dataframes if possible or subprocess objects containing nudging restart file diffs
Type: list
-
ldasout= None¶ List of pandas dataframes if possible or subprocess objects containing nudging restart file diffs
Type: list
-
restart_hydro= None¶ List of pandas dataframes if possible or subprocess objects containing hydro restart file diffs
Type: list
-
restart_lsm= None¶ List of pandas dataframes if possible or subprocess objects containing lsm restart file diffs
Type: list
-
restart_nudging= None¶ List of pandas dataframes if possible or subprocess objects containing nudging restart file diffs
Type: list
-
rtout= None¶ List of pandas dataframes if possible or subprocess objects containing nudging restart file diffs
Type: list
-
-
class
wrfhydropy.core.outputdiffs.OutputMetaDataDiffs(candidate_output: wrfhydropy.core.simulation.SimulationOutput, reference_output: wrfhydropy.core.simulation.SimulationOutput, stats_only=False, nccmp_options: list = None, exclude_vars: list = None, exclude_atts: list = None, xrcmp_n_cores: int = 0)[source]¶ Bases:
object-
channel_rt= None¶ List of pandas dataframes if possible or subprocess objects containing nudging restart file diffs
Type: list
-
chanobs= None¶ List of pandas dataframes if possible or subprocess objects containing nudging restart file diffs
Type: list
-
diff_counts= None¶ Counts of diffs by restart type
Type: dict
-
gwout= None¶ List of pandas dataframes if possible or subprocess objects containing nudging restart file diffs
Type: list
-
lakeout= None¶ List of pandas dataframes if possible or subprocess objects containing nudging restart file diffs
Type: list
-
ldasout= None¶ List of pandas dataframes if possible or subprocess objects containing nudging restart file diffs
Type: list
-
restart_hydro= None¶ List of pandas dataframes if possible or subprocess objects containing hydro restart file diffs
Type: list
-
restart_lsm= None¶ List of pandas dataframes if possible or subprocess objects containing lsm restart file diffs
Type: list
-
restart_nudging= None¶ List of pandas dataframes if possible or subprocess objects containing nudging restart file diffs
Type: list
-
rtout= None¶ List of pandas dataframes if possible or subprocess objects containing nudging restart file diffs
Type: list
-
-
wrfhydropy.core.outputdiffs.compare_ncfiles(candidate_files:list, reference_files:list, stats_only:bool=False, nccmp_options:list=None, exclude_vars:list=None, exclude_atts:list=None, xrcmp_n_cores:int=0)[source]¶ Compare lists of netcdf restart files element-wise. Files must have common names :Parameters: * candidate_files – List of candidate netcdf file paths
- reference_files – List of reference netcdf file paths
- stats_only – Only return statistics on differences in data values
- nccmp_options – List of long-form command line options passed to nccmp,
- see http – //nccmp.sourceforge.net/ for options. Defaults are ‘–metadata’, ‘–force’
- exclude_vars – A list of strings containing variables names to
- exclude from the comparison.
- exclude_atts – A list of strings containing attribute names to exclude from the
- comparison. Defaults are ‘valid_min’
Returns: A named list of either pandas dataframes if possible or subprocess objects
wrfhydropy.core.schedulers module¶
-
class
wrfhydropy.core.schedulers.PBSCheyenne(account: str, nproc: int, nnodes: int, mem: int = None, ppn: int = None, queue: str = 'regular', walltime: str = '12:00:00', email_who: str = None, email_when: str = 'abe', custom: dict = {})[source]¶ Bases:
wrfhydropy.core.schedulers.SchedulerA Scheduler object compatible with PBS on the NCAR Cheyenne system.
Attributes: - nnodes
- nproc
- ppn
Methods
schedule(self, jobs)Schedule one or more jobs using the scheduler scheduler :Parameters: jobs – list of jobs to schedule -
nnodes¶
-
nproc¶
-
ppn¶
wrfhydropy.core.simulation module¶
-
class
wrfhydropy.core.simulation.Simulation[source]¶ Bases:
objectClass for a WRF-Hydro Simulation object. The Simulation object is used to orchestrate a WRF-Hydro simulation by accessing methods of Model, Domain, and Job objects. Optionally, a scheduler can also be added.
Methods
add(self, obj, …)Add an approparite object to a Simulation, such as a Model, Domain, Job, or Scheduler collect(self[, sim_dir, output])Collect simulation output after a run compose(self, symlink_domain, force, …)Compose simulation directories and files :Parameters: * symlink_domain – Symlink the domain files rather than copy * force – Compose into directory even if not empty. pickle(self, path)Pickle sim object to specified file path :Parameters: path – The file path for pickle run(self, env)Run the composed simulation. pickle_sub_objs restore_sub_objs -
add(self, obj:Union[wrfhydropy.core.model.Model, wrfhydropy.core.domain.Domain, wrfhydropy.core.schedulers.Scheduler, wrfhydropy.core.job.Job])[source]¶ Add an approparite object to a Simulation, such as a Model, Domain, Job, or Scheduler
-
base_hrldas_namelist= None¶ base hrldas namelist produced from model and domain
Type: dict
-
base_hydro_namelist= None¶ base hydro namelist produced from model and domain
Type: dict
-
compose(self, symlink_domain:bool=True, force:bool=False, check_nlst_warn:bool=False)[source]¶ Compose simulation directories and files :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.
- check_nlst_warn – Allow the namelist checking/validation to only result in warnings.
- This is also not great practice, but necessary in certain circumstances.
-
jobs= None¶ a list containing Job objects
Type: list
-
output= None¶ A CompletedSim object returned by the self.collect() method
Type: CompletedSim
-
-
class
wrfhydropy.core.simulation.SimulationOutput[source]¶ Bases:
objectClass containing output objects from a completed Simulation, retrieved using the Simulation.collect() method
Methods
check_output_nans(self, n_cores)Check all outputs for NA values collect_output(self, sim_dir, pathlib.Path]=None)Collect simulation output after a run :Parameters: sim_dir – The simulation directory to collect open -
channel_rt= None¶ Timeseries dataset of CHRTOUT files
Type: WrfHydroTs
-
channel_rt_grid= None¶ Timeseries dataset of CHRTOUT gridded files
Type: WrfHydroTs
-
chanobs= None¶ Timeseries dataset of CHANOBS files
Type: WrfHydroTs
-
collect_output(self, sim_dir:Union[str, pathlib.Path]=None)[source]¶ Collect simulation output after a run :Parameters: sim_dir – The simulation directory to collect
-
gwout= None¶ Timeseries dataset of GWOUT files
Type: WrfHydroTs
-
lakeout= None¶ Timeseries dataset of LAKEOUT files
Type: WrfHydroTs
-
ldasout= None¶ Timeseries dataset of LDASOUT files
Type: WrfHydroTs
-
restart_hydro= None¶ List of HYDRO_RST WrfHydroStatic objects
Type: list
-
restart_lsm= None¶ List of RESTART WrfHydroStatic objects
Type: list
-
restart_nudging= None¶ List of nudgingLastObs WrfHydroStatic objects
Type: list
-
rtout= None¶ Timeseries dataset of RTOUT files
Type: WrfHydroTs
-