-
Notifications
You must be signed in to change notification settings - Fork 1
Add natural gas price regression pipeline #2
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
Open
Yunzhi-Chen
wants to merge
14
commits into
main
Choose a base branch
from
yc/natural_gas_update
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8fe590e
Move natural gas price regression code to here
Yunzhi-Chen 1f797f9
Add auto-update for historical NG data and backfill 2024
Yunzhi-Chen 77d3367
Update aeo_alpha_regression.py
Yunzhi-Chen abc49f1
Create national_beta.csv
Yunzhi-Chen 8dc8113
Remove cd_beta0_allsector
Yunzhi-Chen d997b25
Delete cd_beta0_allsector.csv
Yunzhi-Chen a8f5489
Update the results for minor difference due to the rounding somewhere
Yunzhi-Chen 5851f3c
Don't push outputs and intermediate csv files to Github
Yunzhi-Chen 41eb990
Use python to kick off the pipeline rather than the batch file (to fa…
Yunzhi-Chen dfc9c7d
Clean up
Yunzhi-Chen 8fddf96
Remove csv files
Yunzhi-Chen 9d144d5
Create README.md
Yunzhi-Chen 2a1fbe0
Create README.md
Yunzhi-Chen b6874b0
Remove old method for updating natural gas values.
wesleyjcole 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
Binary file not shown.
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,35 @@ | ||
| # Python cache | ||
| __pycache__/ | ||
| *.pyc | ||
|
|
||
| # Visualization outputs (PNGs, PDFs) | ||
| *.png | ||
|
|
||
| # Validation and visualization results (all generated output) | ||
| results validation/ | ||
|
|
||
| # Alpha regression outputs (all CSVs are generated, reproducible) | ||
| outputs of alpha regression/*.csv | ||
| outputs of alpha regression/raw_aeo_data/ | ||
|
|
||
| # Beta regression outputs (all generated, reproducible) | ||
| outputs of beta regression/*.csv | ||
| outputs of beta regression/raw_aeo_data/ | ||
| outputs of beta regression/bata raw data visualization/ | ||
| outputs of beta regression/alpha from beta regression/ | ||
|
|
||
| # Intermediate beta inputs (copied by sync_beta_to_alpha_inputs.py, not source data) | ||
| inputs for alpha regression/cd_beta0.csv | ||
| inputs for alpha regression/national_beta.csv | ||
|
|
||
| # Notebook checkpoints | ||
| .ipynb_checkpoints/ | ||
|
|
||
| # Stale nested duplicate directory | ||
| AEO_Updates/ | ||
|
|
||
| # Old scripts (replaced by visualization.py) | ||
| results_visualization.py | ||
| results_validation.py | ||
| beta_raw_data_visualization.py | ||
|
Comment on lines
+32
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why should these be here if they are replaced? |
||
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,93 @@ | ||
| # Natural Gas Price Regression | ||
|
|
||
| This folder has the natural gas update workflow for ReEDS. | ||
|
|
||
| Files to update in the ReEDS repository are described in "outputs of alpha regression/README.md". | ||
|
|
||
| ## Model Note | ||
|
|
||
| `alpha` differs by step: | ||
|
|
||
| - Beta step (`alpha1`) is `alpha1(region, year)` and is shared across scenarios. | ||
| - Alpha step (`alpha2`) is `alpha2(region, year, scenario)`, so each output | ||
| scenario has its own alpha path. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| ### EIA API Key | ||
|
|
||
| The pipeline fetches data from the EIA API and requires an API key. Set it as an environment variable before running: | ||
|
|
||
| **Windows (persistent — open a new terminal after running):** | ||
| ```cmd | ||
| setx EIA_API_KEY your_api_key_here | ||
| ``` | ||
|
|
||
| **Windows (current session only):** | ||
| ```cmd | ||
| set EIA_API_KEY=your_api_key_here | ||
| ``` | ||
|
|
||
| **macOS/Linux:** | ||
| ```bash | ||
| export EIA_API_KEY=your_api_key_here | ||
| ``` | ||
|
|
||
| > The key is read from the `EIA_API_KEY` environment variable. Do **not** hardcode it in `aeo_pipeline_config.json`. | ||
|
|
||
| ## Run order | ||
|
|
||
| 1. Edit `aeo_pipeline_config.json` with your settings. | ||
|
|
||
| 2. Run **beta regression first**. | ||
|
|
||
| ```bash | ||
| python aeo_beta_regression.py --config aeo_pipeline_config.json | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need these given that run_ng_pipeline.py does all of it for you? |
||
| ``` | ||
|
|
||
| 3. Sync beta outputs into alpha inputs. | ||
|
|
||
| ```bash | ||
| python sync_beta_to_alpha_inputs.py --config aeo_pipeline_config.json | ||
| ``` | ||
|
|
||
| 4. Run **alpha regression**. | ||
|
|
||
| ```bash | ||
| python aeo_alpha_regression.py --config aeo_pipeline_config.json | ||
| ``` | ||
|
|
||
| 5. Generate all diagnostic plots and validation. | ||
|
|
||
| ```bash | ||
| python visualization.py --config aeo_pipeline_config.json | ||
| ``` | ||
|
|
||
| Skip individual parts with flags: | ||
| ```bash | ||
| python visualization.py --skip-raw-scatter --skip-validation | ||
| ``` | ||
|
|
||
| Default output folder: `results validation` (all plots and validation CSVs). | ||
|
|
||
| ## Scenario Configuration | ||
|
|
||
| Set explicit scenarios in `aeo_pipeline_config.json` under `scenarios`: | ||
|
|
||
| - `scenarios.beta_regression.include`: scenarios used to estimate beta. | ||
| - `scenarios.alpha_regression.fetch`: scenarios fetched for alpha preprocessing. | ||
| - `scenarios.alpha_regression.outputs`: mapping from output suffix (`reference`, `HOG`, `LOG`, etc.) to scenario aliases. | ||
|
|
||
| Use canonical IDs (for example `ref{aeo_year}`, `highogs`, `lowogs`) for a clear setup. | ||
|
|
||
| ## One-command run (all platforms) | ||
|
|
||
| ```bash | ||
| python run_ng_pipeline.py | ||
| ``` | ||
|
|
||
| Optional custom config: | ||
|
|
||
| ```bash | ||
| python run_ng_pipeline.py --config my_config.json | ||
| ``` | ||
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.
Typo in ignored directory name: "bata raw data visualization" looks unintended and likely won't match the actual output directory. Fixing this prevents generated artifacts from being accidentally committed.