ravenpy package

A Python package to help run Raven, the hydrologic modelling framework.

Subpackages

Submodules

ravenpy.__version__ module

ravenpy.ravenpy module

Main module.

class ravenpy.ravenpy.Emulator(config: Config, workdir: str | PathLike | None = None, modelname: str | None = None, overwrite: bool = False)[source]

Bases: object

property config: Config

Read-only model configuration.

property modelname: str

File name stem of configuration files.

property output: OutputReader

Return simulation output object.

property output_path: Path | None

Path to model outputs.

resume(timestamp: bool = True) Config[source]

Return new model configuration using state variables from the end of the run.

timestamp: bool

If False, ignore time stamp information in the solution. If True, the solution will set StartDate to the solution’s timestamp.

run(overwrite: bool = False) OutputReader[source]

Run the model. This will write RV files if not already done.

Parameters:

overwrite (bool) – If True, overwrite existing files.

property workdir: Path

Path to RV files and output subdirectory.

class ravenpy.ravenpy.EnsembleReader(*, run_name: str | None = None, paths: List[str | PathLike] | None = None, runs: List[OutputReader] | None = None, dim: str = 'member')[source]

Bases: object

property files
property hydrograph
property storage
class ravenpy.ravenpy.OutputReader(run_name: str | None = None, path: str | Path | None = None)[source]

Bases: object

property diagnostics: dict | None

Return model diagnostics.

property files: dict

Return paths to output files.

property hydrograph: Dataset

Return the hydrograph.

property messages: str | None
property path: Path

Path to output directory.

property solution: dict | None

Return solution file content.

property storage: Dataset

Return the storage variables.

exception ravenpy.ravenpy.RavenError[source]

Bases: Exception

This is an error that is meant to be raised whenever a message of type “ERROR” is found in the Raven_errors.txt file resulting from a Raven (i.e. the C program) run.

exception ravenpy.ravenpy.RavenWarning[source]

Bases: Warning

This is a warning corresponding to a message of type “WARNING” in the Raven_errors.txt file resulting from a Raven (i.e. the C program) run.

ravenpy.ravenpy.run(modelname: str, configdir: str | Path, outputdir: str | Path | None = None, overwrite: bool = True, verbose: bool = False) Path[source]

Run Raven given the path to an existing model configuration.

Parameters:
  • modelname (str) – Configuration files stem, i.e. the file name without extension.

  • configdir (Path or str) – Path to configuration files directory.

  • outputdir (Path or str, optional) – Path to model simulation output. If None, will write to configdir/output.

  • overwrite (bool) – If True, overwrite existing files.

  • verbose (bool) – If True, always display Raven warnings. If False, warnings will only be printed if an error occurs.

Returns:

Path to model outputs.

Return type:

Path