-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make new extractor compatible with 2021 data
The new extractor added some data to the 2021 XBRL archives. This caused some integration and validation test fails. I added some plants to the pudl_id mapping spreadsheet, all of which are considered totals. I.e., not real plants, but we're mapping them for the sake of giving them an ID (they are not connected to EIA records). Because this is how we treat other total records reported to FERC1. This also updates the way that values were assigned to a slice of the ferc1_eia_train output spreadsheets. NA values were causing an issue, so I had to change how the values were being converted. This also updates the test_minmax_rows test to reflect the new rows in the 2021 data.
- Loading branch information
Showing
5 changed files
with
301 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,244 @@ | ||
"""idk | ||
Revision ID: 11a43f756905 | ||
Revises: 273a78878b74 | ||
Create Date: 2023-09-25 13:06:55.676082 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "11a43f756905" | ||
down_revision = "273a78878b74" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table( | ||
"denorm_depreciation_amortization_summary_ferc1", schema=None | ||
) as batch_op: | ||
batch_op.add_column( | ||
sa.Column( | ||
"utility_type", | ||
sa.Text(), | ||
nullable=True, | ||
comment="Listing of utility plant types. Examples include Electric Utility, Gas Utility, and Other Utility.", | ||
) | ||
) | ||
|
||
with op.batch_alter_table( | ||
"denorm_electric_operating_expenses_ferc1", schema=None | ||
) as batch_op: | ||
batch_op.add_column( | ||
sa.Column( | ||
"utility_type", | ||
sa.Text(), | ||
nullable=True, | ||
comment="Listing of utility plant types. Examples include Electric Utility, Gas Utility, and Other Utility.", | ||
) | ||
) | ||
|
||
with op.batch_alter_table( | ||
"denorm_electric_operating_revenues_ferc1", schema=None | ||
) as batch_op: | ||
batch_op.add_column( | ||
sa.Column( | ||
"utility_type", | ||
sa.Text(), | ||
nullable=True, | ||
comment="Listing of utility plant types. Examples include Electric Utility, Gas Utility, and Other Utility.", | ||
) | ||
) | ||
|
||
with op.batch_alter_table( | ||
"denorm_electric_plant_depreciation_functional_ferc1", schema=None | ||
) as batch_op: | ||
batch_op.add_column( | ||
sa.Column( | ||
"depreciation_type", | ||
sa.Text(), | ||
nullable=True, | ||
comment="Type of depreciation provision within FERC Account 108, including cost ofremoval, depreciation expenses, salvage, cost of retired plant, etc.", | ||
) | ||
) | ||
batch_op.drop_column("ferc_account") | ||
|
||
with op.batch_alter_table("denorm_plant_in_service_ferc1", schema=None) as batch_op: | ||
batch_op.add_column( | ||
sa.Column( | ||
"utility_type", | ||
sa.Text(), | ||
nullable=True, | ||
comment="Listing of utility plant types. Examples include Electric Utility, Gas Utility, and Other Utility.", | ||
) | ||
) | ||
|
||
with op.batch_alter_table("denorm_purchased_power_ferc1", schema=None) as batch_op: | ||
batch_op.add_column( | ||
sa.Column( | ||
"purchased_storage_mwh", | ||
sa.Float(), | ||
nullable=True, | ||
comment="Number of megawatt hours purchased during the period for energy storage.", | ||
) | ||
) | ||
batch_op.add_column( | ||
sa.Column( | ||
"purchased_other_than_storage_mwh", | ||
sa.Float(), | ||
nullable=True, | ||
comment="Number of megawatt hours purchased during the period for other than energy storage.", | ||
) | ||
) | ||
|
||
with op.batch_alter_table( | ||
"depreciation_amortization_summary_ferc1", schema=None | ||
) as batch_op: | ||
batch_op.add_column( | ||
sa.Column( | ||
"utility_type", | ||
sa.Text(), | ||
nullable=True, | ||
comment="Listing of utility plant types. Examples include Electric Utility, Gas Utility, and Other Utility.", | ||
) | ||
) | ||
batch_op.add_column( | ||
sa.Column( | ||
"row_type_xbrl", | ||
sa.Enum("calculated_value", "reported_value", "correction"), | ||
nullable=True, | ||
comment="Indicates whether the value reported in the row is calculated, or uniquely reported within the table.", | ||
) | ||
) | ||
|
||
with op.batch_alter_table( | ||
"electric_operating_expenses_ferc1", schema=None | ||
) as batch_op: | ||
batch_op.add_column( | ||
sa.Column( | ||
"utility_type", | ||
sa.Text(), | ||
nullable=True, | ||
comment="Listing of utility plant types. Examples include Electric Utility, Gas Utility, and Other Utility.", | ||
) | ||
) | ||
|
||
with op.batch_alter_table( | ||
"electric_operating_revenues_ferc1", schema=None | ||
) as batch_op: | ||
batch_op.add_column( | ||
sa.Column( | ||
"utility_type", | ||
sa.Text(), | ||
nullable=True, | ||
comment="Listing of utility plant types. Examples include Electric Utility, Gas Utility, and Other Utility.", | ||
) | ||
) | ||
|
||
with op.batch_alter_table( | ||
"electric_plant_depreciation_functional_ferc1", schema=None | ||
) as batch_op: | ||
batch_op.add_column( | ||
sa.Column( | ||
"depreciation_type", | ||
sa.Text(), | ||
nullable=True, | ||
comment="Type of depreciation provision within FERC Account 108, including cost ofremoval, depreciation expenses, salvage, cost of retired plant, etc.", | ||
) | ||
) | ||
batch_op.drop_column("ferc_account") | ||
|
||
with op.batch_alter_table("plant_in_service_ferc1", schema=None) as batch_op: | ||
batch_op.add_column( | ||
sa.Column( | ||
"utility_type", | ||
sa.Text(), | ||
nullable=True, | ||
comment="Listing of utility plant types. Examples include Electric Utility, Gas Utility, and Other Utility.", | ||
) | ||
) | ||
|
||
with op.batch_alter_table("purchased_power_ferc1", schema=None) as batch_op: | ||
batch_op.add_column( | ||
sa.Column( | ||
"purchased_storage_mwh", | ||
sa.Float(), | ||
nullable=True, | ||
comment="Number of megawatt hours purchased during the period for energy storage.", | ||
) | ||
) | ||
batch_op.add_column( | ||
sa.Column( | ||
"purchased_other_than_storage_mwh", | ||
sa.Float(), | ||
nullable=True, | ||
comment="Number of megawatt hours purchased during the period for other than energy storage.", | ||
) | ||
) | ||
|
||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table("purchased_power_ferc1", schema=None) as batch_op: | ||
batch_op.drop_column("purchased_other_than_storage_mwh") | ||
batch_op.drop_column("purchased_storage_mwh") | ||
|
||
with op.batch_alter_table("plant_in_service_ferc1", schema=None) as batch_op: | ||
batch_op.drop_column("utility_type") | ||
|
||
with op.batch_alter_table( | ||
"electric_plant_depreciation_functional_ferc1", schema=None | ||
) as batch_op: | ||
batch_op.add_column(sa.Column("ferc_account", sa.TEXT(), nullable=True)) | ||
batch_op.drop_column("depreciation_type") | ||
|
||
with op.batch_alter_table( | ||
"electric_operating_revenues_ferc1", schema=None | ||
) as batch_op: | ||
batch_op.drop_column("utility_type") | ||
|
||
with op.batch_alter_table( | ||
"electric_operating_expenses_ferc1", schema=None | ||
) as batch_op: | ||
batch_op.drop_column("utility_type") | ||
|
||
with op.batch_alter_table( | ||
"depreciation_amortization_summary_ferc1", schema=None | ||
) as batch_op: | ||
batch_op.drop_column("row_type_xbrl") | ||
batch_op.drop_column("utility_type") | ||
|
||
with op.batch_alter_table("denorm_purchased_power_ferc1", schema=None) as batch_op: | ||
batch_op.drop_column("purchased_other_than_storage_mwh") | ||
batch_op.drop_column("purchased_storage_mwh") | ||
|
||
with op.batch_alter_table("denorm_plant_in_service_ferc1", schema=None) as batch_op: | ||
batch_op.drop_column("utility_type") | ||
|
||
with op.batch_alter_table( | ||
"denorm_electric_plant_depreciation_functional_ferc1", schema=None | ||
) as batch_op: | ||
batch_op.add_column(sa.Column("ferc_account", sa.TEXT(), nullable=True)) | ||
batch_op.drop_column("depreciation_type") | ||
|
||
with op.batch_alter_table( | ||
"denorm_electric_operating_revenues_ferc1", schema=None | ||
) as batch_op: | ||
batch_op.drop_column("utility_type") | ||
|
||
with op.batch_alter_table( | ||
"denorm_electric_operating_expenses_ferc1", schema=None | ||
) as batch_op: | ||
batch_op.drop_column("utility_type") | ||
|
||
with op.batch_alter_table( | ||
"denorm_depreciation_amortization_summary_ferc1", schema=None | ||
) as batch_op: | ||
batch_op.drop_column("utility_type") | ||
|
||
# ### 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
Binary file not shown.
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