Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Release Notes

## Version 1.3.0 (not released yet)

- Introduced the `pySWATPlus.Calibration` class for parameter calibration using multi-objective optimization, evolutionary algorithms, and parallel computing.

- Added the `pySWATPlus.SensitivityAnalyzer.simulation_and_indices` method to compute sensitivity indices directly against observed data without saving detailed simulation results.


## Version 1.2.0 (October 13, 2025)

- All SWAT+ simulations with modified parameters are now configured through the `calibration.cal` file, eliminating the need to read and modify individual input files.
Expand Down Expand Up @@ -31,7 +38,6 @@
- Renamed `set_begin_and_end_date` to `set_simulation_period` for better consistency.



## Version 1.1.0 (August 26, 2025)

- Added a new class `pySWATPlus.SensitivityAnalyzer` to support sensitivity simulations with two main methods:
Expand Down
9 changes: 5 additions & 4 deletions docs/userguide/model_calibration.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ the calibration interface offers flexible options for optimizing model parameter


The interface provides a [`Calibration`](https://swat-model.github.io/pySWATPlus/api/calibration/) class that must be initialized with the required parameters.
This class includes the `parameter_optimization` method, which performs parameter optimization using multi-objective algorithms, evolutionary strategies, and parallel computation.
This class includes the [`parameter_optimization`](https://swat-model.github.io/pySWATPlus/api/calibration/#pySWATPlus.Calibration.parameter_optimization) method,
which performs parameter optimization using multi-objective algorithms, evolutionary strategies, and parallel computation.

The following code provides an example of optimizing flow discharge for both daily and monthly time-series data using multi-objective evolutionary computation.
The usage of both daily and monthly flow discharge is just for illustrative purposes on how multi-objective optimization can be performed. Users should replace monthly flow
discharge by nitorgen or phosporus concentration according to their needs.


```python
# Calibration parameter space
# Define parameter space
parameters = [
{
'name': 'esco',
Expand Down Expand Up @@ -84,7 +85,7 @@ observe_data = {
}

# Objective configuration
objectives = {
objective_config = {
'channel_sd_day.txt': {
'sim_col': 'flo_out',
'obs_col': 'discharge',
Expand All @@ -105,7 +106,7 @@ if __name__ == '__main__':
txtinout_dir=r"C:\Users\Username\project\Scenarios\Default\TxtInOut",
extract_data=extract_data,
observe_data=observe_data,
objectives=objectives,
objective_config=objective_config,
algorithm='NSGA2',
n_gen=2,
pop_size=5
Expand Down
77 changes: 77 additions & 0 deletions docs/userguide/sensitivity_interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,81 @@ output = pySWATPlus.SensitivityAnalyzer().parameter_sensitivity_indices(
indicators=['KGE', 'RMSE'],
json_file=r"C:\Users\Username\sensitivity_indices.json"
)
```


## Integrated Simulation and Sensitivity

To compute sensitivity indices directly for multiple outputs against observed data and skip saving the detailed simulation results, use the following interface:


```python
# Define parameter space
parameters = [
{
'name': 'esco',
'change_type': 'absval',
'lower_bound': 0,
'upper_bound': 1
},
{
'name': 'perco',
'change_type': 'absval',
'lower_bound': 0,
'upper_bound': 1
}
]


# Extract data configuration
extract_data = {
'channel_sd_day.txt': {
'has_units': True,
'apply_filter': {'name': ['cha561']}
},
'channel_sd_mon.txt': {
'has_units': True,
'ref_day': 1,
'apply_filter': {'name': ['cha561']}
}
}

# Observe data configuration
observe_data = {
'channel_sd_day.txt': {
'obs_file': r"C:\Users\Username\observed_folder\discharge_daily.csv",
'date_format': '%Y-%m-%d'
},
'channel_sd_mon.txt': {
'obs_file': r"C:\Users\Username\observed_folder\discharge_monthly.csv",
'date_format': '%Y-%m-%d'
}
}

# Metric configuration
metric_config = {
'channel_sd_day.txt': {
'sim_col': 'flo_out',
'obs_col': 'discharge',
'indicator': 'NSE'
},
'channel_sd_mon.txt': {
'sim_col': 'flo_out',
'obs_col': 'mean',
'indicator': 'RMSE'
}
}

# Sensitivity indices
if __name__ == '__main__':
output = pySWATPlus.SensitivityAnalyzer().simulation_and_indices(
parameters=parameters,
sample_number=1,
sensim_dir=r"C:\Users\dpal22\Desktop\swat_run\experiment_dominant_hru\empty_dir",
txtinout_dir=r"C:\Users\dpal22\Desktop\swat_run\experiment_dominant_hru\txtinout_copy",
extract_data=extract_data,
observe_data=observe_data,
metric_config=metric_config
)
print(output)
```
Loading