From 4260c2e31fc12e6fc03ad0dacaabb17d2b1057d0 Mon Sep 17 00:00:00 2001 From: Bennett Norman Date: Thu, 5 Oct 2023 10:13:03 -0800 Subject: [PATCH] Rename `heat_rate_mmbtu_mwh -> heat_rate_mmbtu_mwh_by_unit` (#2917) * Rename heat_rate_mmbtu_mwh -> heat_rate_mmbtu_mwh_by_unit * Rename heat rate mmbtu mwh to follow existing naming convention --- ...41cf_rename_heat_rate_column_to_follow_.py | 121 ++++++++++++++++++ ...ename_heat_rate_mmbtu_mwh_to_heat_rate_.py | 121 ++++++++++++++++++ src/pudl/analysis/ferc1_eia.py | 12 +- src/pudl/analysis/ferc1_eia_train.py | 2 +- src/pudl/analysis/mcoe.py | 25 ++-- src/pudl/analysis/plant_parts_eia.py | 2 +- src/pudl/metadata/fields.py | 2 +- src/pudl/metadata/resources/eia.py | 4 +- src/pudl/metadata/resources/mcoe.py | 10 +- src/pudl/validate.py | 12 +- test/unit/analysis/plant_parts_eia_test.py | 4 +- 11 files changed, 280 insertions(+), 35 deletions(-) create mode 100644 migrations/versions/1e4356aa41cf_rename_heat_rate_column_to_follow_.py create mode 100644 migrations/versions/c415b55c4dcf_rename_heat_rate_mmbtu_mwh_to_heat_rate_.py diff --git a/migrations/versions/1e4356aa41cf_rename_heat_rate_column_to_follow_.py b/migrations/versions/1e4356aa41cf_rename_heat_rate_column_to_follow_.py new file mode 100644 index 0000000000..7428946be9 --- /dev/null +++ b/migrations/versions/1e4356aa41cf_rename_heat_rate_column_to_follow_.py @@ -0,0 +1,121 @@ +"""Rename heat rate column to follow column naming convention + +Revision ID: 1e4356aa41cf +Revises: c415b55c4dcf +Create Date: 2023-10-04 20:00:29.217602 + +""" +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = '1e4356aa41cf' +down_revision = 'c415b55c4dcf' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('_out_eia__monthly_derived_generator_attributes', schema=None) as batch_op: + batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + with op.batch_alter_table('_out_eia__monthly_fuel_cost_by_generator', schema=None) as batch_op: + batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + with op.batch_alter_table('_out_eia__monthly_heat_rate_by_generator', schema=None) as batch_op: + batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + with op.batch_alter_table('_out_eia__monthly_heat_rate_by_unit', schema=None) as batch_op: + batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + with op.batch_alter_table('_out_eia__yearly_derived_generator_attributes', schema=None) as batch_op: + batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + with op.batch_alter_table('_out_eia__yearly_fuel_cost_by_generator', schema=None) as batch_op: + batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + with op.batch_alter_table('_out_eia__yearly_heat_rate_by_generator', schema=None) as batch_op: + batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + with op.batch_alter_table('_out_eia__yearly_heat_rate_by_unit', schema=None) as batch_op: + batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + with op.batch_alter_table('out_eia__monthly_generators', schema=None) as batch_op: + batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + with op.batch_alter_table('out_eia__plant_parts', schema=None) as batch_op: + batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + with op.batch_alter_table('out_eia__yearly_generators', schema=None) as batch_op: + batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + with op.batch_alter_table('out_eia__yearly_generators_by_ownership', schema=None) as batch_op: + batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('out_eia__yearly_generators_by_ownership', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.FLOAT(), nullable=True)) + batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') + + with op.batch_alter_table('out_eia__yearly_generators', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.FLOAT(), nullable=True)) + batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') + + with op.batch_alter_table('out_eia__plant_parts', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.FLOAT(), nullable=True)) + batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') + + with op.batch_alter_table('out_eia__monthly_generators', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.FLOAT(), nullable=True)) + batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') + + with op.batch_alter_table('_out_eia__yearly_heat_rate_by_unit', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.FLOAT(), nullable=True)) + batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') + + with op.batch_alter_table('_out_eia__yearly_heat_rate_by_generator', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.FLOAT(), nullable=True)) + batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') + + with op.batch_alter_table('_out_eia__yearly_fuel_cost_by_generator', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.FLOAT(), nullable=True)) + batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') + + with op.batch_alter_table('_out_eia__yearly_derived_generator_attributes', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.FLOAT(), nullable=True)) + batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') + + with op.batch_alter_table('_out_eia__monthly_heat_rate_by_unit', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.FLOAT(), nullable=True)) + batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') + + with op.batch_alter_table('_out_eia__monthly_heat_rate_by_generator', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.FLOAT(), nullable=True)) + batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') + + with op.batch_alter_table('_out_eia__monthly_fuel_cost_by_generator', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.FLOAT(), nullable=True)) + batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') + + with op.batch_alter_table('_out_eia__monthly_derived_generator_attributes', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.FLOAT(), nullable=True)) + batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') + + # ### end Alembic commands ### diff --git a/migrations/versions/c415b55c4dcf_rename_heat_rate_mmbtu_mwh_to_heat_rate_.py b/migrations/versions/c415b55c4dcf_rename_heat_rate_mmbtu_mwh_to_heat_rate_.py new file mode 100644 index 0000000000..e5e2f9d299 --- /dev/null +++ b/migrations/versions/c415b55c4dcf_rename_heat_rate_mmbtu_mwh_to_heat_rate_.py @@ -0,0 +1,121 @@ +"""Rename heat_rate_mmbtu_mwh to heat_rate_mmbtu_mwh_by_unit + +Revision ID: c415b55c4dcf +Revises: ab0540a6484c +Create Date: 2023-10-04 08:08:23.744433 + +""" +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = 'c415b55c4dcf' +down_revision = 'ab0540a6484c' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('_out_eia__monthly_derived_generator_attributes', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh') + + with op.batch_alter_table('_out_eia__monthly_fuel_cost_by_generator', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh') + + with op.batch_alter_table('_out_eia__monthly_heat_rate_by_generator', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh') + + with op.batch_alter_table('_out_eia__monthly_heat_rate_by_unit', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh') + + with op.batch_alter_table('_out_eia__yearly_derived_generator_attributes', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh') + + with op.batch_alter_table('_out_eia__yearly_fuel_cost_by_generator', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh') + + with op.batch_alter_table('_out_eia__yearly_heat_rate_by_generator', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh') + + with op.batch_alter_table('_out_eia__yearly_heat_rate_by_unit', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh') + + with op.batch_alter_table('out_eia__monthly_generators', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh') + + with op.batch_alter_table('out_eia__plant_parts', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh') + + with op.batch_alter_table('out_eia__yearly_generators', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh') + + with op.batch_alter_table('out_eia__yearly_generators_by_ownership', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_by_unit', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) + batch_op.drop_column('heat_rate_mmbtu_mwh') + + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('out_eia__yearly_generators_by_ownership', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + with op.batch_alter_table('out_eia__yearly_generators', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + with op.batch_alter_table('out_eia__plant_parts', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + with op.batch_alter_table('out_eia__monthly_generators', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + with op.batch_alter_table('_out_eia__yearly_heat_rate_by_unit', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + with op.batch_alter_table('_out_eia__yearly_heat_rate_by_generator', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + with op.batch_alter_table('_out_eia__yearly_fuel_cost_by_generator', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + with op.batch_alter_table('_out_eia__yearly_derived_generator_attributes', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + with op.batch_alter_table('_out_eia__monthly_heat_rate_by_unit', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + with op.batch_alter_table('_out_eia__monthly_heat_rate_by_generator', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + with op.batch_alter_table('_out_eia__monthly_fuel_cost_by_generator', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + with op.batch_alter_table('_out_eia__monthly_derived_generator_attributes', schema=None) as batch_op: + batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) + batch_op.drop_column('heat_rate_mmbtu_mwh_by_unit') + + # ### end Alembic commands ### diff --git a/src/pudl/analysis/ferc1_eia.py b/src/pudl/analysis/ferc1_eia.py index 875209644e..c8a95e91bd 100644 --- a/src/pudl/analysis/ferc1_eia.py +++ b/src/pudl/analysis/ferc1_eia.py @@ -193,7 +193,9 @@ def get_plants_ferc1(self, clobber: bool = False) -> pd.DataFrame: x.plant_id_report_year + "_" + x.utility_id_pudl.map(str) ), fuel_cost_per_mmbtu=lambda x: (x.fuel_cost / x.fuel_mmbtu), - heat_rate_mmbtu_mwh=lambda x: (x.fuel_mmbtu / x.net_generation_mwh), + unit_heat_rate_mmbtu_per_mwh=lambda x: ( + x.fuel_mmbtu / x.net_generation_mwh + ), ) .rename( columns={ @@ -403,9 +405,9 @@ def make_features( label="fuel_cost_per_mmbtu", ), Numeric( - "heat_rate_mmbtu_mwh", - "heat_rate_mmbtu_mwh", - label="heat_rate_mmbtu_mwh", + "unit_heat_rate_mmbtu_per_mwh", + "unit_heat_rate_mmbtu_per_mwh", + label="unit_heat_rate_mmbtu_per_mwh", ), Exact( "fuel_type_code_pudl", @@ -808,7 +810,7 @@ def prettyify_best_matches( "capacity_mw", "capacity_factor", "total_mmbtu", - "heat_rate_mmbtu_mwh", + "unit_heat_rate_mmbtu_per_mwh", "fuel_type_code_pudl", "installation_year", "plant_part_id_eia", diff --git a/src/pudl/analysis/ferc1_eia_train.py b/src/pudl/analysis/ferc1_eia_train.py index 2ff798bb8e..ed01a43701 100644 --- a/src/pudl/analysis/ferc1_eia_train.py +++ b/src/pudl/analysis/ferc1_eia_train.py @@ -103,7 +103,7 @@ "total_fuel_cost", "total_mmbtu", "fuel_cost_per_mmbtu", - "heat_rate_mmbtu_mwh", + "unit_heat_rate_mmbtu_per_mwh", ] # -------------------------------------------------------------------------------------- diff --git a/src/pudl/analysis/mcoe.py b/src/pudl/analysis/mcoe.py index bfa96da89b..1771f3b840 100644 --- a/src/pudl/analysis/mcoe.py +++ b/src/pudl/analysis/mcoe.py @@ -285,7 +285,7 @@ def heat_rate_by_unit(gen_fuel_by_energy_source: pd.DataFrame, bga: pd.DataFrame - unit_id_pudl - net_generation_mwh - fuel_consumed_for_electricity_mmbtu - - heat_rate_mmbtu_mwh + - unit_heat_rate_mmbtu_per_mwh """ gen_fuel_by_unit = pudl.helpers.date_merge( left=gen_fuel_by_energy_source, @@ -301,7 +301,7 @@ def heat_rate_by_unit(gen_fuel_by_energy_source: pd.DataFrame, bga: pd.DataFrame .sum() .convert_dtypes() .assign( - heat_rate_mmbtu_mwh=lambda x: x.fuel_consumed_for_electricity_mmbtu + unit_heat_rate_mmbtu_per_mwh=lambda x: x.fuel_consumed_for_electricity_mmbtu / x.net_generation_mwh ) ) @@ -326,7 +326,7 @@ def heat_rate_by_gen( Returns: DataFrame with columns report_date, plant_id_eia, unit_id_pudl, generator_id, - heat_rate_mmbtu_mwh, fuel_type_code_pudl, fuel_type_count, prime_mover_code. + unit_heat_rate_mmbtu_per_mwh, fuel_type_code_pudl, fuel_type_count, prime_mover_code. The output will have a time frequency corresponding to that of the input pudl_out. Output data types are set to their canonical values before returning. """ @@ -339,7 +339,7 @@ def heat_rate_by_gen( "report_date", "plant_id_eia", "unit_id_pudl", - "heat_rate_mmbtu_mwh", + "unit_heat_rate_mmbtu_per_mwh", ], ] @@ -404,7 +404,7 @@ def fuel_cost( "generator_id", "unit_id_pudl", "report_date", - "heat_rate_mmbtu_mwh", + "unit_heat_rate_mmbtu_per_mwh", ], ] gens = gens.loc[ @@ -515,7 +515,7 @@ def fuel_cost( "plant_id_eia", "report_date", "generator_id", - "heat_rate_mmbtu_mwh", + "unit_heat_rate_mmbtu_per_mwh", "fuel_cost_from_eiaapi", ] ], @@ -532,7 +532,7 @@ def fuel_cost( "report_date", "generator_id", "fuel_cost_per_mmbtu", - "heat_rate_mmbtu_mwh", + "unit_heat_rate_mmbtu_per_mwh", "fuel_cost_from_eiaapi", ] ] @@ -540,13 +540,14 @@ def fuel_cost( fc = ( pd.concat([one_fuel, multi_fuel], sort=True) .assign( - fuel_cost_per_mwh=lambda x: x.fuel_cost_per_mmbtu * x.heat_rate_mmbtu_mwh + fuel_cost_per_mwh=lambda x: x.fuel_cost_per_mmbtu + * x.unit_heat_rate_mmbtu_per_mwh ) .sort_values(["report_date", "plant_id_eia", "generator_id"]) ) out_df = ( - gen_w_ft.drop("heat_rate_mmbtu_mwh", axis=1) + gen_w_ft.drop("unit_heat_rate_mmbtu_per_mwh", axis=1) .drop_duplicates() .merge(fc, on=["report_date", "plant_id_eia", "generator_id"]) ) @@ -633,7 +634,7 @@ def mcoe( "unit_id_pudl", "fuel_cost_from_eiaapi", "fuel_cost_per_mmbtu", - "heat_rate_mmbtu_mwh", + "unit_heat_rate_mmbtu_per_mwh", "fuel_cost_per_mwh", ], ], @@ -645,12 +646,12 @@ def mcoe( ) # Calculate a couple more derived values: .assign( - total_mmbtu=lambda x: x.net_generation_mwh * x.heat_rate_mmbtu_mwh, + total_mmbtu=lambda x: x.net_generation_mwh * x.unit_heat_rate_mmbtu_per_mwh, total_fuel_cost=lambda x: x.total_mmbtu * x.fuel_cost_per_mmbtu, ) .pipe( pudl.helpers.oob_to_nan_with_dependent_cols, - cols=["heat_rate_mmbtu_mwh"], + cols=["unit_heat_rate_mmbtu_per_mwh"], dependent_cols=["total_mmbtu", "fuel_cost_per_mwh"], lb=min_heat_rate, ub=None, diff --git a/src/pudl/analysis/plant_parts_eia.py b/src/pudl/analysis/plant_parts_eia.py index 819157eb76..9a5051c159 100644 --- a/src/pudl/analysis/plant_parts_eia.py +++ b/src/pudl/analysis/plant_parts_eia.py @@ -281,7 +281,7 @@ WTAVG_DICT = { "fuel_cost_per_mwh": "capacity_mw", - "heat_rate_mmbtu_mwh": "capacity_mw", + "unit_heat_rate_mmbtu_per_mwh": "capacity_mw", "fuel_cost_per_mmbtu": "capacity_mw", } """Dict: a dictionary of columns (keys) to perform weighted averages on and the weight diff --git a/src/pudl/metadata/fields.py b/src/pudl/metadata/fields.py index 34d9c912d2..7d63c6b2f5 100644 --- a/src/pudl/metadata/fields.py +++ b/src/pudl/metadata/fields.py @@ -1159,7 +1159,7 @@ "description": "The energy contained in fuel burned, measured in million BTU.", "unit": "MMBtu", }, - "heat_rate_mmbtu_mwh": { + "unit_heat_rate_mmbtu_per_mwh": { "type": "number", "description": "Fuel content per unit of electricity generated. Coming from MCOE calculation.", "unit": "MMBtu_MWh", diff --git a/src/pudl/metadata/resources/eia.py b/src/pudl/metadata/resources/eia.py index d4bd30e9b1..be3a086d10 100644 --- a/src/pudl/metadata/resources/eia.py +++ b/src/pudl/metadata/resources/eia.py @@ -551,7 +551,7 @@ "fuel_cost_from_eiaapi", "fuel_cost_per_mmbtu", "fuel_cost_per_mwh", - "heat_rate_mmbtu_mwh", + "unit_heat_rate_mmbtu_per_mwh", "net_generation_mwh", "total_fuel_cost", "total_mmbtu", @@ -651,7 +651,7 @@ "fuel_cost_per_mwh", "fuel_type_code_pudl", "generator_retirement_date", - "heat_rate_mmbtu_mwh", + "unit_heat_rate_mmbtu_per_mwh", "installation_year", "net_generation_mwh", "generator_operating_year", diff --git a/src/pudl/metadata/resources/mcoe.py b/src/pudl/metadata/resources/mcoe.py index 2b738a3e3d..740506d7fd 100644 --- a/src/pudl/metadata/resources/mcoe.py +++ b/src/pudl/metadata/resources/mcoe.py @@ -24,7 +24,7 @@ "unit_id_pudl", "net_generation_mwh", "fuel_consumed_for_electricity_mmbtu", - "heat_rate_mmbtu_mwh", + "unit_heat_rate_mmbtu_per_mwh", ], "primary_key": [ "report_date", @@ -53,7 +53,7 @@ "plant_id_eia", "unit_id_pudl", "generator_id", - "heat_rate_mmbtu_mwh", + "unit_heat_rate_mmbtu_per_mwh", "fuel_type_code_pudl", "fuel_type_count", "prime_mover_code", @@ -126,7 +126,7 @@ "fuel_type_code_pudl", "fuel_cost_from_eiaapi", "fuel_cost_per_mmbtu", - "heat_rate_mmbtu_mwh", + "unit_heat_rate_mmbtu_per_mwh", "fuel_cost_per_mwh", ], "primary_key": [ @@ -165,7 +165,7 @@ "fuel_cost_from_eiaapi", "fuel_cost_per_mmbtu", "fuel_cost_per_mwh", - "heat_rate_mmbtu_mwh", + "unit_heat_rate_mmbtu_per_mwh", "net_generation_mwh", "total_fuel_cost", "total_mmbtu", @@ -212,7 +212,7 @@ "fuel_cost_from_eiaapi", "fuel_cost_per_mmbtu", "fuel_cost_per_mwh", - "heat_rate_mmbtu_mwh", + "unit_heat_rate_mmbtu_per_mwh", "net_generation_mwh", "total_fuel_cost", "total_mmbtu", diff --git a/src/pudl/validate.py b/src/pudl/validate.py index 114c6dba7c..15955052c7 100644 --- a/src/pudl/validate.py +++ b/src/pudl/validate.py @@ -2657,7 +2657,7 @@ def plot_vs_agg(orig_df, agg_df, validation_cases): "low_bound": 7.0, "hi_q": 0.50, "hi_bound": 7.5, - "data_col": "heat_rate_mmbtu_mwh", + "data_col": "unit_heat_rate_mmbtu_per_mwh", "weight_col": "net_generation_mwh", }, { # EIA natural gas reporting really only becomes usable in 2015. @@ -2667,7 +2667,7 @@ def plot_vs_agg(orig_df, agg_df, validation_cases): "low_bound": 6.4, "hi_q": 0.95, "hi_bound": 13.0, - "data_col": "heat_rate_mmbtu_mwh", + "data_col": "unit_heat_rate_mmbtu_per_mwh", "weight_col": "net_generation_mwh", }, ] @@ -2681,7 +2681,7 @@ def plot_vs_agg(orig_df, agg_df, validation_cases): "low_bound": 10.0, "hi_q": 0.50, "hi_bound": 11.0, - "data_col": "heat_rate_mmbtu_mwh", + "data_col": "unit_heat_rate_mmbtu_per_mwh", "weight_col": "net_generation_mwh", }, { @@ -2691,7 +2691,7 @@ def plot_vs_agg(orig_df, agg_df, validation_cases): "low_bound": 9.0, "hi_q": 0.95, "hi_bound": 12.5, - "data_col": "heat_rate_mmbtu_mwh", + "data_col": "unit_heat_rate_mmbtu_per_mwh", "weight_col": "net_generation_mwh", }, ] @@ -2857,7 +2857,7 @@ def plot_vs_agg(orig_df, agg_df, validation_cases): "low_q": 0.05, "mid_q": 0.50, "hi_q": 0.95, - "data_col": "heat_rate_mmbtu_mwh", + "data_col": "unit_heat_rate_mmbtu_per_mwh", "weight_col": "net_generation_mwh", }, { @@ -2866,7 +2866,7 @@ def plot_vs_agg(orig_df, agg_df, validation_cases): "low_q": 0.05, "mid_q": 0.50, "hi_q": 0.95, - "data_col": "heat_rate_mmbtu_mwh", + "data_col": "unit_heat_rate_mmbtu_per_mwh", "weight_col": "net_generation_mwh", }, ] diff --git a/test/unit/analysis/plant_parts_eia_test.py b/test/unit/analysis/plant_parts_eia_test.py index 7eed73c2b2..b45fcf31a4 100644 --- a/test/unit/analysis/plant_parts_eia_test.py +++ b/test/unit/analysis/plant_parts_eia_test.py @@ -535,7 +535,7 @@ def test_one_to_many(): "net_generation_mwh": [100] * 8, "total_fuel_cost": [100] * 8, "fuel_cost_per_mwh": [1] * 8, - "heat_rate_mmbtu_mwh": [1] * 8, + "unit_heat_rate_mmbtu_per_mwh": [1] * 8, "fuel_cost_per_mmbtu": [1] * 8, "fuel_type_code_pudl": ["test"] * 8, "planned_generator_retirement_date": [2076] * 8, @@ -622,7 +622,7 @@ def test_one_to_many(): "net_generation_mwh": [100, 100, 100, 100, 100, 100, 100, 100, 200], "total_fuel_cost": [100, 100, 100, 100, 100, 100, 100, 100, 200], "fuel_cost_per_mwh": [1] * 9, - "heat_rate_mmbtu_mwh": [1] * 9, + "unit_heat_rate_mmbtu_per_mwh": [1] * 9, "fuel_cost_per_mmbtu": [1] * 9, "fuel_type_code_pudl": ["test"] * 9, "planned_generator_retirement_date": [2076] * 9,