Skip to main content

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

hdd_cdd_calculator-0.1.1.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

hdd_cdd_calculator-0.1.1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hdd_cdd_calculator-0.1.1.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

Hashes for hdd_cdd_calculator-0.1.1.tar.gz
Algorithm Hash digest
SHA256 856ef51112ce389fb8b79298cb70acb8df0b69746444994096ac91948beb95e0
MD5 1259198606bf42302678bb91f33637fd
BLAKE2b-256 f5c32e881da196703ada73ac02774cc597ab2deeefed38eebe8371401055ed7f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdd_cdd_calculator-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 04187d7eec69270c89ff3c59d86b2923c20f0ab30e09b6dfe696c5896c8bc674
MD5 10671d5d0c772ba5b8c08d4bb2267374
BLAKE2b-256 04e37bd763aa4b3f4c2d057c28d9e68b442d983d8e46197a9248d20ab0145db8

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