From aff679ef5340b9fed666dc7f5e7fab0543b240c8 Mon Sep 17 00:00:00 2001 From: Ben RdO Date: Mon, 13 Jan 2025 23:01:28 -0800 Subject: [PATCH] feat: create notebook exporting information in EIA 860 for generators in MISO footprint --- notebooks/explore_data/export_eia860.ipynb | 222 +++++++++++++++++++++ 1 file changed, 222 insertions(+) create mode 100644 notebooks/explore_data/export_eia860.ipynb diff --git a/notebooks/explore_data/export_eia860.ipynb b/notebooks/explore_data/export_eia860.ipynb new file mode 100644 index 0000000..d008158 --- /dev/null +++ b/notebooks/explore_data/export_eia860.ipynb @@ -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 +}