β’ Loading Options Overview
β’ Sources/Sinks vs External Fluxes
Section 01: JSON Inline Format
β’ JSON Configuration
β’ Inline Data Examples
Section 02: CSV/ASCII Files
β’ External File Format
β’ Time Series Data
Section 03: HDF5 Coupling
β’ Model Integration
Section 04: Land Use Based Loading
β’ LULC with Static Coefficients
β’ LULC with Dynamic Coefficients
Section 05: Machine Learning
β’ ML Model Predictions
β’ Temporal Patterns & Wildcards
β’ Discrete vs Continuous Loads
β’ Master Configuration
OpenWQ supports five methods for defining sources/sinks and external fluxes:
Data embedded directly in config files
External time series files
Upstream model coupling
Copernicus land use export coefficients
XGBoost/RF predictions from monitoring data
Direct mass addition or removal from a compartment
Concentration in water entering from external sources
JSON Embed time series directly in the configuration file
{
"1": {
"CHEMICAL_NAME": "NO3_N",
"COMPARTMENT_NAME": "SOIL",
"TYPE": "source",
"UNITS": "kg",
"DATA_FORMAT": "JSON",
"DATA": {
// [YYYY, MM, DD, HH, MIN, SEC, ix, iy, iz, load, load_type, time_units]
"1": [2020, 4, 15, 8, 0, 0, "all", "all", 1, 50.0, "discrete"],
"2": [2020, "all", "all", "all", "all", "all", "all", "all", 1, 0.5, "continuous", "day"]
}
}
}
| YYYY, MM, DD... | Date/time (or "all") |
| ix, iy, iz | Spatial indices (or "all") |
| load | Value in specified units |
| load_type | "discrete" or "continuous" |
"all" for time β recurring pattern"all" for space β entire dimension
CSV Reference external time series files for large datasets
{
"1": {
"CHEMICAL_NAME": "NO3_N",
"COMPARTMENT_NAME": "RIVER",
"TYPE": "source",
"UNITS": "kg/day",
"DATA_FORMAT": "ASCII",
"DATA": {
"FILEPATH": "loads.csv",
"DELIMITER": ","
}
}
}
# Loading data for point source
YYYY,MM,DD,HH,MIN,SEC,ix,iy,iz,load,load_type
2020,1,1,0,0,0,1,1,1,10.5,continuous
2020,1,2,0,0,0,1,1,1,11.2,continuous
2020,1,3,0,0,0,1,1,1,9.8,continuous
...
HDF5 Couple with upstream model output (External Water Fluxes only)
{
"1": {
"DATA_FORMAT": "HDF5",
"UNITS": "mg/L",
"CHEMICAL_NAME": "NO3_N",
// Upstream model info
"EXTERNAL_COMPARTMENT_NAME": "ATMOSPHERE",
"EXTERNAL_INPUTFLUX_NAME": "PRECIP",
// Spatial interface
"INTERACTION_INTERFACE": ["all", "all", 1],
// Time interpolation
"INTERPOLATION": "LINEAR",
"FOLDERPATH": "upstream_output/"
}
}
| STEP | Previous value (zero-order) |
| NEAREST | Closest timestamp |
| LINEAR | Linear interpolation |
LULC Calculate loads from Copernicus land use data and export coefficients
Copernicus LULC NetCDF Basin Shapefile Export Coefficients
βββββββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββββββ
β β’ Land cover class β + β β’ HRU polygons β + β β’ Cropland: 15 kg/haβ
β β’ Annual maps β β β’ Reach IDs β β β’ Forest: 2 kg/ha β
β β’ 300m resolution β β β β β’ Urban: 8 kg/ha β
ββββββββββββ¬βββββββββββ ββββββββββ¬βββββββββ ββββββββββββ¬βββββββββββ
β β β
ββββββββββββββββββββ¬ββββββββββ΄ββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β Per-HRU Annual Loads (CSV) β
β Load = Ξ£(Area Γ Coeff) β
βββββββββββββββββββββββββββββββ
LULC+Climate Extend static method with monthly precipitation and temperature scaling
| Parameter | Description | Default |
|---|---|---|
| Pm | Monthly precipitation | mm |
| Ξ± | Precip scaling power | 1.0 |
| Q10 | Temperature coefficient | 2.0 |
| Tref | Reference temperature | 15Β°C |
Annual load is distributed across months based on climate weights:
ML Train XGBoost or Random Forest on monitoring data to predict loads
Monitoring CSV ML Training OpenWQ Input
βββββββββββββββββββββββ βββββββββββββββββββββββ βββββββββββββββββββββββ
β date, discharge, β β β’ Feature engineer β β β’ JSON with β
β precip, temp, ββββββββββΆβ β’ Train XGBoost/RF ββββββββββΆβ predicted loads β
β NO3-N, TP, ... β β β’ Validate (RΒ², RMSE)β β β’ Model files (.txt)β
βββββββββββββββββββββββ βββββββββββββββββββββββ βββββββββββββββββββββββ
date,discharge_m3s,precip_mm,temp_c,NO3-N,TP
2018-01-01,15.2,3.5,-2.1,2.3,0.05
2018-01-02,14.8,0.0,-3.5,2.1,0.04
...
ml_model_NO3-N.txt β trained modelml_model_features.json β config
Use "all" wildcards to create recurring patterns without repeating data:
| Pattern | Data Row | Meaning |
|---|---|---|
| Single event | [2020, 4, 15, 8, 0, 0, ...] |
April 15, 2020 at 8:00 AM |
| Every year | ["all", 4, 15, 8, 0, 0, ...] |
April 15 at 8:00 AM every year |
| Every month | [2020, "all", 15, 8, 0, 0, ...] |
15th of each month in 2020 |
| Every day | [2020, 4, "all", 8, 0, 0, ...] |
Every day at 8:00 AM in April 2020 |
| Continuous | [2020, "all", "all", "all", "all", "all", ..., "continuous", "day"] |
Steady load throughout 2020 |
"all" for ix, iy, iz) for watershed-wide loads
Applies entire load value at a specific instant
// 50 kg applied on April 15 at 8 AM [2020, 4, 15, 8, 0, 0, "all", "all", 1, 50.0, "discrete"]
Distributes load evenly over a time period
// 0.5 kg/day throughout April [2020, 4, "all", "all", "all", "all", "all", "all", 1, 0.5, "continuous", "day"]
Register loading files in the master JSON under OPENWQ_INPUT:
{
"OPENWQ_INPUT": {
"CONFIG_FILEPATH": "openwq_config.json",
"SINK_SOURCE": {
"1": { "LABEL": "Fertilizer", "FILEPATH": "fertilizer_loads.json" },
"2": { "LABEL": "WWTP", "FILEPATH": "point_sources.json" },
"3": { "LABEL": "Diffuse", "FILEPATH": "lulc_loads.json" }
},
"EXTERNAL_WATER_FLUXES": {
"1": { "LABEL": "Precipitation", "FILEPATH": "precip_conc.json" },
"2": { "LABEL": "Upstream", "FILEPATH": "upstream_hdf5.json" }
}
}
}
| Method | Format | Best For | Complexity |
|---|---|---|---|
| JSON | Inline data | Small datasets, quick setup | Low |
| CSV | External files | Long time series, existing data | Low |
| HDF5 | Binary arrays | Model coupling, large grids | Medium |
| LULC | Satellite + coeffs | Diffuse sources, scenarios | Medium |
| ML | Trained model | Data-rich sites, gap-filling | High |