-
Notifications
You must be signed in to change notification settings - Fork 2
EIA profile-based powerplant age imputation #31
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
Changes from all commits
4a9f7b7
1f79a5f
5700a53
8b8c7df
5f914f5
6dfe258
ed6753b
3a33748
557632a
998b702
9875124
33ea138
9796752
4bef4fd
46ff3ae
0733140
1d179be
8c1a9a1
c06dbad
4ce0e98
8afbc1e
1555409
6994c30
f144acb
8736400
e38d53f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| Annual commissioning-capacity imputation profile. | ||
|
|
||
| Bars show commissioning capacity by start year, split into observed and imputed | ||
| powerplants. The line shows the target annual commissioning profile used during | ||
| imputation. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,74 @@ def listify(item) -> list: | |
| } | ||
| EIA_CAT_MAPPING = {k: listify(v) for k, v in EIA_CAT_MAPPING.items()} | ||
|
|
||
| DATE_SOURCE_METADATA = { | ||
| "observed": { | ||
| "label": "Observed date (from powerplant data)", | ||
| "applies_to": {"start_year", "end_year"}, | ||
| }, | ||
| "derived_from_end_year": { | ||
| "label": "Start date derived from observed end date", | ||
| "applies_to": {"start_year"}, | ||
| }, | ||
| "imputed_capacity_profile": { | ||
| "label": "Start date imputed from historical commissioning-profile", | ||
| "applies_to": {"start_year"}, | ||
| }, | ||
| "imputed_construction_window": { | ||
| "label": "Start date imputed within construction window", | ||
| "applies_to": {"start_year"}, | ||
| }, | ||
| "imputed_pre_construction_window": { | ||
| "label": "Start date imputed within pre-construction window", | ||
| "applies_to": {"start_year"}, | ||
| }, | ||
| "imputed_announced_window": { | ||
| "label": "Start date imputed within announced window", | ||
| "applies_to": {"start_year"}, | ||
| }, | ||
| "derived_from_imputed_retirement_end_year": { | ||
| "label": "Start date derived from retirement-profile end date", | ||
| "applies_to": {"start_year"}, | ||
| }, | ||
| "derived_from_start_year_lifetime": { | ||
| "label": "End date derived from start date and lifetime", | ||
| "applies_to": {"end_year"}, | ||
| }, | ||
| "imputed_retirement_capacity_profile": { | ||
| "label": "End date imputed from retirement-profile", | ||
| "applies_to": {"end_year"}, | ||
| }, | ||
| "derived_from_start_year_lifetime_capped_to_retired_status": { | ||
| "label": "End date derived from start date but capped to retired status", | ||
| "applies_to": {"end_year"}, | ||
| }, | ||
| "derived_from_start_year_lifetime_with_retirement_delay": { | ||
| "label": "End date derived from start date, lifetime, and retirement delay", | ||
| "applies_to": {"end_year"}, | ||
| }, | ||
| "observed_adjusted_with_retirement_delay": { | ||
| "label": "Observed end date adjusted with retirement delay", | ||
| "applies_to": {"end_year"}, | ||
| }, | ||
| } | ||
|
|
||
|
|
||
| def date_source_types_for(year_column: str) -> set[str]: | ||
| """Return source types valid for a date column.""" | ||
| return { | ||
| source_type | ||
| for source_type, metadata in DATE_SOURCE_METADATA.items() | ||
| if year_column in metadata["applies_to"] | ||
| } | ||
|
|
||
|
|
||
| def date_source_labels() -> dict[str, str]: | ||
| """Return date-source display labels.""" | ||
| return { | ||
| source_type: metadata["label"] | ||
| for source_type, metadata in DATE_SOURCE_METADATA.items() | ||
| } | ||
|
Comment on lines
+113
to
+118
Collaborator
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. Suggestion: this kind of label boilerplate code can be avoided with the help of the pixi add --feature module inflection # installs the lib for the module
pixi run export-snakemake-env module # export the environment so rules can use itThen just run: from inflection import humanize
print(humanize("imputed_capacity_profile")
# Imputed capacity profileThis will make the the name easy to read while matching the dataset naming, which helps avoid confusion. It also forces the dev to come up with concise but clear naming too 😉
Collaborator
Author
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. I understand what you are asking, but humanize() doesnt add all the context that might helper a user unless i make all the variable names very very long. So I would prefer to keep my DATE_SOURCE_METADATA as-is .... it provides a "single source of truth' generally for this rule so it would have to exist anyway. |
||
|
|
||
|
|
||
| def get_eia_stats_in_cat_yr( | ||
| stats: pd.DataFrame, year: int, category: str | ||
|
|
||
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.
This could be removed with some smart helpers. See below.