Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement custom electricity emissions backend #135

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

MisterClean
Copy link

Description

Issue #121

Introduces a feature to calculate and append electricity emissions to the building benchmarking dataset. The calculation uses electricity usage data and year-specific carbon intensity factors to estimate CO₂ emissions.

The annual emissions factors are configurable in the emissions.yml file.

NOTE: The current configuration file has incorrect values right now. We will need to calculate the accurate version of the emissions factor using EIA data. I eyeballed 2023 using slide 28 of the PJM Illinois annual report

This only impacts the data backend. We will still need to come up with a new building emissions calculation that combines non-electricity emissions with the new custom electricity emissions estimate to determine the new total building emissions estimate.

Here’s how it works:


Key Changes

  1. New Column: ElectricityEmissions

    • Represents CO₂ emissions from electricity usage for each building, measured in metric tons.
    • Calculated using electricity consumption (converted from kBtu to kWh) and carbon intensity factors specific to the year of data.
  2. Supporting Column: ElectricityUseKWh

    • Converts ElectricityUse from kBtu to kWh for accurate emissions calculations.
  3. Carbon Intensity Factors

    • Retrieved from a configuration file (emissions.yml) and specify the grams of CO₂ emitted per kWh for each year.

How It Works

  1. Data Preparation:

    • Input data is cleaned and transformed to ensure numeric columns are correctly formatted.
    • Electricity usage (ElectricityUse) is converted from kBtu to kWh using the factor: 1 kBtu = 0.293071 kWh.
  2. Emissions Calculation:

    • For each building, emissions are calculated using the formula:
image
  1. Integration:

    • The calculate_building_emissions function is used to add the ElectricityEmissions and ElectricityUseKWh columns to the dataset.
    • The new column is included in the analysis and ranking workflow, allowing for comparison and statistical evaluation. ElectricityEmissions is measured in metric tons.
  2. Output:

    • Updated datasets are exported as CSV and JSON files for further use, including frontend integration.

Example Output

Given the following input:

PropertyName ElectricityUse (kBtu) DataYear
Building A 10,000 2022

The output includes:

PropertyName ElectricityUse (kBtu) DataYear ElectricityUseKWh ElectricityEmissions (metric tons)
Building A 10,000 2022 2,930.71 1.47

Why This Matters

  • Provides a standardized emissions metric based on electricity consumption.
  • Enables ranking and analysis of buildings by electricity emissions, facilitating actionable insights for reducing carbon footprints.

Let me know if you need further details or edits for this summary!

Testing Instructions

Build data with python src/data/scripts/process_data.py
Test data with python tests/data/scripts/test_emissions.py

A successful test will look like this

Carbon Intensity Factors:
2014: 137 g/kWh
2015: 137 g/kWh
2016: 137 g/kWh
2017: 137 g/kWh
2018: 137 g/kWh
2019: 137 g/kWh
2020: 150 g/kWh
2021: 145 g/kWh
2022: 140 g/kWh
2023: 137 g/kWh

Sample Building Emissions:
Year | Electricity (kBtu) | Electricity (kWh) | Emissions (metric tons)
-----------------------------------------------------------------
2020 |          100000 |          29307 |                4.40
2021 |          100000 |          29307 |                4.25
2022 |          100000 |          29307 |                4.10
2023 |          100000 |          29307 |                4.02

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link

netlify bot commented Nov 18, 2024

Deploy Preview for radiant-cucurucho-d09bae failed.

Name Link
🔨 Latest commit 6344e26
🔍 Latest deploy log https://app.netlify.com/sites/radiant-cucurucho-d09bae/deploys/673bd488331ff400089ac331

result = df.copy()

# Convert kBtu to kWh (1 kBtu = 0.293071 kWh)
result['ElectricityUseKWh'] = result['ElectricityUse'] * 0.293071
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't make sense to store this, since it's calculatable from electricity use in kBTUs, including at run-time. In fact, we already do that in common-functions.js:estimateUtilitySpend to make a rough approximation of how much buildings might be spend on electricity.

@@ -0,0 +1,11 @@
carbon_intensity_factors:
2014: 137
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a data source? If we're adding a new source we need to maintain year-over-year, we'll need to have that noted, and make sure that it errors out if the latest year's intensity is missing

@vkoves
Copy link
Owner

vkoves commented Nov 23, 2024

@MisterClean - super exciting to see you tackle this, but the site doesn't build: https://app.netlify.com/sites/radiant-cucurucho-d09bae/deploys/673bd488331ff400089ac331

I also just ran the Python tests and those look to be hitting errors too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants