
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
hdd-cdd-calculator
Advanced tools
A Python library for calculating Heating Degree Days (HDD) and Cooling Degree Days (CDD) from multiple weather data sources including the U.S. NWS API and Meteostat, with regression and visualization tools.
A Python library for calculating Heating Degree Days (HDD) and Cooling Degree Days (CDD) from multiple weather data sources, including:
The package also supports:
From PyPI:
pip install hdd-cdd-calculator
Optional extras:
pip install hdd-cdd-calculator[dev] # dev tools (pytest, linting, typing)
pip install hdd-cdd-calculator[viz] # includes matplotlib for plotting
From source:
git clone https://github.com/rmkenv/hdd_cdd_calculator.git
cd hdd_cdd_calculator
pip install -e .[dev]
from hdd_cdd_calculator import get_degree_days
results = get_degree_days(
lat=38.8977,
lon=-77.0365,
start_date="2023-06-01",
end_date="2023-06-07",
source="nws"
)
for r in results:
print(f"{r.date} | High: {r.high_temp}°F | Low: {r.low_temp}°F | HDD: {r.hdd} | CDD: {r.cdd}")
from hdd_cdd_calculator import get_degree_days
results = get_degree_days(
lat=40.7128,
lon=-74.0060,
start_date="2023-06-01",
end_date="2023-06-30",
source="meteostat"
)
Expected CSV headers:
date,kwh,mmbtu,gal
from hdd_cdd_calculator import read_energy_data_from_csv
energy_values = read_energy_data_from_csv("energy_data.csv", column="kwh")
from hdd_cdd_calculator import (
get_degree_days_for_period,
align_energy_with_degree_days,
perform_regression,
plot_regression
)
import pandas as pd
# Step 1: Fetch HDD data
dd_results = get_degree_days_for_period(
lat=40.7128,
lon=-74.0060,
start_date="2023-06-01",
end_date="2023-06-10"
)
# Step 2: Align with CSV
energy_vals, hdd_vals = align_energy_with_degree_days(
dd_results,
"examples/sample_energy_data.csv",
energy_column="kwh",
degree_day_type="hdd"
)
# Step 3: Fit regression
model = perform_regression(hdd_vals, energy_vals)
print(f"Slope: {model.coef_:.2f}, Intercept: {model.intercept_:.2f}")
# Step 4: Plot and save
plot_regression(
pd.Series(hdd_vals),
pd.Series(energy_vals),
model,
save_path="examples/regression_plot.png" # Save file in examples/
)
We include a complete dataset + CLI workflow.
From the repo root or after installing:
python -m hdd_cdd_calculator --example
This will:
examples/sample_energy_data.csvexamples/regression_plot.png
Data fetching
get_degree_days_for_location(...)get_degree_days_for_period(...)fetch_meteostat_data(...)get_degree_days(...) — unified source selectorCSV utilities
read_energy_data_from_csv(path, column="kwh")read_energy_data_with_dates(path, column="kwh")align_energy_with_degree_days(degree_days, csv, energy_column="kwh", degree_day_type="hdd")Analysis
perform_regression(degree_days, energy_usage)plot_regression(degree_days, energy_usage, model, save_path=None, show=True)Utilities
validate_coordinates(...)calculate_degree_days(...)fahrenheit_to_celsius(...), celsius_to_fahrenheit(...)Clone and install with developer tools:
git clone https://github.com/rmkenv/hdd_cdd_calculator.git
cd hdd_cdd_calculator
pip install -e .[dev]
Run tests:
pytest
MIT License — see LICENSE for details.
Author: Ryan Kmetz
FAQs
A Python library for calculating Heating Degree Days (HDD) and Cooling Degree Days (CDD) from multiple weather data sources including the U.S. NWS API and Meteostat, with regression and visualization tools.
We found that hdd-cdd-calculator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.