Skip to main content

A tool to calculate time weighted average for water level / flow.

Project description

Time weighted average for water

PyPI version PyPI - Downloads Downloads DOI

It is a tool to calculate time weighted average for gauged water level, flow, or something similar.

Table of contents

Installation, update and uninstallation

To install

Quick installation with pip:

pip install time-weighted-average-for-water

Or from github:

pip install git+https://github.com/longavailable/time-weighted-average-for-water

Also, you can just copy related functions from twaw/twaw.py to your work.

To update

pip install --upgrade time-weighted-average-for-water

To uninstall

pip uninstall time-weighted-average-for-water

Usage

See tests/001-daily-average.py.

import pandas as pd
from twaw import dailyAverage

# load data
url_demodata = 'https://raw.githubusercontent.com/longavailable/datarepo02/main/data/twaw/test-data-for-twaw.csv'
data = pd.read_csv(url_demodata)
data['time'] = pd.to_datetime(data['time'])

# usages
items = ['Z', 'Q']
results1 = dailyAverage(data, itemHeader=items, timeHeader='time')
results2 = dailyAverage(data, itemHeader=['Z'], timeHeader='time')
results3 = dailyAverage(data, itemHeader='Q', timeHeader='time')

# export
newdata = pd.DataFrame(data=results1)
newdata2 = newdata.dropna(subset=items, how='all').sort_values(by=['year', 'month', 'day'])
if len(newdata2) > 0:
	filename = 'test-o.csv'
	newdata2.to_csv(filename, index=False)
else:
	print('No data to export!')

How to cite

If this tool is useful to your research, star and cite it as below:

Xiaolong Liu. (2023, March 02). longavailable/time-weighted-average-for-water. Zenodo.
https://doi.org/10.5281/zenodo.7691849

Easily, you can import it to Mendeley.

Changelog

v0.1.0

  • First release.

Todo

  • Add a method description.

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

time-weighted-average-for-water-0.1.0.tar.gz (4.8 kB view hashes)

Uploaded Source

Built Distribution

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