-
Notifications
You must be signed in to change notification settings - Fork 32
Automated EIA baseline comparison #554
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2b9e7fa
Add baseline comparison script and CI workflow
jmythms c8abae8
Add EIA update documentation
jmythms d8d6690
update dependencies
jmythms 7357091
Enforce failure if above allowed threshold
jmythms d0d8571
Implement per-series error tolerance in comparison
jmythms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| name: EIA update check | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| workflow_dispatch: {} | ||
|
|
||
| jobs: | ||
| eia-check: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| env: | ||
| # EIA API key stored as a GitHub Actions secret | ||
| EIA_API_KEY: ${{ secrets.EIA_API_KEY }} | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - name: Install package | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install ".[dev]" | ||
|
|
||
| - name: Run EIA baseline comparison (save output) | ||
| run: | | ||
| # Fail the step if the Python command fails, even when piped through tee | ||
| set -o pipefail | ||
| mkdir -p tests/eia_update | ||
| python -m scout.AEO_update_helpers.baseline_comparison --year 2025 2>&1 | tee tests/eia_update/eia_baseline_output.txt | ||
|
|
||
| - name: Upload artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: eia-baseline-results | ||
| path: | | ||
| ./tests/eia_update/ | ||
| ./generated/log_*.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| .. _eia-update: | ||
|
|
||
| EIA Updates | ||
| ================= | ||
|
|
||
| Scout's residential and commercial baseline energy use is anchored to the | ||
| U.S. Energy Information Administration (EIA) Annual Energy Outlook (AEO). | ||
| When Scout is updated to a new AEO release, we use a small helper script to | ||
| compare Scout's internal microsegment totals against the official AEO tables. | ||
|
|
||
| The script lives in ``scout/AEO_update_helpers/baseline_comparison.py``. | ||
| At a high level it: | ||
|
|
||
| * loads Scout's processed AEO microsegments file (``mseg_res_com_cz.json``), | ||
| * aggregates energy use by building class, fuel type, and end use, | ||
| * queries the EIA AEO API for the matching time-series, | ||
| * compares Scout vs. EIA year-by-year, and | ||
| * prints summary tables showing any large differences. | ||
|
|
||
| Running the EIA update check | ||
| ---------------------------- | ||
|
|
||
| 1. **Create a local `.env` file (not committed to git)** in the project root | ||
| (the same folder as ``pyproject.toml``) with your EIA API key:: | ||
|
|
||
| EIA_API_KEY=YOUR_REAL_KEY_HERE | ||
|
|
||
| You can request a free key from EIA at https://www.eia.gov/opendata/register.php. | ||
|
|
||
| 2. **Install Scout and its dependencies** into a virtual environment | ||
| (see :ref:`install-guide`). | ||
|
|
||
| 3. **From the project root, run the helper script**, for example:: | ||
|
|
||
| python -m scout.AEO_update_helpers.baseline_comparison --year 2025 | ||
|
|
||
| Use ``--verbose`` to see the underlying API calls and any combinations where | ||
| data are missing. | ||
|
|
||
| The output includes per-combination comparisons and simple roll-up tables by | ||
| building class and fuel type. These reports make it easier to confirm that | ||
| Scout's baseline matches the chosen AEO reference. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is still failing in the actions? Can you confirm that it is actually loading this dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed