-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create notebook exporting information in EIA 860 for generators…
… in MISO footprint
- Loading branch information
Showing
1 changed file
with
222 additions
and
0 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,222 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Export EIA 860" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import pandas as pd\n", | ||
"\n", | ||
"from oge.load_data import load_pudl_table" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Load data" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"gens_eia860 = load_pudl_table(\"core_eia860__scd_generators\")\n", | ||
"plants_eia860 = load_pudl_table(\"core_eia860__scd_plants\")\n", | ||
"plants_entity = load_pudl_table(\"core_eia__entity_plants\")\n", | ||
"generators_entity = load_pudl_table(\"core_eia__entity_generators\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Merge data" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"eia_gens = gens_eia860.merge(\n", | ||
" plants_eia860,\n", | ||
" how=\"left\",\n", | ||
" on=[\"report_date\", \"plant_id_eia\"],\n", | ||
" suffixes=(None, \"_remove\"),\n", | ||
" validate=\"m:1\",\n", | ||
")\n", | ||
"\n", | ||
"eia_gens = eia_gens.merge(\n", | ||
" generators_entity,\n", | ||
" how=\"left\",\n", | ||
" on=[\"plant_id_eia\", \"generator_id\"],\n", | ||
" suffixes=(None, \"_remove\"),\n", | ||
" validate=\"m:1\",\n", | ||
")\n", | ||
"\n", | ||
"eia_gens = eia_gens.merge(\n", | ||
" plants_entity,\n", | ||
" how=\"left\",\n", | ||
" on=[\"plant_id_eia\"],\n", | ||
" suffixes=(None, \"_remove\"),\n", | ||
" validate=\"m:1\",\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Keep only the most recent entry for each generator" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"eia_gens = eia_gens.sort_values(\n", | ||
" by=[\"plant_id_eia\", \"generator_id\", \"report_date\"], ascending=True\n", | ||
")\n", | ||
"eia_gens = eia_gens.drop_duplicates(\n", | ||
" subset=[\"plant_id_eia\", \"generator_id\"], keep=\"last\"\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Remove duplicate columns" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"eia_gens = eia_gens[[col for col in eia_gens.columns if \"_remove\" not in col]]\n", | ||
"eia_gens = eia_gens[\n", | ||
" [\n", | ||
" \"plant_id_eia\",\n", | ||
" \"plant_name_eia\",\n", | ||
" \"generator_id\",\n", | ||
" \"report_date\",\n", | ||
" \"rto_iso_lmp_node_id\",\n", | ||
" \"transmission_distribution_owner_name\",\n", | ||
" \"transmission_distribution_owner_state\",\n", | ||
" \"balancing_authority_code_eia\",\n", | ||
" \"balancing_authority_name_eia\",\n", | ||
" \"iso_rto_code\",\n", | ||
" \"nerc_region\",\n", | ||
" \"latitude\",\n", | ||
" \"longitude\",\n", | ||
" \"street_address\",\n", | ||
" \"city\",\n", | ||
" \"county\",\n", | ||
" \"state\",\n", | ||
" \"zip_code\",\n", | ||
" \"capacity_mw\",\n", | ||
" \"grid_voltage_1_kv\",\n", | ||
" \"prime_mover_code\",\n", | ||
" \"energy_source_code_1\",\n", | ||
" \"energy_source_code_2\",\n", | ||
" \"multiple_fuels\",\n", | ||
" \"cofire_fuels\",\n", | ||
" \"switch_oil_gas\",\n", | ||
" \"energy_storage\",\n", | ||
" \"generator_operating_date\",\n", | ||
" \"current_planned_generator_operating_date\",\n", | ||
" \"operational_status\",\n", | ||
" \"generator_retirement_date\",\n", | ||
" ]\n", | ||
"]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Keep only states in MISO footprint" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"states_to_remove = [\n", | ||
" \"AK\",\n", | ||
" \"HI\",\n", | ||
" \"WA\",\n", | ||
" \"OR\",\n", | ||
" \"CA\",\n", | ||
" \"ID\",\n", | ||
" \"NV\",\n", | ||
" \"AZ\",\n", | ||
" \"UT\",\n", | ||
" \"WY\",\n", | ||
" \"CO\",\n", | ||
" \"ME\",\n", | ||
" \"NH\",\n", | ||
" \"RI\",\n", | ||
"]\n", | ||
"\n", | ||
"# to filter this a bit, get rid of generators in WECC, Texas, Alaska, and Hawaii\n", | ||
"eia_gens = eia_gens[~eia_gens[\"state\"].isin([\"UNK\", \"TRE\", \"WECC\"])]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Export file" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"eia_gens.to_csv(\"~/Desktop/eia860_export.csv\", index=False)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "open-grid-emissions-zm3GQQDc", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.2" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |