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

Rename MCOE and plant part list assets #2904

Merged
merged 7 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions docs/templates/package.rst.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ PUDL Data Dictionary
===============================================================================

The following data tables have been cleaned and transformed by our ETL process.
Please note that tables beginning with "denorm" are temporary tables whose names and
metadata will shortly change, as we migrate new tables into our database.

{% for resource in package.resources %}
.. _{{ resource.name.lstrip("_") }}:
{% for resource in package.get_sorted_resources() %}
.. _{{ resource.name|format_resource_name_cross_ref }}:

{% include 'resource.rst.jinja' %}
{% endfor %}
799 changes: 799 additions & 0 deletions migrations/versions/56d425818439_rename_mcoe_and_ppl_assets.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
"""Rename fuel cost by generator asset

Revision ID: 6c66da98c4e1
Revises: 56d425818439
Create Date: 2023-10-02 18:31:16.729897

"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = '6c66da98c4e1'
down_revision = '56d425818439'
branch_labels = None
depends_on = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('_out_eia__monthly_fuel_cost_by_generator',
sa.Column('report_date', sa.Date(), nullable=False, comment='Date reported.'),
sa.Column('plant_id_eia', sa.Integer(), nullable=False, comment='The unique six-digit facility identification number, also called an ORISPL, assigned by the Energy Information Administration.'),
sa.Column('generator_id', sa.Text(), nullable=False, comment='Generator ID is usually numeric, but sometimes includes letters. Make sure you treat it as a string!'),
sa.Column('unit_id_pudl', sa.Integer(), nullable=True, comment='Dynamically assigned PUDL unit id. WARNING: This ID is not guaranteed to be static long term as the input data and algorithm may evolve over time.'),
sa.Column('plant_name_eia', sa.Text(), nullable=True, comment='Plant name.'),
sa.Column('plant_id_pudl', sa.Integer(), nullable=True, comment='A manually assigned PUDL plant ID. May not be constant over time.'),
sa.Column('utility_id_eia', sa.Integer(), nullable=True, comment='The EIA Utility Identification number.'),
sa.Column('utility_name_eia', sa.Text(), nullable=True, comment='The name of the utility.'),
sa.Column('utility_id_pudl', sa.Integer(), nullable=True, comment='A manually assigned PUDL utility ID. May not be stable over time.'),
sa.Column('fuel_type_count', sa.Integer(), nullable=True, comment='A count of how many different simple energy sources there are associated with a generator.'),
sa.Column('fuel_type_code_pudl', sa.Enum('coal', 'gas', 'hydro', 'nuclear', 'oil', 'other', 'solar', 'waste', 'wind'), nullable=True, comment='Simplified fuel type code used in PUDL'),
sa.Column('fuel_cost_from_eiaapi', sa.Boolean(), nullable=True, comment='Indicates whether the fuel cost was derived from the EIA API.'),
sa.Column('fuel_cost_per_mmbtu', sa.Float(), nullable=True, comment='Average fuel cost per mmBTU of heat content in nominal USD.'),
sa.Column('heat_rate_mmbtu_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.'),
sa.Column('fuel_cost_per_mwh', sa.Float(), nullable=True, comment='Derived from MCOE, a unit level value. Average fuel cost per MWh of heat content in nominal USD.'),
sa.ForeignKeyConstraint(['plant_id_eia', 'generator_id'], ['core_eia__entity_generators.plant_id_eia', 'core_eia__entity_generators.generator_id'], name=op.f('fk__out_eia__monthly_fuel_cost_by_generator_plant_id_eia_core_eia__entity_generators')),
sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name=op.f('fk__out_eia__monthly_fuel_cost_by_generator_plant_id_pudl_core_pudl__entity_plants_pudl')),
sa.ForeignKeyConstraint(['utility_id_eia'], ['core_eia__entity_utilities.utility_id_eia'], name=op.f('fk__out_eia__monthly_fuel_cost_by_generator_utility_id_eia_core_eia__entity_utilities')),
sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name=op.f('fk__out_eia__monthly_fuel_cost_by_generator_utility_id_pudl_core_pudl__entity_utilities_pudl')),
sa.PrimaryKeyConstraint('report_date', 'plant_id_eia', 'generator_id', name=op.f('pk__out_eia__monthly_fuel_cost_by_generator'))
)
op.create_table('_out_eia__yearly_fuel_cost_by_generator',
sa.Column('report_date', sa.Date(), nullable=False, comment='Date reported.'),
sa.Column('plant_id_eia', sa.Integer(), nullable=False, comment='The unique six-digit facility identification number, also called an ORISPL, assigned by the Energy Information Administration.'),
sa.Column('generator_id', sa.Text(), nullable=False, comment='Generator ID is usually numeric, but sometimes includes letters. Make sure you treat it as a string!'),
sa.Column('unit_id_pudl', sa.Integer(), nullable=True, comment='Dynamically assigned PUDL unit id. WARNING: This ID is not guaranteed to be static long term as the input data and algorithm may evolve over time.'),
sa.Column('plant_name_eia', sa.Text(), nullable=True, comment='Plant name.'),
sa.Column('plant_id_pudl', sa.Integer(), nullable=True, comment='A manually assigned PUDL plant ID. May not be constant over time.'),
sa.Column('utility_id_eia', sa.Integer(), nullable=True, comment='The EIA Utility Identification number.'),
sa.Column('utility_name_eia', sa.Text(), nullable=True, comment='The name of the utility.'),
sa.Column('utility_id_pudl', sa.Integer(), nullable=True, comment='A manually assigned PUDL utility ID. May not be stable over time.'),
sa.Column('fuel_type_count', sa.Integer(), nullable=True, comment='A count of how many different simple energy sources there are associated with a generator.'),
sa.Column('fuel_type_code_pudl', sa.Enum('coal', 'gas', 'hydro', 'nuclear', 'oil', 'other', 'solar', 'waste', 'wind'), nullable=True, comment='Simplified fuel type code used in PUDL'),
sa.Column('fuel_cost_from_eiaapi', sa.Boolean(), nullable=True, comment='Indicates whether the fuel cost was derived from the EIA API.'),
sa.Column('fuel_cost_per_mmbtu', sa.Float(), nullable=True, comment='Average fuel cost per mmBTU of heat content in nominal USD.'),
sa.Column('heat_rate_mmbtu_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.'),
sa.Column('fuel_cost_per_mwh', sa.Float(), nullable=True, comment='Derived from MCOE, a unit level value. Average fuel cost per MWh of heat content in nominal USD.'),
sa.ForeignKeyConstraint(['plant_id_eia', 'generator_id', 'report_date'], ['core_eia860__scd_generators.plant_id_eia', 'core_eia860__scd_generators.generator_id', 'core_eia860__scd_generators.report_date'], name=op.f('fk__out_eia__yearly_fuel_cost_by_generator_plant_id_eia_core_eia860__scd_generators')),
sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name=op.f('fk__out_eia__yearly_fuel_cost_by_generator_plant_id_pudl_core_pudl__entity_plants_pudl')),
sa.ForeignKeyConstraint(['utility_id_eia', 'report_date'], ['core_eia860__scd_utilities.utility_id_eia', 'core_eia860__scd_utilities.report_date'], name=op.f('fk__out_eia__yearly_fuel_cost_by_generator_utility_id_eia_core_eia860__scd_utilities')),
sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name=op.f('fk__out_eia__yearly_fuel_cost_by_generator_utility_id_pudl_core_pudl__entity_utilities_pudl')),
sa.PrimaryKeyConstraint('report_date', 'plant_id_eia', 'generator_id', name=op.f('pk__out_eia__yearly_fuel_cost_by_generator'))
)
op.drop_table('fuel_cost_by_generator_yearly')
op.drop_table('fuel_cost_by_generator_monthly')
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('fuel_cost_by_generator_monthly',
sa.Column('report_date', sa.DATE(), nullable=False),
sa.Column('plant_id_eia', sa.INTEGER(), nullable=False),
sa.Column('generator_id', sa.TEXT(), nullable=False),
sa.Column('unit_id_pudl', sa.INTEGER(), nullable=True),
sa.Column('plant_name_eia', sa.TEXT(), nullable=True),
sa.Column('plant_id_pudl', sa.INTEGER(), nullable=True),
sa.Column('utility_id_eia', sa.INTEGER(), nullable=True),
sa.Column('utility_name_eia', sa.TEXT(), nullable=True),
sa.Column('utility_id_pudl', sa.INTEGER(), nullable=True),
sa.Column('fuel_type_count', sa.INTEGER(), nullable=True),
sa.Column('fuel_type_code_pudl', sa.VARCHAR(length=7), nullable=True),
sa.Column('fuel_cost_from_eiaapi', sa.BOOLEAN(), nullable=True),
sa.Column('fuel_cost_per_mmbtu', sa.FLOAT(), nullable=True),
sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True),
sa.Column('fuel_cost_per_mwh', sa.FLOAT(), nullable=True),
sa.ForeignKeyConstraint(['plant_id_eia', 'generator_id', 'report_date'], ['core_eia860__scd_generators.plant_id_eia', 'core_eia860__scd_generators.generator_id', 'core_eia860__scd_generators.report_date'], name='fk_fuel_cost_by_generator_monthly_plant_id_eia_core_eia860__scd_generators'),
sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_fuel_cost_by_generator_monthly_plant_id_pudl_core_pudl__entity_plants_pudl'),
sa.ForeignKeyConstraint(['utility_id_eia', 'report_date'], ['core_eia860__scd_utilities.utility_id_eia', 'core_eia860__scd_utilities.report_date'], name='fk_fuel_cost_by_generator_monthly_utility_id_eia_core_eia860__scd_utilities'),
sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_fuel_cost_by_generator_monthly_utility_id_pudl_core_pudl__entity_utilities_pudl'),
sa.PrimaryKeyConstraint('report_date', 'plant_id_eia', 'generator_id', name='pk_fuel_cost_by_generator_monthly')
)
op.create_table('fuel_cost_by_generator_yearly',
sa.Column('report_date', sa.DATE(), nullable=False),
sa.Column('plant_id_eia', sa.INTEGER(), nullable=False),
sa.Column('generator_id', sa.TEXT(), nullable=False),
sa.Column('unit_id_pudl', sa.INTEGER(), nullable=True),
sa.Column('plant_name_eia', sa.TEXT(), nullable=True),
sa.Column('plant_id_pudl', sa.INTEGER(), nullable=True),
sa.Column('utility_id_eia', sa.INTEGER(), nullable=True),
sa.Column('utility_name_eia', sa.TEXT(), nullable=True),
sa.Column('utility_id_pudl', sa.INTEGER(), nullable=True),
sa.Column('fuel_type_count', sa.INTEGER(), nullable=True),
sa.Column('fuel_type_code_pudl', sa.VARCHAR(length=7), nullable=True),
sa.Column('fuel_cost_from_eiaapi', sa.BOOLEAN(), nullable=True),
sa.Column('fuel_cost_per_mmbtu', sa.FLOAT(), nullable=True),
sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True),
sa.Column('fuel_cost_per_mwh', sa.FLOAT(), nullable=True),
sa.ForeignKeyConstraint(['plant_id_eia', 'generator_id', 'report_date'], ['core_eia860__scd_generators.plant_id_eia', 'core_eia860__scd_generators.generator_id', 'core_eia860__scd_generators.report_date'], name='fk_fuel_cost_by_generator_yearly_plant_id_eia_core_eia860__scd_generators'),
sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_fuel_cost_by_generator_yearly_plant_id_pudl_core_pudl__entity_plants_pudl'),
sa.ForeignKeyConstraint(['utility_id_eia', 'report_date'], ['core_eia860__scd_utilities.utility_id_eia', 'core_eia860__scd_utilities.report_date'], name='fk_fuel_cost_by_generator_yearly_utility_id_eia_core_eia860__scd_utilities'),
sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_fuel_cost_by_generator_yearly_utility_id_pudl_core_pudl__entity_utilities_pudl'),
sa.PrimaryKeyConstraint('report_date', 'plant_id_eia', 'generator_id', name='pk_fuel_cost_by_generator_yearly')
)
op.drop_table('_out_eia__yearly_fuel_cost_by_generator')
op.drop_table('_out_eia__monthly_fuel_cost_by_generator')
# ### end Alembic commands ###