Skip to main content

A Python implementation of the calculations and evaluations done by the Dew Point Calculator found at https://www.dpcalc.org/.

Project description

preservationeval

PyPI Python CI Coverage License

A Python implementation of the calculations and evaluations done by the Dew Point Calculator found at https://www.dpcalc.org/.

Details

The preservation evaluation is inspired by the Dew point calulator created by the Image Permanence Institute. They are publishing their code http://www.dpcalc.org/dp.js and most of the work in this project has been spent on figuring out how to install this package without redistributing the lookup tables from the original Javascript code. These tables are downloaded from the Internet and converted into a python module during installation of the package.

Installation

pip install preservationeval

Usage

Basic Examples

from preservationeval import pi, emc, mold

# Calculate Preservation Index
pi_value = pi(20, 50)  # temperature=20°C, RH=50%
print(f"Preservation Index: {pi_value}")

# Calculate EMC (Equilibrium Moisture Content)
emc_value = emc(20, 50)
print(f"EMC: {emc_value}%")

# Calculate Mold Risk
mold_risk = mold(20, 50)
print(f"Mold Risk: {mold_risk}")

Interpreting Restults

For details of how to use, see:

Development

Project Status Downloads Issues

Setup

# Clone the repository
git clone https://github.com/petter-b/preservationeval
cd preservationeval

# Install development dependencies
pip install -e ".[dev]"

Development Tools

  • ruff: Code formatting, linting and code quality
  • mypy: Static type checking
  • pytest: Testing framework
  • pre-commit: Git hooks for code quality

Common Tasks

# Format code
ruff format .

# Run linter
ruff check .

# Type checking
mypy .

# Run tests with coverage
pytest --cov

Testing

CI Coverage CodeQL

Validation Testing

The package includes a validation framework that compares the Python implementation against the original JavaScript implementation from dpcalc.org.

Requirements
  • Node.js and npm must be installed (download)
  • Python test dependencies: pip install -e ".[test]"
Test Data Setup

The test framework automatically:

  • Creates the tests/data directory (git-ignored)
  • Downloads the JavaScript reference implementation
  • Generates and saves test cases
  • Caches results for future test runs

You can manually trigger this setup:

# Download JavaScript reference implementation
# This happens automatically when running tests, or manually:
python -m tests.validate_core

# Run all tests
pytest

# Run only validation tests
pytest tests/test_validation.py

# Run with verbose output
pytest -v tests/test_validation.py

# Generate new test cases (ignore cached)
pytest tests/test_validation.py --force-update

Code Quality

Ruff Ruff Mypy

Automation

Pre-commit Pre-commit CI Renovate

Development Notes

This project was developed with assistance from Claude AI (Anthropic) and to some extent Codeium and GitHub Copilot. All code has been validated and tested for accuracy.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog

See CHANGELOG.md for all changes and versioning details.

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

preservationeval-1.1.0.tar.gz (31.8 kB view details)

Uploaded Source

File details

Details for the file preservationeval-1.1.0.tar.gz.

File metadata

  • Download URL: preservationeval-1.1.0.tar.gz
  • Upload date:
  • Size: 31.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for preservationeval-1.1.0.tar.gz
Algorithm Hash digest
SHA256 bf6f59c20bd689f29fac34486a5353ba42619f94e68ca432b923394d7c6ca9b1
MD5 f1f481ebc6a82eefc19c6b58ecfc9862
BLAKE2b-256 0c34a3ca53d09cc0a1fe11c0940e941c3ebefc2fbde537c277b6194762c237a6

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