Metadata-Version: 2.1
Name: tj_hyd_tank
Version: 1.0.0
Summary: Python implementation of Tank Hydrological model by Sugawara and Funiyuki (1956)
Author: duynguyen02
Description-Content-Type: text/markdown
Requires-Dist: attrs==23.2.0
Requires-Dist: certifi==2024.7.4
Requires-Dist: cftime==1.6.4
Requires-Dist: click==8.1.7
Requires-Dist: click-plugins==1.1.1
Requires-Dist: cligj==0.7.2
Requires-Dist: contourpy==1.2.1
Requires-Dist: cycler==0.12.1
Requires-Dist: exceptiongroup==1.2.2
Requires-Dist: fiona==1.9.6
Requires-Dist: fonttools==4.53.1
Requires-Dist: importlib_metadata==8.2.0
Requires-Dist: importlib_resources==6.4.0
Requires-Dist: iniconfig==2.0.0
Requires-Dist: kiwisolver==1.4.5
Requires-Dist: matplotlib==3.9.1
Requires-Dist: netCDF4==1.7.1.post1
Requires-Dist: numpy==2.0.1
Requires-Dist: packaging==24.1
Requires-Dist: pandas==2.2.2
Requires-Dist: pathlib==1.0.1
Requires-Dist: patsy==0.5.6
Requires-Dist: pillow==10.4.0
Requires-Dist: pluggy==1.5.0
Requires-Dist: pyparsing==3.1.2
Requires-Dist: pyscissor==1.1.7
Requires-Dist: pytest==8.3.2
Requires-Dist: python-dateutil==2.9.0.post0
Requires-Dist: pytz==2024.1
Requires-Dist: scipy==1.13.1
Requires-Dist: seaborn==0.13.2
Requires-Dist: shapely==2.0.5
Requires-Dist: six==1.16.0
Requires-Dist: statsmodels==0.14.2
Requires-Dist: tabulate==0.9.0
Requires-Dist: termcolor==2.3.0
Requires-Dist: tomli==2.0.1
Requires-Dist: tzdata==2024.1
Requires-Dist: yaspin==3.0.2
Requires-Dist: zipp==3.19.2

# TJ_HYD_NAM

Python implementation of Tank Hydrological model by Sugawara and Funiyuki (1956) , based on the original code
from [tank-model](https://github.com/nzahasan/tank-model) by [hckaraman](https://github.com/nzahasan)

### Installation

```
pip install tj_hyd_tank
```

### Getting Started

#### Prepare the Dataset
##### Dataset

The dataset should include columns: Date, Precipitation, Evapotranspiration, and Discharge, with column
names customizable.

| Date       | Q       | P   | E    |
|------------|---------|-----|------|
| 10/9/2016  | 0.25694 | 0   | 2.79 |
| 10/10/2016 | 0.25812 | 0   | 3.46 |
| 10/11/2016 | 0.30983 | 0   | 3.65 |
| 10/12/2016 | 0.31422 | 0   | 3.46 |
| 10/13/2016 | 0.30866 | 0   | 5.64 |
| 10/14/2016 | 0.30868 | 0   | 3.24 |
| 10/15/2016 | 0.31299 | 0   | 3.41 |
| ...        | ...     | ... | ...  |

The time intervals between dates must be equal (e.g., 24 hours) for the model to function accurately.

##### Basin file
HEC-HMS basin.

#### Quick start
```python
import pandas as pd

from tj_hyd_tank import TJHydTANK, TANKColNames, TANKConfig

df = pd.read_csv('data_example.csv')
tank_cols_name = TANKColNames(
    date='Date',
    precipitation='P',
    evapotranspiration='E',
    discharge='Q'
)
tank_config = TANKConfig(
    start_date=None,
    end_date=None,
    interval=24.0
)

tank = TJHydTANK(
    basin_file='CedarCreek.basin',
    df=df,
    tank_col_names=tank_cols_name,
    tank_config=tank_config
)
tank
```
#### Get basin_defs
```python
from tj_hyd_tank import Subbasin, Reach

for basin_def in tank.basin_defs:
    print(basin_def.name, basin_def.type)
    print(basin_def.stats)
    if isinstance(basin_def, (Subbasin, Reach)):
        print(basin_def.params)
```
#### Get root_node
```python
from tj_hyd_tank import Subbasin, Reach

for root_node in tank.root_node:
    print(root_node.name, root_node.type)
    print(root_node.stats)
    if isinstance(root_node, (Subbasin, Reach)):
        print(root_node.params)
```
#### Plot a comparison between Q_obs and Q_sim of a basin_def
```python
outlet1 = tank.get_basin_def_by_name('Outlet1')
if outlet1 is not None:
    tank.show_discharge(outlet1)
```
#### Reconfig and show Subbasin 's properties
```python
from tj_hyd_tank import SubbasinParams

w170 = tank.get_basin_def_by_name('W170')
if w170 is not None:
    if isinstance(w170, Subbasin):
        tank.reconfig_subbasin_params(
            w170,
            SubbasinParams(
                t0_is=0.02,
                t0_soc_uo=80.0
            )
        )
        print('Q_tank_0', w170.Q_tank_0.tolist())
        print('Q_tank_1', w170.Q_tank_1.tolist())
        print('Q_tank_2', w170.Q_tank_2.tolist())
        print('Q_tank_3', w170.Q_tank_3.tolist())
        print('bottom_outlet_flow_tank_0', w170.bottom_outlet_flow_tank_0.tolist())
        print('bottom_outlet_flow_tank_1', w170.bottom_outlet_flow_tank_1.tolist())
        print('bottom_outlet_flow_tank_2', w170.bottom_outlet_flow_tank_2.tolist())
```
#### Reconfig TANK model
```python
tank.reconfig_tank(
    TANKConfig(
        start_date=pd.to_datetime('09/10/2016', dayfirst=True, utc=True),
        end_date=pd.to_datetime('20/10/2016', dayfirst=True, utc=True)
    )
)
```
#### To DataFrame
```python
outlet1_df = tank.to_dataframe(outlet1)
outlet1_df
```
#### Get Logs
```python
print(tank.logs)
```
