Skip to main content

Library and command to calculate detention times, disinfectant residuals, and CT ratios for drinking water systems

Project description

Python Drinking Water Disinfection

Disinfection Parameter Calculator

Overview

This library and CLI tool provide calculations for disinfection values, including 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 such as Giardia and 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 <repo_url>
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)  # {'Required CT': 126.5, 'Actual CT': 134, 'Meets Requirement': True}

🔹 CLI Usage

You can also run calculations using the command-line tool:

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 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:

  1. Fork the repository.
  2. Clone your fork.
  3. Install dependencies: pip install -r requirements_dev.txt and pip install -r requirements.txt
  4. 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


Download files

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

Source Distribution

py_disinfection-0.1.1.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_disinfection-0.1.1-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file py_disinfection-0.1.1.tar.gz.

File metadata

  • Download URL: py_disinfection-0.1.1.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for py_disinfection-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f1e45a05e17d1afe16b9b0d28e84e23c91780a7eca719ed32f6a2e4fe0b09a66
MD5 0ace447072b291203f0d19ac5c65bf07
BLAKE2b-256 f97032c0243869422db2732f221b00da8afe5c624d5bf7b522a6dbff794e04e6

See more details on using hashes here.

File details

Details for the file py_disinfection-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for py_disinfection-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8aca3918bb83c7de90aaa3f330d486fcb519d0c6bc05154737d1c1c688a35a45
MD5 2c0b2aeaf3ec901d480b1fa7410f54f4
BLAKE2b-256 d18f9e0416fc8ebceb79d8cd425d15add7a9a91d90a733b5450de30218c7b65a

See more details on using hashes here.

Supported by

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