Library and command to calculate detention times, disinfectant residuals, and CT ratios for drinking water systems
Project description
py_disinfection: Drinking Water Disinfection Parameter Calculations
Overview
This library and CLI tool provide calculations for disinfection values, including contact time, CT, log inactivation, and log inactivation ratios. These values are used in drinking water treatment to assess the effectiveness of various disinfectants (e.g., free chlorine, chlorine dioxide, chloramines) against microbial targets like Giardia, as well as viruses.
This library implements most of the methods described in the US EPA Disinfection Profiling and Benchmarking Technical Guidance Manual. Its internal tables for CT values are also taken from this document. A PDF copy is included in this repository to guard against removal of the EPA link, or dissolution of the EPA.
Features
- Python Library for programmatic access to CT calculations.
- Command-Line Interface (CLI) for quick calculations from the terminal.
- Supports Multiple Estimation Methods: for free chlorine disinfection:
- Conservative: Uses worst-case values.
- Interpolation: Performs multi-step interpolation.
- Regression: Uses EPA regression equations.
- Temperature Handling in Celsius or Fahrenheit.
- Multiple Disinfectant Agents supported, including free chlorine, chloramines, and chlorine dioxide.
- Giardia and Virus Targets for CT calculations.
- JSON Output Support for easy integration with other systems.
- Tested on Python 3.6 - 3.13-0a2, may work on other versions.
Installation
To install the package, run:
pip install py-disinfection
To install from source:
git clone git@github.com:SylvieWaterServices/py_disinfection.git
cd py-disinfection
make
Usage
🔹 Library Usage (Python API)
You can use the library to calculate required CT values programmatically:
from py_disinfection.core import DisinfectionSegment, DisinfectionSegmentOptions, DisinfectionTarget, DisinfectantAgent, CTReqEstimator
options = DisinfectionSegmentOptions(
volume_gallons=1000,
temperature_celsius=10,
ph=7.0,
concentration_mg_per_liter=0.5,
baffling_factor=0.3,
peak_hourly_flow_gallons_per_minute=20,
agent=DisinfectantAgent.FREE_CHLORINE,
ctreq_estimator=CTReqEstimator.INTERPOLATION
)
segment = DisinfectionSegment(options)
results = segment.analyze(DisinfectionTarget.GIARDIA)
print(results)
🔹 CLI Usage
You can also run calculations using the command-line tool Run disinfect --help to see all options:
Basic Usage
disinfect -v 1000 -t 10 -u C -p 7.0 -c 0.5 -m interpolation -a free_chlorine -b 0.3 -f 20
Output:
Segment Parameters:
volume_gallons: 1000.0
temperature_celsius: 10.0
ph: 7.0
concentration_mg_per_liter: 0.5
baffling_factor: 0.3
peak_hourly_flow_gallons_per_minute: 20.0
agent: DisinfectantAgent.FREE_CHLORINE
ctreq_estimator: CTReqEstimator.INTERPOLATION
Disinfection Analysis Results:
tdt: 50.0
contact_time: 15.0
viruses_required_ct: 6
viruses_calculated_ct: 7.5
viruses_ct_ratio: 1.25
viruses_log_inactivation: 5.0
giardia_required_ct: 105.5
giardia_calculated_ct: 7.5
giardia_ct_ratio: 0.07109004739336493
giardia_log_inactivation: 0.21327014218009477
Output in JSON Format
disinfect -v 1000 -t 10 -u C -p 7.0 -c 0.5 -m interpolation -a free_chlorine -b 0.3 -f 20 --json
Output:
{
"parameters": {
"agent": "FREE_CHLORINE",
"volume_gallons": 1000.0,
"temperature_celsius": 10.0,
"ph": 7.0,
"concentration_mg_per_liter": 0.5,
"peak_hourly_flow_gallons_per_minute": 20.0,
"ctreq_estimator": "INTERPOLATION",
"baffling_factor": 0.3,
"temp_fahrenheit": 50.0
},
"results": {
"tdt": 50.0,
"contact_time": 15.0,
"viruses_required_ct": 6,
"viruses_calculated_ct": 7.5,
"viruses_ct_ratio": 1.25,
"viruses_log_inactivation": 5.0,
"giardia_required_ct": 105.5,
"giardia_calculated_ct": 7.5,
"giardia_ct_ratio": 0.07109004739336493,
"giardia_log_inactivation": 0.21327014218009477
}
}
Features Coming Soon
- Support for inactivation credits from filtration and other treatment steps
- Ozone disinfection support
- Ability to create multiple treatment segments, and calculate the sum parameters of all segments in a treatment chain
- Expanded test suite
Development & Contribution
To contribute:
- Fork the repository.
- Clone your fork.
- Install dependencies:
pip install . - Run tests:
make test
License
This project is licensed under the BSD License. See LICENSE for details.
Author
Developed by Sylvie Water Services. Contributions and suggestions welcome! Reach us at hello@sylviewater.com.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_disinfection-0.1.10.tar.gz.
File metadata
- Download URL: py_disinfection-0.1.10.tar.gz
- Upload date:
- Size: 20.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b506a8f2cb7151983860b2186723f8a7d135e02359889659f9e728b598dfff89
|
|
| MD5 |
54b88f484d29d1349bebfc08f0ee1616
|
|
| BLAKE2b-256 |
47a2efca4ef1a67cde6676aadcfc6cdc4fc8f14a409427931641bc475de823c1
|
File details
Details for the file py_disinfection-0.1.10-py3-none-any.whl.
File metadata
- Download URL: py_disinfection-0.1.10-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
086d2a1e11ed3e6b4d300a01679d34f36e29bc15c458f26cec09f808eda45459
|
|
| MD5 |
c92b3b61ad37fc424b92241b899b12f1
|
|
| BLAKE2b-256 |
a1ecd141cd0558b96c61f89fc0898dfe42321a324a59471939840c632be360a2
|