Skip to content

Commit

Permalink
Rename heat_rate_mmbtu_mwh -> heat_rate_mmbtu_mwh_by_unit (#2917)
Browse files Browse the repository at this point in the history
* Rename heat_rate_mmbtu_mwh -> heat_rate_mmbtu_mwh_by_unit

* Rename heat rate mmbtu mwh to follow existing naming convention
  • Loading branch information
bendnorman authored Oct 5, 2023
1 parent 799282a commit 4260c2e
Show file tree
Hide file tree
Showing 11 changed files with 280 additions and 35 deletions.
121 changes: 121 additions & 0 deletions migrations/versions/1e4356aa41cf_rename_heat_rate_column_to_follow_.py
Original file line number Diff line number Diff line change
@@ -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 ###
Original file line number Diff line number Diff line change
@@ -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 ###
12 changes: 7 additions & 5 deletions src/pudl/analysis/ferc1_eia.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/pudl/analysis/ferc1_eia_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"total_fuel_cost",
"total_mmbtu",
"fuel_cost_per_mmbtu",
"heat_rate_mmbtu_mwh",
"unit_heat_rate_mmbtu_per_mwh",
]

# --------------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 4260c2e

Please sign in to comment.