You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3-5Lines changed: 3 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,14 +31,12 @@
31
31
32
32
## 📦 About
33
33
34
-
`pySWATPlus` is an open-source Python package that provides a programmatic interface to the [SWAT+](https://swat.tamu.edu/software/plus/) model, allowing users to run simulations, modify input files, and streamline custom experimentation through the model’s `TxtInOut` folder.
35
-
34
+
`pySWATPlus` is an open-source Python package that provides a programmatic interface to the [SWAT+](https://swat.tamu.edu/software/plus/) model, allowing users to run simulations and conduct custom experiments.
36
35
37
36
## ✨ Key Features
38
37
39
-
- Navigate and read files in the SWAT+ `TxtInOut` folder.
40
-
- Modify input parameters and save the updated files.
41
-
- Run SWAT+ simulations either in the main `TxtInOut` folder or in a user-specified directory.
38
+
- Modify parameters via the `calibration.cal` file.
39
+
- Run SWAT+ simulations.
42
40
- Perform sensitivity analysis on model parameters using the [SALib](https://github.com/SALib/SALib) Python package, with support for parallel computation.
`pySWATPlus` is an open-source Python package that provides a programmatic interface to the [SWAT+](https://swat.tamu.edu/software/plus/) model, allowing users to run simulations, modify input files, and streamline custom experimentation through the model’s `TxtInOut` folder.
8
-
7
+
`pySWATPlus` is an open-source Python package that provides a programmatic interface to the [SWAT+](https://swat.tamu.edu/software/plus/) model, allowing users to run simulations and conduct custom experiments.
9
8
10
9
## ✨ Key Features
11
10
12
-
- Navigate and read files in the SWAT+ `TxtInOut` folder.
13
-
- Modify input parameters and save the updated files.
14
-
- Run SWAT+ simulations either in the main `TxtInOut` folder or in a user-specified directory.
11
+
- Modify parameters via the `calibration.cal` file.
12
+
- Run SWAT+ simulations.
15
13
- Perform sensitivity analysis on model parameters using the [SALib](https://github.com/SALib/SALib) Python package, with support for parallel computation.
Copy file name to clipboardExpand all lines: docs/userguide/read_output.md
+20-16Lines changed: 20 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,27 +3,33 @@
3
3
This section explains how to read output data generated from `SWAT+` simulations.
4
4
It covers accessing results from both standard simulations and Sobol-based sensitivity analyses.
5
5
6
-
---
7
6
8
7
## Read Time Series Data
9
8
10
-
A standard `SWAT+` simulation generates TXT files with time series columns: `day`, `mon`, and `yr` for day, month, and year, respectively. To create a time series `DataFrame` that includes a new `date` column with `datetime.date` objects. Additionally, the method can optionally save the resulting DataFrame to a JSON file. This is controlled by the parameters `save_df` and `json_file`: setting `save_df=True` enables the saving process, and `json_file` specifies the path where the DataFrame will be written.
9
+
A standard `SWAT+` simulation generates TXT files with time series columns: `day`, `mon`, and `yr` for day, month, and year, respectively.
10
+
The following method creates a time series `DataFrame` that includes a new `date` column with `datetime.date` objects and save the resulting DataFrame to a JSON file.
The high-level [Sobol-Based Simulation Interface](https://swat-model.github.io/pySWATPlus/userguide/sensitivity_analysis/#sobol-based-simulation-interface) automates the sensitivity analysis workflow using Sobol samples. By default, it generates a file named `sensitivity_simulation_sobol.json` in the simulation folder. This JSON file contains all the information needed to analyze Sobol simulations, including:
31
+
The [sensitivity analysis](https://swat-model.github.io/pySWATPlus/userguide/sensitivity_analysis/) generates a file called `sensitivity_simulation.json` within the simulation folder.
32
+
This JSON file stores all information necessary for Sobol simulation analysis, including:
27
33
28
34
-`problem`: the Sobol problem definition
29
35
-`sample`: the generated sample array
@@ -33,8 +39,8 @@ To retrieve and process this data for further analysis:
33
39
34
40
```python
35
41
import json
36
-
import numpyas np
37
-
import pandasas pd
42
+
import numpy
43
+
import pandas
38
44
import io
39
45
40
46
# Path to the JSON file generated by the Sobol interface
@@ -48,25 +54,23 @@ with open(json_file, 'r') as input_json:
# Retrieve targeted DataFrames from sensitivity simulations
54
60
simulation_dict = sensitivity_dict['simulation']
55
-
df_name ='channel_sd_yr_df'# Example output
61
+
df_name ='channel_sd_mon_df'# Example output
56
62
df_dict = {}
57
63
58
64
for sim_key, sim_val in simulation_dict.items():
59
65
# Convert JSON string to pandas DataFrame
60
-
df =pd.read_json(
66
+
df =pandas.read_json(
61
67
path_or_buf=io.StringIO(sim_val[df_name])
62
68
)
63
69
# Ensure 'date' column is in datetime.date format
64
70
df['date'] = df['date'].dt.date
65
71
df_dict[sim_key] = df
66
72
```
67
73
68
-
> **Notes:**`df_dict` contains a `DataFrame` for each simulation key, which can be easily analyzed or plotted. Replace `'channel_sd_yr_df'` with any other output `DataFrame` as needed.
0 commit comments