A Python implementation of the calculations and evaluations done by the Dew Point Calculator found at https://www.dpcalc.org/.
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.
pip install preservationevalfrom 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}")For details of how to use, see:
- http://www.dpcalc.org/howtouse_step2.php
- https://www.eclimatenotebook.com/fundamentals_nl.php
- https://s3.cad.rit.edu/ipi-assets/publications/understanding_preservation_metrics.pdf
# Clone the repository
git clone https://github.com/petter-b/preservationeval
cd preservationeval
# Install development dependencies
pip install -e ".[dev]"ruff: Code formatting, linting and code qualitymypy: Static type checkingpytest: Testing frameworkpre-commit: Git hooks for code quality
# Format code
ruff format .
# Run linter
ruff check .
# Type checking
mypy .
# Run tests with coverage
pytest --covThe package includes a validation framework that compares the Python implementation against the original JavaScript implementation from dpcalc.org.
- Node.js and npm must be installed (download)
- Python test dependencies:
pip install -e ".[test]"
The test framework automatically:
- Creates the
tests/datadirectory (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-updateThis 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.
This project is licensed under the MIT License - see the LICENSE file for details.
See CHANGELOG.md for all changes and versioning details.