Skip to content

Stochastic Generation

Salvador Navas edited this page Jul 2, 2026 · 1 revision

Stochastic Generation

Package: pyhydra.climate.stochastic_generation

This package separates the Python API from the optional stochastic libraries it uses. NEOPRENE is the library used for NSRP/STNSRP precipitation models. CoSMoS_py is used for CoSMoS-based time-series and spatial-field generation.

Point Rainfall and Time-Series Generation

Main APIs from point.py:

  • NSRPModel
  • analyze_ts
  • report_ts
  • simulate_ts
  • generate_ts
  • fit_distribution
  • fit_acs

NSRPModel wraps NEOPRENE workflows for point rainfall generation. The general time-series helpers use CoSMoS-style statistical fitting and simulation when the dependency is available.

Multi-Site Precipitation

Main API from spatial.py:

  • STNSRPModel

STNSRPModel wraps NEOPRENE STNSRP workflows for spatially distributed precipitation generation.

Spatial Random Fields

Main APIs from fields.py:

  • SpatialFieldModel
  • fit_spatial_model
  • generate_random_field
  • generate_random_field_fast
  • check_random_field

These functions support CoSMoS-based spatial random-field fitting and simulation.

Dependency Notes

The optional dependencies are intentionally loaded lazily. If a workflow needs NEOPRENE or CoSMoS_py and the package is missing, pyhydra raises an import error at the point of use.

This distinction matters in publications and documentation:

  • NSRP and STNSRP are stochastic rainfall model families implemented through NEOPRENE.
  • CoSMoS is used through CoSMoS_py.
  • pyhydra provides wrappers, configuration helpers and workflow integration, not a reimplementation of those external libraries.

Recommended Practice

  • Fix random seeds in experiments where reproducibility matters.
  • Store generated model parameters and YAML configuration files.
  • Archive input time series and calibration periods.
  • Report which optional library and version were used.
  • Validate simulated moments, autocorrelation and extremes against observations.

Clone this wiki locally