Forecast Hydrological Tutorial

Running the model

Plotting hydrological forecast is done by running this command in the terminal:

# replace "input.json" with the path to your input json
python -m cuwalid.forecasting.main_hydro_forecast input.json

Or you can import the function into your code like this:

from cuwalid.forecasting.main_hydro_forecast import run_hydro_forecast

# replace "input.json" with the path to your input json
run_hydro_forecast("input.json")

Input Parameters

The input JSON shown above will look something like this:

 1{
 2    "run_hindcast": true,
 3    "run_forecast": true,
 4    "run_plotting":true,
 5
 6    "hindcast_model_name": "HAD_IMERGba_sim0",
 7    "forecast_model_name": "MAM_2022_realization_test",
 8    "model_path": "/home/cuwalid/training/historical/regional/outputs/",
 9    "postpp_path": "/home/aquichimbo/training/historical/regional/postpp/",
10    "threshold_path": "/home/aquichimbo/training/historical/regional/postpp/netcdf/HAD_IMERGba_sim0_MAM_extremes_quantiles.nc",
11    "dataset_path": "/path/to/dataset",
12    "season": ["MAM"],
13    "start_year": 2003,
14    "end_year": 2023,
15    "variables": {
16        "pre": true,
17        "pet": true,
18        "aet": true,
19        "tht": true,
20        "egw": true,
21        "inf": false,
22        "run": false,
23        "rch": true,
24        "fch": true,
25        "gdh": false,
26        "dis": true,
27        "tls": false,
28        "wte": true,
29        "twsc": true,
30        "wrsi": false
31    }
32}

Here is an explanation of what each parameter does:

  • run_hindcast: A boolean value that specifies whether to run the hindcast simulation. Set to true to enable this step.

  • run_forecast: A boolean value that specifies whether to run the forecast simulation. Set to true to enable this step.

  • run_plotting: A boolean value that specifies whether to generate plots from the forecast and hindcast simulations. Set to true to enable plotting.

  • hindcast_model_name: The name of the model used for the hindcast simulation. In this case, the hindcast model is named “HAD_IMERGba_sim0”.

  • forecast_model_name: The name of the model used for the forecast simulation. In this example, the forecast model is named “MAM_2022_realization_test”.

  • model_path: The directory path where the model’s outputs (hindcast and forecast data) are stored. It should point to the location containing the regional model output files.

  • postpp_path: Specifies the path to the directory where the post-processing files are stored. This path is used after the hindcast and forecast simulations are complete for further analysis.

  • threshold_path: The path to the NetCDF file containing threshold data used for defining extreme weather conditions. For example, it helps in classifying conditions like floods or droughts. In the file name, replace specific indicators (e.g., year) with placeholders like YYYY to handle multiple time periods automatically.

  • dataset_path: The directory where the dataset used in the simulation is located. This typically contains observational or gridded data required for the model.

  • season: A list that specifies the seasons for which the forecast or hindcast is being generated. For example, “MAM” refers to the March-April-May season.

  • start_year: The starting year for the hindcast or forecast simulation. Defines the earliest year included in the analysis.

  • end_year: The ending year for the hindcast or forecast simulation. Defines the most recent year included in the analysis.

  • variables: A dictionary that specifies which variables are included in the simulation. Each key is a variable name, and the value is a boolean indicating whether it is active (true) or inactive (false).

    • pre: A boolean indicating whether precipitation (pre) is included in the simulation.

    • pet: A boolean indicating whether potential evapotranspiration (pet) is included.

    • aet: A boolean indicating whether actual evapotranspiration (aet) is included.

    • tht: A boolean indicating whether total heat (tht) is included.

    • egw: A boolean indicating whether groundwater evaporation (egw) is included.

    • inf: A boolean indicating whether infiltration (inf) is included.

    • run: A boolean indicating whether surface runoff (run) is included.

    • rch: A boolean indicating whether recharge (rch) is included.

    • fch: A boolean indicating whether flow from catchment (fch) is included.

    • gdh: A boolean indicating whether groundwater depth (gdh) is included.

    • dis: A boolean indicating whether discharge (dis) is included.

    • tls: A boolean indicating whether total land surface temperature (tls) is included.

    • wte: A boolean indicating whether water table elevation (wte) is included.

    • twsc: A boolean indicating whether terrestrial water storage change (twsc) is included.

    • wrsi: A boolean indicating whether water requirement satisfaction index (wrsi) is included.