A Python library for calculating Heating Degree Days (HDD) and Cooling Degree Days (CDD) using NWS API data
Project description
HDD/CDD Calculator
A Python library for calculating Heating Degree Days (HDD) and Cooling Degree Days (CDD) using weather data from the National Weather Service (NWS) API.
Features
- Calculate HDD and CDD for any geographic location by latitude and longitude.
- Support for custom base temperatures.
- Retrieve degree day data for specific date ranges.
- Graceful handling of errors and invalid inputs.
- Type hints for improved code clarity and IDE support.
- Unit tests included for core functionality.
- Ready for packaging and distribution via PyPI.
Installation
Install the package via pip:
pip install hdd-cdd-calculator
Usage
Basic Usage
from hdd_cdd import get_degree_days_for_location
# Get degree days for a specific location (e.g., White House coordinates)
results = get_degree_days_for_location(38.8977, -77.0365)
for result in results:
print(f"Date: {result.date}")
print(f"High: {result.high_temp}°F, Low: {result.low_temp}°F")
print(f"Mean: {result.mean_temp:.1f}°F")
print(f"HDD: {result.hdd:.1f}, CDD: {result.cdd:.1f}")
print()
Advanced Usage with Date Range
from hdd_cdd import get_degree_days_for_period
# Get degree days for New York City for June 2023
results = get_degree_days_for_period(
lat=40.7128,
lon=-74.0060,
start_date="2023-06-01",
end_date="2023-06-30"
)
total_hdd = sum(result.hdd for result in results)
total_cdd = sum(result.cdd for result in results)
print(f"Total HDD for June 2023: {total_hdd:.1f}")
print(f"Total CDD for June 2023: {total_cdd:.1f}")
Documentation
Full documentation is available in the docs directory.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Additional Project Files
pyproject.toml — Build system configuration.
setup.cfg — Package metadata and configuration.
.gitignore — Recommended ignores for Python projects, including build artifacts, virtual environments, and IDE files.
If you have any questions or want to contribute, feel free to open an issue or submit a pull request!
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
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 hdd_cdd_calculator-0.1.0.tar.gz.
File metadata
- Download URL: hdd_cdd_calculator-0.1.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6aefc2831cf6dbdbc335fddb38161ee75506ab550269ecd43f77cf12f92d598
|
|
| MD5 |
e328a4d755d9168fa579644abfd7d623
|
|
| BLAKE2b-256 |
77f7d2bc15230e8cd75876fd25262a36bb46612a274ed5b8a3a388693bcb92e4
|
File details
Details for the file hdd_cdd_calculator-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hdd_cdd_calculator-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c397cb9f6ee7884e3672249af599b59cae1d49e1018d07ee855abcdb89167ac8
|
|
| MD5 |
3825fbd9b677eff909049f9a5a68b541
|
|
| BLAKE2b-256 |
966ad8f909ac8f8f97ffe6e3a311dda1628bdc8eeaf83512920a2a654d22ae01
|