Skip to content

API reference

MOBIDICpy provides a comprehensive Python API for distributed hydrological modeling. The API is organized into functional modules for easy navigation and usage.

Overview

The MOBIDICpy public API is designed to be simple and functional, exposing only the essential functions needed for preprocessing, configuration, and model setup.

API modules

Configuration

Load and validate YAML configuration files using Pydantic schemas, and configure logging behavior.

GIS data I/O

Read and write geospatial data (rasters and vectors).

Grid operations

Process and transform gridded data (resolution decimation, flow direction conversion).

River network processing

Build and process river network topology with Strahler ordering and routing parameters.

Hillslope-reach mapping

Connect hillslope grid cells to river reaches for lateral flow routing.

Meteorological preprocessing

Convert meteorological data from various formats to CF-compliant NetCDF, and generate synthetic design storm hyetographs.

Data I/O

Consolidated I/O for preprocessed MOBIDIC data.

Preprocessing workflow

High-level workflow orchestrating the complete preprocessing pipeline.

Soil water balance

Hillslope water balance with four reservoir model (capillary, gravitational, plants, surface).

Routing

Hillslope and channel routing algorithms for water propagation.

Simulation

Main simulation engine and time-stepping loop.

State I/O

Save and load simulation state variables (NetCDF format).

Report I/O

Export discharge and lateral inflow time series.

Calibration

Model calibration, global sensitivity analysis, and uncertainty quantification using PEST++.

Requires optional dependencies: pip install "mobidicpy[calibration]" && get-pestpp :pyemu

Quick import

All core APIs are available from the top-level mobidic package. The calibration module is under mobidic.calibration:

from mobidic import (
    # Configuration
    load_config,
    MOBIDICConfig,
    configure_logger,
    configure_logger_from_config,
    # GIS I/O
    grid_to_matrix,
    read_shapefile,
    # Grid Operations
    decimate_raster,
    decimate_flow_direction,
    # River Network
    process_river_network,
    save_network,
    load_network,
    # Hillslope-Reach Mapping
    compute_hillslope_cells,
    map_hillslope_to_reach,
    # Meteorological Data
    MeteoData,
    MeteoRaster,
    HyetographGenerator,
    convert_mat_to_netcdf,
    # Data I/O
    GISData,
    save_gisdata,
    load_gisdata,
    # Preprocessing Workflow
    run_preprocessing,
    # Soil Water Balance
    soil_mass_balance,
    capillary_rise,
    # Routing
    hillslope_routing,
    linear_channel_routing,
    # Reservoirs
    process_reservoirs,
    Reservoir,
    Reservoirs,
    load_reservoirs,
    save_reservoirs,
    # Simulation
    Simulation,
    SimulationState,
    SimulationResults,
    # State I/O
    StateWriter,
    load_state,
    MeteoWriter,
    # Report I/O
    save_discharge_report,
    save_lateral_inflow_report,
    load_discharge_report,
    # Constants
    constants,
)

Development status

MOBIDICpy’s currently implemented features (v0.1):

  • Configuration system
  • GIS data I/O
  • Grid operations
  • River network processing
  • Hillslope-reach mapping
  • Meteorological preprocessing (station data, raster forcing, hyetograph generation)
  • Data I/O and consolidation
  • Complete preprocessing workflow
  • Soil water balance (4 reservoirs: capillary, gravitational, plants, surface)
  • Linear routing (hillslope + channel)
  • Reservoir module (preprocessing, routing, time-varying regulation)
  • Simulation engine (basic)
  • State I/O (NetCDF)
  • Report I/O (CSV/Parquet discharge time series)
  • Calibration and sensitivity analysis (PEST++ coupling via pyemu)

Coming soon:

  • Energy balance module (1L, 5L schemes, Snow)
  • Groundwater models (Linear, Linear_mult, Dupuit, MODFLOW)
  • Advanced routing (Muskingum-Cunge)
  • Meteorological data gap filling and quality control
  • CLI interface