-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EIA 923 energy storage transform (#3546)
* Move the fix_boolean_columns function to the helpers module so that it can be used for EIA923 as well as EIA860. This can probably be combined with the existing convert_col_to_bool function, but keeping both for now * Add beginnings of a _core_eia923_energy_storage table function. Paused to fix the issues with encoding in the EIA modules * Finish transformer for EIA 923 energy storage table: dquote> - Update names of the total columns to match the monthly columns dquote> - Change the table from yearly to monthly dquote> - Add new fields - Add new migration * Update doc strings to fix build fail * Make migrations compatible with main * Small resource/field metadata updates. * minor data cleaning for the EIA-923 energy storage table. * Add foreign_key_rules to the core_eia__codes_storage_technology_types and core_eia__codes_storage_enclosure_types tables -- this should have been part of the EIA860 storage table PR * Clarify description of core_eia923__monthly_energy_storage table * Add migration for new foreign key relationships * Add data_maturity field to the cooling_system table --------- Co-authored-by: Zane Selvans <[email protected]>
- Loading branch information
1 parent
568dbfa
commit d37d630
Showing
14 changed files
with
291 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
migrations/versions/172898b30824_add_data_maturity_to_eia923_cooling_.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Add data_maturity to EIA923 cooling system table | ||
Revision ID: 172898b30824 | ||
Revises: 823e58cbf0e0 | ||
Create Date: 2024-04-10 13:36:48.866852 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '172898b30824' | ||
down_revision = '823e58cbf0e0' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('_core_eia923__cooling_system_information', schema=None) as batch_op: | ||
batch_op.add_column(sa.Column('data_maturity', sa.Text(), nullable=True, comment='Level of maturity of the data record. Some data sources report less-than-final data. PUDL sometimes includes this data, but use at your own risk.')) | ||
batch_op.create_foreign_key(batch_op.f('fk__core_eia923__cooling_system_information_data_maturity_core_pudl__codes_data_maturities'), 'core_pudl__codes_data_maturities', ['data_maturity'], ['code']) | ||
|
||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('_core_eia923__cooling_system_information', schema=None) as batch_op: | ||
batch_op.drop_constraint(batch_op.f('fk__core_eia923__cooling_system_information_data_maturity_core_pudl__codes_data_maturities'), type_='foreignkey') | ||
batch_op.drop_column('data_maturity') | ||
|
||
# ### end Alembic commands ### |
44 changes: 44 additions & 0 deletions
44
migrations/versions/4e14f531f5d6_add_eia923_energy_storage_monthly_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"""Add EIA923 Energy Storage monthly table | ||
Revision ID: 4e14f531f5d6 | ||
Revises: 00e4382815d9 | ||
Create Date: 2024-04-09 11:57:50.890543 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '4e14f531f5d6' | ||
down_revision = '00e4382815d9' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table('core_eia923__monthly_energy_storage', | ||
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('report_date', sa.Date(), nullable=False, comment='Date reported.'), | ||
sa.Column('prime_mover_code', sa.Text(), nullable=False, comment='Code for the type of prime mover (e.g. CT, CG)'), | ||
sa.Column('energy_source_code', sa.Text(), nullable=False, comment='A 2-3 letter code indicating the energy source (e.g. fuel type) associated with the record.'), | ||
sa.Column('data_maturity', sa.Text(), nullable=True, comment='Level of maturity of the data record. Some data sources report less-than-final data. PUDL sometimes includes this data, but use at your own risk.'), | ||
sa.Column('fuel_units', sa.Enum('barrels', 'mcf', 'mwh', 'short_tons'), nullable=True, comment='Reported unit of measure for fuel.'), | ||
sa.Column('fuel_consumed_for_electricity_units', sa.Float(), nullable=True, comment='Consumption for electric generation of the fuel type in physical unit.'), | ||
sa.Column('fuel_consumed_units', sa.Float(), nullable=True, comment='Consumption of the fuel type in physical unit. Note: this is the total quantity consumed for both electricity and, in the case of combined heat and power plants, process steam production.'), | ||
sa.Column('gross_generation_mwh', sa.Float(), nullable=True, comment='Gross electricity generation for the specified period in megawatt-hours (MWh).'), | ||
sa.Column('net_generation_mwh', sa.Float(), nullable=True, comment='Net electricity generation for the specified period in megawatt-hours (MWh).'), | ||
sa.ForeignKeyConstraint(['data_maturity'], ['core_pudl__codes_data_maturities.code'], name=op.f('fk_core_eia923__monthly_energy_storage_data_maturity_core_pudl__codes_data_maturities')), | ||
sa.ForeignKeyConstraint(['energy_source_code'], ['core_eia__codes_energy_sources.code'], name=op.f('fk_core_eia923__monthly_energy_storage_energy_source_code_core_eia__codes_energy_sources')), | ||
sa.ForeignKeyConstraint(['plant_id_eia'], ['core_eia__entity_plants.plant_id_eia'], name=op.f('fk_core_eia923__monthly_energy_storage_plant_id_eia_core_eia__entity_plants')), | ||
sa.ForeignKeyConstraint(['prime_mover_code'], ['core_eia__codes_prime_movers.code'], name=op.f('fk_core_eia923__monthly_energy_storage_prime_mover_code_core_eia__codes_prime_movers')), | ||
sa.PrimaryKeyConstraint('plant_id_eia', 'report_date', 'prime_mover_code', 'energy_source_code', name=op.f('pk_core_eia923__monthly_energy_storage')) | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table('core_eia923__monthly_energy_storage') | ||
# ### end Alembic commands ### |
40 changes: 40 additions & 0 deletions
40
migrations/versions/823e58cbf0e0_update_foreign_key_relationships_for_.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""Update foreign key relationships for EIA860 storage coding tables | ||
Revision ID: 823e58cbf0e0 | ||
Revises: 4e14f531f5d6 | ||
Create Date: 2024-04-10 12:50:46.401285 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '823e58cbf0e0' | ||
down_revision = '4e14f531f5d6' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('core_eia860__scd_generators_energy_storage', schema=None) as batch_op: | ||
batch_op.create_foreign_key(batch_op.f('fk_core_eia860__scd_generators_energy_storage_storage_enclosure_code_core_eia__codes_storage_enclosure_types'), 'core_eia__codes_storage_enclosure_types', ['storage_enclosure_code'], ['code']) | ||
batch_op.create_foreign_key(batch_op.f('fk_core_eia860__scd_generators_energy_storage_storage_technology_code_3_core_eia__codes_storage_technology_types'), 'core_eia__codes_storage_technology_types', ['storage_technology_code_3'], ['code']) | ||
batch_op.create_foreign_key(batch_op.f('fk_core_eia860__scd_generators_energy_storage_storage_technology_code_4_core_eia__codes_storage_technology_types'), 'core_eia__codes_storage_technology_types', ['storage_technology_code_4'], ['code']) | ||
batch_op.create_foreign_key(batch_op.f('fk_core_eia860__scd_generators_energy_storage_storage_technology_code_2_core_eia__codes_storage_technology_types'), 'core_eia__codes_storage_technology_types', ['storage_technology_code_2'], ['code']) | ||
batch_op.create_foreign_key(batch_op.f('fk_core_eia860__scd_generators_energy_storage_storage_technology_code_1_core_eia__codes_storage_technology_types'), 'core_eia__codes_storage_technology_types', ['storage_technology_code_1'], ['code']) | ||
|
||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('core_eia860__scd_generators_energy_storage', schema=None) as batch_op: | ||
batch_op.drop_constraint(batch_op.f('fk_core_eia860__scd_generators_energy_storage_storage_technology_code_1_core_eia__codes_storage_technology_types'), type_='foreignkey') | ||
batch_op.drop_constraint(batch_op.f('fk_core_eia860__scd_generators_energy_storage_storage_technology_code_2_core_eia__codes_storage_technology_types'), type_='foreignkey') | ||
batch_op.drop_constraint(batch_op.f('fk_core_eia860__scd_generators_energy_storage_storage_technology_code_4_core_eia__codes_storage_technology_types'), type_='foreignkey') | ||
batch_op.drop_constraint(batch_op.f('fk_core_eia860__scd_generators_energy_storage_storage_technology_code_3_core_eia__codes_storage_technology_types'), type_='foreignkey') | ||
batch_op.drop_constraint(batch_op.f('fk_core_eia860__scd_generators_energy_storage_storage_enclosure_code_core_eia__codes_storage_enclosure_types'), type_='foreignkey') | ||
|
||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.