Skip to main content

Python implementation of Tank Hydrological model by Sugawara and Funiyuki (1956)

Project description

TJ_HYD_NAM

Python implementation of Tank Hydrological model by Sugawara and Funiyuki (1956) , based on the original code from tank-model by hckaraman

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

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

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

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

outlet1 = tank.get_basin_def_by_name('Outlet1')
if outlet1 is not None:
    tank.show_discharge(outlet1)

Reconfig and show Subbasin 's properties

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

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

outlet1_df = tank.to_dataframe(outlet1)
outlet1_df

Get Logs

print(tank.logs)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tj_hyd_tank-1.0.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

tj_hyd_tank-1.0.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file tj_hyd_tank-1.0.0.tar.gz.

File metadata

  • Download URL: tj_hyd_tank-1.0.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.6

File hashes

Hashes for tj_hyd_tank-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6fb16be92631a63301d46c9484816dc29625350206c68b90141c449f19f396b4
MD5 20b53fb5d5b8e0c2016e08da2b696ba0
BLAKE2b-256 0b2f8ebb107fc71989af59761a412cf627c50f20c8ee7e0fda5ebc1bbf3e8421

See more details on using hashes here.

File details

Details for the file tj_hyd_tank-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: tj_hyd_tank-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.6

File hashes

Hashes for tj_hyd_tank-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93c20df40cd1f439c31433e53d8fd3a6c7d696d88764e4b26d0bfedcf0a77aa7
MD5 ec6445a48d9bef508702a55c5a928128
BLAKE2b-256 21b2e63c2491b4c050e1b6bce4440b1795f0042d53a30968746396800ea7c722

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page