Skip to content

Commit

Permalink
docs: added python example usage in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusPic committed Apr 25, 2024
1 parent 2a1f1fc commit db937a5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,34 @@ in the [`requirements.txt`](https://github.com/MarkusPic/intensity_duration_freq

The documentation of the python-API can be found [here](https://markuspic.github.io/intensity_duration_frequency_analysis/api.html).

One basic usage could be:

```python
import pandas as pd
from idf_analysis import IntensityDurationFrequencyAnalyse
from idf_analysis.definitions import *

# initialize of the analysis class
idf = IntensityDurationFrequencyAnalyse(series_kind=SERIES.PARTIAL, worksheet=METHOD.KOSTRA, extended_durations=True)

series = pd.Series(index=pd.DatetimeIndex(...), data=...)

# setting the series for the analysis
idf.set_series(series)
# auto-save the calculated parameter so save time for a later use, as the parameters doesn't have to be calculated again.
idf.auto_save_parameters('idf_parameters.yaml')
```

If you only want to analyse an already existing IDF-table

```python
import pandas as pd
from idf_analysis import IntensityDurationFrequencyAnalyse

idf_table = pd.DataFrame(...) # index='Duration Steps', columns='Return Periods'
idf = IntensityDurationFrequencyAnalyse.from_idf_table(idf_table)
```

## Commandline tool

The following commands show the usage for Linux/Unix systems.
Expand Down
3 changes: 1 addition & 2 deletions examples/example_reverse_engeneering.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
idf_table = get_max_calculation_method(df)
idf_table = df.xs('ÖKOSTRA', axis=0, level=INDICES.CALCULATION_METHOD, drop_level=True).copy()

idf_reverse = IntensityDurationFrequencyAnalyse(series_kind=SERIES.PARTIAL, worksheet=METHOD.KOSTRA, extended_durations=True)
idf_reverse._parameter.reverse_engineering(idf_table)
idf_reverse = IntensityDurationFrequencyAnalyse.from_idf_table(idf_table)

output_directory = path.join(f'design_rain_ehyd_{grid_point_number}')
idf_reverse.auto_save_parameters(path.join(output_directory, 'idf_parameters.yaml'))
Expand Down

0 comments on commit db937a5

Please sign in to comment.