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

Move the EIA plant-parts list into PUDL outputs #1157

Merged
merged 45 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
890cb6a
direct copy/past of EIA's master plant-part list
cmgosnell Aug 26, 2021
0276744
Integrate plant-parts list into pudl out. add helpers.
cmgosnell Aug 27, 2021
71cac6a
Fix docs test hooks
cmgosnell Aug 27, 2021
35fe0c0
clean up tests, documentation
cmgosnell Aug 30, 2021
6ed9759
Merge branch 'dev' into mul_eia
cmgosnell Aug 30, 2021
96d4887
update with new dependencies
cmgosnell Aug 31, 2021
29faf79
add a time-independed eia record id.
cmgosnell Sep 27, 2021
165169b
add a time-independed eia record id.
cmgosnell Sep 27, 2021
c563bb2
Merge branch 'dev' into mul_eia
cmgosnell Sep 29, 2021
3de55b1
Merge branch 'dev' into mul_eia
cmgosnell Sep 30, 2021
fb81d6a
remove pesky little docs builds
cmgosnell Sep 30, 2021
8d2cdfa
respond to pr comments on EIA plant-part list
cmgosnell Nov 5, 2021
e6cf770
docs update omigosh whyy
cmgosnell Nov 6, 2021
8da64c6
docs update but actually fix it yayyyy (hopefully i'm not jinxing it)
cmgosnell Nov 6, 2021
1cd8cd4
docs on "parent" and "child" plant-parts for the true granularity lab…
cmgosnell Nov 8, 2021
a2be073
move true granularites df into the main ppl output method.
cmgosnell Nov 9, 2021
5db5a15
Merge branch 'dev' into mul_eia
cmgosnell Nov 9, 2021
ece7ea5
add back in all of the attribute columns doh
cmgosnell Nov 11, 2021
b1d911d
Merge branch 'dev' into mul_eia
cmgosnell Dec 1, 2021
5a17250
update the "total" ownership slice in the gens_mega table
cmgosnell Dec 13, 2021
cc125be
Add example dfs to docs about creation of gens_mega
cmgosnell Dec 22, 2021
e75dbe4
Merge branch 'dev' into mul_eia
cmgosnell Dec 22, 2021
1a881e8
Add more examples into the plant-part documentation
cmgosnell Dec 22, 2021
07bf1b4
more examples for the ppl's recipe book
cmgosnell Dec 23, 2021
7652d9b
update docs: fails pre commit
cmgosnell Jan 20, 2022
35c7893
merge and UPDATE TESTS OMIGOSH
cmgosnell Jan 21, 2022
47ae175
update ridiculous doctest pd.options.display
cmgosnell Jan 21, 2022
4f3e048
maybe actually do a real doctest?
cmgosnell Jan 21, 2022
a90cd36
Merge branch 'dev' into mul_eia
cmgosnell Jan 21, 2022
09b9277
Convert more doctests to actually run through the methods
cmgosnell Jan 24, 2022
e5864ff
remove pytest fixture cruft
cmgosnell Jan 24, 2022
6b85387
Merge branch 'dev' into mul_eia
cmgosnell Jan 25, 2022
ca2ec36
add a doctest in the plant_part_eia module doc string.. for testing t…
cmgosnell Jan 25, 2022
2361b4a
add a test from doctests into unit tests
cmgosnell Jan 25, 2022
b624615
slightly clean the doctest output dfs maybe this will work probably not.
cmgosnell Jan 28, 2022
89e4771
bb doc change test
cmgosnell Jan 28, 2022
61de23a
save df and then output
cmgosnell Jan 28, 2022
7a49341
Merge branch 'dev' into mul_eia
cmgosnell Feb 23, 2022
fada71e
Merge branch 'dev' into mul_eia
katie-lamb Mar 8, 2022
77a7b3d
move plantparts tests and make mega gen doctests to unit tests
katie-lamb Mar 8, 2022
4d7be91
added all unit tests from doctests
katie-lamb Mar 8, 2022
9e41f62
updated docstrings to pass tox
katie-lamb Mar 9, 2022
4781417
had to remove code blocks test
katie-lamb Mar 9, 2022
314ccaf
merge in dev and fix conflict in output tests
katie-lamb Mar 10, 2022
26950da
broke up plant part tests, took out pandas terminal width fixture
katie-lamb Mar 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
442 changes: 442 additions & 0 deletions notebooks/work-in-progress/make_master_unit_list_eia.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/pudl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import pudl.analysis.allocate_net_gen
import pudl.analysis.mcoe
import pudl.analysis.plant_parts_eia
import pudl.analysis.service_territory
import pudl.analysis.spatial
import pudl.analysis.state_demand
Expand Down
38 changes: 7 additions & 31 deletions src/pudl/analysis/mcoe.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,8 @@ def capacity_factor(pudl_out, min_cap_fact=0, max_cap_fact=1.5):

Capacity Factor is calculated by using the net generation from eia923 and
the nameplate capacity from eia860. The net gen and capacity are pulled
into one dataframe, then the dates from that dataframe are pulled out to
determine the hours in each period based on the frequency. The number of
hours is used in calculating the capacity factor. Then records with
capacity factors outside the range specified by min_cap_fact and
max_cap_fact are dropped.
into one dataframe and then run through our standard capacity factor
function (``pudl.helpers.calc_capacity_factor()``).
"""
# pudl_out must have a freq, otherwise capacity factor will fail and merges
# between tables with different frequencies will fail
Expand Down Expand Up @@ -370,32 +367,11 @@ def capacity_factor(pudl_out, min_cap_fact=0, max_cap_fact=1.5):
right=gens_eia860,
by=["plant_id_eia", "generator_id"],
)

# get a unique set of dates to generate the number of hours
dates = cf['report_date'].drop_duplicates()
dates_to_hours = pd.DataFrame(
data={'report_date': dates,
'hours': dates.apply(
lambda d: (
pd.date_range(d, periods=2, freq=pudl_out.freq)[1] -
pd.date_range(d, periods=2, freq=pudl_out.freq)[0]) /
pd.Timedelta(hours=1))})

cf = (
# merge in the hours for the calculation
cf.merge(dates_to_hours, on=['report_date'])
# actually calculate capacity factor wooo!
.assign(
capacity_factor=lambda x: x.net_generation_mwh / (x.capacity_mw * x.hours)
)
# Replace unrealistic capacity factors with NaN
.pipe(
pudl.helpers.oob_to_nan,
['capacity_factor'],
lb=min_cap_fact,
ub=max_cap_fact
)
.drop(['hours'], axis=1)
cf = pudl.helpers.calc_capacity_factor(
cf,
min_cap_fact=min_cap_fact,
max_cap_fact=max_cap_fact,
freq=pudl_out.freq
)

return apply_pudl_dtypes(cf, group="eia")
Expand Down
Loading