{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": { "mystnb": { "nb_execution_mode": "off" } }, "source": [ "# Benchmark Sourcecode\n", "**Comparing the results of NEMED to AEMO CDEII Reporting for Regional Sent-Out Generation, Total Emissions and Average Emissions Intensity**
\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "#### Import Packages" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "tags": [ "hide-cell" ] }, "outputs": [], "source": [ "import nemed\n", "from nemed.downloader import download_aemo_cdeii_summary, download_unit_dispatch\n", "from nemed.process import get_total_emissions_by_DI_DUID, aggregate_data_by\n", "\n", "# To generate plots shown \n", "import pandas as pd\n", "import numpy as np\n", "import os\n", "import plotly.graph_objects as go\n", "import plotly.express as px\n", "from plotly.subplots import make_subplots\n", "\n", "# Open plot in browser (optional)\n", "import plotly.io as pio\n", "pio.renderers.default = \"browser\"\n", "\n", "# Hide NEMOSIS logging\n", "import logging\n", "logging.getLogger(\"nemosis\").setLevel(logging.WARNING)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "#### Extracting & Processing Emissions Data\n", "Refer to explained details in the [Total Emissions Example](total_emissions.ipynb)\n", "\n", "```{warning} Data size and computation time is extensive for a 7 year period. \n", "Computation time for `get_total_emissions` was approx 1 hr.\n", "Cached directory consumes approx 18GB.\n", "```" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "start = \"2015/01/01 00:00\"\n", "end = \"2022/01/01 00:00\"\n", "cache = \"E:/TEMPCACHE_nemed_demo/\"" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "tags": [ "hide-output" ] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "INFO: Processing total emissions from 2014-12-31 to 2015-01-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2015-01-01 to 2015-02-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2015-02-01 to 2015-03-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2015-03-01 to 2015-04-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2015-04-01 to 2015-05-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2015-05-01 to 2015-06-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2015-06-01 to 2015-07-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2015-07-01 to 2015-08-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2015-08-01 to 2015-09-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2015-09-01 to 2015-10-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2015-10-01 to 2015-11-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2015-11-01 to 2015-12-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2015-12-01 to 2016-01-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2016-01-01 to 2016-02-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2016-02-01 to 2016-03-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2016-03-01 to 2016-04-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2016-04-01 to 2016-05-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2016-05-01 to 2016-06-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2016-06-01 to 2016-07-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2016-07-01 to 2016-08-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2016-08-01 to 2016-09-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2016-09-01 to 2016-10-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2016-10-01 to 2016-11-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2016-11-01 to 2016-12-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2016-12-01 to 2017-01-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2017-01-01 to 2017-02-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2017-02-01 to 2017-03-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2017-03-01 to 2017-04-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2017-04-01 to 2017-05-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2017-05-01 to 2017-06-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2017-06-01 to 2017-07-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2017-07-01 to 2017-08-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2017-08-01 to 2017-09-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2017-09-01 to 2017-10-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2017-10-01 to 2017-11-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2017-11-01 to 2017-12-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2017-12-01 to 2018-01-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2018-01-01 to 2018-02-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2018-02-01 to 2018-03-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2018-03-01 to 2018-04-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2018-04-01 to 2018-05-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2018-05-01 to 2018-06-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2018-06-01 to 2018-07-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2018-07-01 to 2018-08-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2018-08-01 to 2018-09-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2018-09-01 to 2018-10-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2018-10-01 to 2018-11-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2018-11-01 to 2018-12-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2018-12-01 to 2019-01-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2019-01-01 to 2019-02-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2019-02-01 to 2019-03-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2019-03-01 to 2019-04-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2019-04-01 to 2019-05-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2019-05-01 to 2019-06-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2019-06-01 to 2019-07-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2019-07-01 to 2019-08-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2019-08-01 to 2019-09-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2019-09-01 to 2019-10-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2019-10-01 to 2019-11-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2019-11-01 to 2019-12-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2019-12-01 to 2020-01-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2020-01-01 to 2020-02-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2020-02-01 to 2020-03-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2020-03-01 to 2020-04-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2020-04-01 to 2020-05-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2020-05-01 to 2020-06-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2020-06-01 to 2020-07-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2020-07-01 to 2020-08-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2020-08-01 to 2020-09-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2020-09-01 to 2020-10-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2020-10-01 to 2020-11-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2020-11-01 to 2020-12-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2020-12-01 to 2021-01-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2021-01-01 to 2021-02-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2021-02-01 to 2021-03-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2021-03-01 to 2021-04-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2021-04-01 to 2021-05-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2021-05-01 to 2021-06-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2021-06-01 to 2021-07-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2021-07-01 to 2021-08-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2021-08-01 to 2021-09-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2021-09-01 to 2021-10-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2021-10-01 to 2021-11-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2021-11-01 to 2021-12-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Processing total emissions from 2021-12-01 to 2022-01-01\n", "INFO: Compiling Energy from Dispatch\n", "INFO: Compiling Sent Out Generation\n", "INFO: Loading results file processed_co2_total_2014-12-31_2015-01-01.parquet\n", "INFO: Loading results file processed_co2_total_2015-01-01_2015-02-01.parquet\n", "INFO: Loading results file processed_co2_total_2015-02-01_2015-03-01.parquet\n", "INFO: Loading results file processed_co2_total_2015-03-01_2015-04-01.parquet\n", "INFO: Loading results file processed_co2_total_2015-04-01_2015-05-01.parquet\n", "INFO: Loading results file processed_co2_total_2015-05-01_2015-06-01.parquet\n", "INFO: Loading results file processed_co2_total_2015-06-01_2015-07-01.parquet\n", "INFO: Loading results file processed_co2_total_2015-07-01_2015-08-01.parquet\n", "INFO: Loading results file processed_co2_total_2015-08-01_2015-09-01.parquet\n", "INFO: Loading results file processed_co2_total_2015-09-01_2015-10-01.parquet\n", "INFO: Loading results file processed_co2_total_2015-10-01_2015-11-01.parquet\n", "INFO: Loading results file processed_co2_total_2015-11-01_2015-12-01.parquet\n", "INFO: Loading results file processed_co2_total_2015-12-01_2016-01-01.parquet\n", "INFO: Loading results file processed_co2_total_2016-01-01_2016-02-01.parquet\n", "INFO: Loading results file processed_co2_total_2016-02-01_2016-03-01.parquet\n", "INFO: Loading results file processed_co2_total_2016-03-01_2016-04-01.parquet\n", "INFO: Loading results file processed_co2_total_2016-04-01_2016-05-01.parquet\n", "INFO: Loading results file processed_co2_total_2016-05-01_2016-06-01.parquet\n", "INFO: Loading results file processed_co2_total_2016-06-01_2016-07-01.parquet\n", "INFO: Loading results file processed_co2_total_2016-07-01_2016-08-01.parquet\n", "INFO: Loading results file processed_co2_total_2016-08-01_2016-09-01.parquet\n", "INFO: Loading results file processed_co2_total_2016-09-01_2016-10-01.parquet\n", "INFO: Loading results file processed_co2_total_2016-10-01_2016-11-01.parquet\n", "INFO: Loading results file processed_co2_total_2016-11-01_2016-12-01.parquet\n", "INFO: Loading results file processed_co2_total_2016-12-01_2017-01-01.parquet\n", "INFO: Loading results file processed_co2_total_2017-01-01_2017-02-01.parquet\n", "INFO: Loading results file processed_co2_total_2017-02-01_2017-03-01.parquet\n", "INFO: Loading results file processed_co2_total_2017-03-01_2017-04-01.parquet\n", "INFO: Loading results file processed_co2_total_2017-04-01_2017-05-01.parquet\n", "INFO: Loading results file processed_co2_total_2017-05-01_2017-06-01.parquet\n", "INFO: Loading results file processed_co2_total_2017-06-01_2017-07-01.parquet\n", "INFO: Loading results file processed_co2_total_2017-07-01_2017-08-01.parquet\n", "INFO: Loading results file processed_co2_total_2017-08-01_2017-09-01.parquet\n", "INFO: Loading results file processed_co2_total_2017-09-01_2017-10-01.parquet\n", "INFO: Loading results file processed_co2_total_2017-10-01_2017-11-01.parquet\n", "INFO: Loading results file processed_co2_total_2017-11-01_2017-12-01.parquet\n", "INFO: Loading results file processed_co2_total_2017-12-01_2018-01-01.parquet\n", "INFO: Loading results file processed_co2_total_2018-01-01_2018-02-01.parquet\n", "INFO: Loading results file processed_co2_total_2018-02-01_2018-03-01.parquet\n", "INFO: Loading results file processed_co2_total_2018-03-01_2018-04-01.parquet\n", "INFO: Loading results file processed_co2_total_2018-04-01_2018-05-01.parquet\n", "INFO: Loading results file processed_co2_total_2018-05-01_2018-06-01.parquet\n", "INFO: Loading results file processed_co2_total_2018-06-01_2018-07-01.parquet\n", "INFO: Loading results file processed_co2_total_2018-07-01_2018-08-01.parquet\n", "INFO: Loading results file processed_co2_total_2018-08-01_2018-09-01.parquet\n", "INFO: Loading results file processed_co2_total_2018-09-01_2018-10-01.parquet\n", "INFO: Loading results file processed_co2_total_2018-10-01_2018-11-01.parquet\n", "INFO: Loading results file processed_co2_total_2018-11-01_2018-12-01.parquet\n", "INFO: Loading results file processed_co2_total_2018-12-01_2019-01-01.parquet\n", "INFO: Loading results file processed_co2_total_2019-01-01_2019-02-01.parquet\n", "INFO: Loading results file processed_co2_total_2019-02-01_2019-03-01.parquet\n", "INFO: Loading results file processed_co2_total_2019-03-01_2019-04-01.parquet\n", "INFO: Loading results file processed_co2_total_2019-04-01_2019-05-01.parquet\n", "INFO: Loading results file processed_co2_total_2019-05-01_2019-06-01.parquet\n", "INFO: Loading results file processed_co2_total_2019-06-01_2019-07-01.parquet\n", "INFO: Loading results file processed_co2_total_2019-07-01_2019-08-01.parquet\n", "INFO: Loading results file processed_co2_total_2019-08-01_2019-09-01.parquet\n", "INFO: Loading results file processed_co2_total_2019-09-01_2019-10-01.parquet\n", "INFO: Loading results file processed_co2_total_2019-10-01_2019-11-01.parquet\n", "INFO: Loading results file processed_co2_total_2019-11-01_2019-12-01.parquet\n", "INFO: Loading results file processed_co2_total_2019-12-01_2020-01-01.parquet\n", "INFO: Loading results file processed_co2_total_2020-01-01_2020-02-01.parquet\n", "INFO: Loading results file processed_co2_total_2020-02-01_2020-03-01.parquet\n", "INFO: Loading results file processed_co2_total_2020-03-01_2020-04-01.parquet\n", "INFO: Loading results file processed_co2_total_2020-04-01_2020-05-01.parquet\n", "INFO: Loading results file processed_co2_total_2020-05-01_2020-06-01.parquet\n", "INFO: Loading results file processed_co2_total_2020-06-01_2020-07-01.parquet\n", "INFO: Loading results file processed_co2_total_2020-07-01_2020-08-01.parquet\n", "INFO: Loading results file processed_co2_total_2020-08-01_2020-09-01.parquet\n", "INFO: Loading results file processed_co2_total_2020-09-01_2020-10-01.parquet\n", "INFO: Loading results file processed_co2_total_2020-10-01_2020-11-01.parquet\n", "INFO: Loading results file processed_co2_total_2020-11-01_2020-12-01.parquet\n", "INFO: Loading results file processed_co2_total_2020-12-01_2021-01-01.parquet\n", "INFO: Loading results file processed_co2_total_2021-01-01_2021-02-01.parquet\n", "INFO: Loading results file processed_co2_total_2021-02-01_2021-03-01.parquet\n", "INFO: Loading results file processed_co2_total_2021-03-01_2021-04-01.parquet\n", "INFO: Loading results file processed_co2_total_2021-04-01_2021-05-01.parquet\n", "INFO: Loading results file processed_co2_total_2021-05-01_2021-06-01.parquet\n", "INFO: Loading results file processed_co2_total_2021-06-01_2021-07-01.parquet\n", "INFO: Loading results file processed_co2_total_2021-07-01_2021-08-01.parquet\n", "INFO: Loading results file processed_co2_total_2021-08-01_2021-09-01.parquet\n", "INFO: Loading results file processed_co2_total_2021-09-01_2021-10-01.parquet\n", "INFO: Loading results file processed_co2_total_2021-10-01_2021-11-01.parquet\n", "INFO: Loading results file processed_co2_total_2021-11-01_2021-12-01.parquet\n", "INFO: Loading results file processed_co2_total_2021-12-01_2022-01-01.parquet\n", "INFO: Completed get_total_emissions_by_DI_DUID\n" ] } ], "source": [ "result = nemed.get_total_emissions(start_time=start,\n", " end_time=end,\n", " cache=cache,\n", " filter_regions=None,\n", " by=None,\n", " generation_sent_out=True,\n", " assume_energy_ramp=True,\n", " return_pivot=False)\n", "result.to_csv(r'E:\\TEMPCACHE_nemed_demo\\EXAMPLE_BENCHMARK_DATA_ASOF_09012023.CSV')" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "```{tip}\n", "A .csv file containing the above processed data can be saved for convenience and reloaded as below.\n", "```" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
TimeEndingRegionEnergyTotal_EmissionsIntensity_Index
02015-01-01 00:05:00NEM0.0000000.0000000.000000
12015-01-01 00:05:00NSW10.0000000.0000000.000000
22015-01-01 00:05:00QLD10.0000000.0000000.000000
32015-01-01 00:05:00SA10.0000000.0000000.000000
42015-01-01 00:05:00TAS10.0000000.0000000.000000
..................
44184912022-01-01 00:00:00NSW1526.126887381.5331860.725173
44184922022-01-01 00:00:00QLD1538.572738398.2503050.739455
44184932022-01-01 00:00:00SA1103.33402735.7807520.346263
44184942022-01-01 00:00:00TAS1138.7851200.0000000.000000
44184952022-01-01 00:00:00VIC1483.276172389.0731250.805074
\n", "

4418496 rows × 5 columns

\n", "
" ], "text/plain": [ " TimeEnding Region Energy Total_Emissions \\\n", "0 2015-01-01 00:05:00 NEM 0.000000 0.000000 \n", "1 2015-01-01 00:05:00 NSW1 0.000000 0.000000 \n", "2 2015-01-01 00:05:00 QLD1 0.000000 0.000000 \n", "3 2015-01-01 00:05:00 SA1 0.000000 0.000000 \n", "4 2015-01-01 00:05:00 TAS1 0.000000 0.000000 \n", "... ... ... ... ... \n", "4418491 2022-01-01 00:00:00 NSW1 526.126887 381.533186 \n", "4418492 2022-01-01 00:00:00 QLD1 538.572738 398.250305 \n", "4418493 2022-01-01 00:00:00 SA1 103.334027 35.780752 \n", "4418494 2022-01-01 00:00:00 TAS1 138.785120 0.000000 \n", "4418495 2022-01-01 00:00:00 VIC1 483.276172 389.073125 \n", "\n", " Intensity_Index \n", "0 0.000000 \n", "1 0.000000 \n", "2 0.000000 \n", "3 0.000000 \n", "4 0.000000 \n", "... ... \n", "4418491 0.725173 \n", "4418492 0.739455 \n", "4418493 0.346263 \n", "4418494 0.000000 \n", "4418495 0.805074 \n", "\n", "[4418496 rows x 5 columns]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result = pd.read_csv(r'C:\\Users\\derlu\\Downloads'+\\\n", " '\\EXAMPLE_BENCHMARK_DATA_ASOF_09012023.CSV',index_col=[0])\n", "result['TimeEnding'] = pd.to_datetime(result['TimeEnding'], format=\"%Y-%m-%d %H:%M:%S\")\n", "result" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "##### Data Aggregation" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
TimeBeginningTimeEndingRegionEnergyTotal_EmissionsIntensity_Index
02015-01-012015-01-02NEM499240.152446855.9030.895
12015-01-022015-01-03NEM554330.260474310.1220.856
22015-01-032015-01-04NEM553499.542482764.9010.872
32015-01-042015-01-05NEM499399.915445382.7070.892
42015-01-052015-01-06NEM533848.633481068.4110.901
.....................
153372021-12-272021-12-28VIC1105752.91370330.2910.665
153382021-12-282021-12-29VIC1110167.13082720.9760.751
153392021-12-292021-12-30VIC1114128.21499348.7840.871
153402021-12-302021-12-31VIC1125026.680104753.9330.838
153412021-12-312022-01-01VIC1145208.124105244.1820.725
\n", "

15342 rows × 6 columns

\n", "
" ], "text/plain": [ " TimeBeginning TimeEnding Region Energy Total_Emissions \\\n", "0 2015-01-01 2015-01-02 NEM 499240.152 446855.903 \n", "1 2015-01-02 2015-01-03 NEM 554330.260 474310.122 \n", "2 2015-01-03 2015-01-04 NEM 553499.542 482764.901 \n", "3 2015-01-04 2015-01-05 NEM 499399.915 445382.707 \n", "4 2015-01-05 2015-01-06 NEM 533848.633 481068.411 \n", "... ... ... ... ... ... \n", "15337 2021-12-27 2021-12-28 VIC1 105752.913 70330.291 \n", "15338 2021-12-28 2021-12-29 VIC1 110167.130 82720.976 \n", "15339 2021-12-29 2021-12-30 VIC1 114128.214 99348.784 \n", "15340 2021-12-30 2021-12-31 VIC1 125026.680 104753.933 \n", "15341 2021-12-31 2022-01-01 VIC1 145208.124 105244.182 \n", "\n", " Intensity_Index \n", "0 0.895 \n", "1 0.856 \n", "2 0.872 \n", "3 0.892 \n", "4 0.901 \n", "... ... \n", "15337 0.665 \n", "15338 0.751 \n", "15339 0.871 \n", "15340 0.838 \n", "15341 0.725 \n", "\n", "[15342 rows x 6 columns]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "nemed_df = aggregate_data_by(result, \"day\")\n", "nemed_df" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "#### Retrieve Published AEMO CDEII data for comparison\n", "This function extracts the publicly available 'Summary Results' files from the [AEMO CDEII website](https://aemo.com.au/en/energy-systems/electricity/national-electricity-market-nem/market-operations/settlements-and-payments/settlements/carbon-dioxide-equivalent-intensity-index).\n" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "tags": [ "hide-output" ] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "WARNING: 'filter_end' date exceeds available data from CURRENT CDEII. Latest available data is 2021-12-31 00:00:00\n" ] } ], "source": [ "aemo_df = download_aemo_cdeii_summary(filter_start=start,\n", " filter_end=end,\n", " cache=cache)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SETTLEMENTDATEREGIONIDTOTAL_SENT_OUT_ENERGYTOTAL_EMISSIONSCO2E_INTENSITY_INDEX
02015-01-01NEM477475.87550444620.3569000.9312
12015-01-01NSW1134533.32030113619.7216000.8445
22015-01-01QLD1162723.14120140410.4662000.8629
32015-01-01SA128239.8016517266.4909100.6114
42015-01-01TAS118188.655932.1031550.0001
\n", "
" ], "text/plain": [ " SETTLEMENTDATE REGIONID TOTAL_SENT_OUT_ENERGY TOTAL_EMISSIONS \\\n", "0 2015-01-01 NEM 477475.87550 444620.356900 \n", "1 2015-01-01 NSW1 134533.32030 113619.721600 \n", "2 2015-01-01 QLD1 162723.14120 140410.466200 \n", "3 2015-01-01 SA1 28239.80165 17266.490910 \n", "4 2015-01-01 TAS1 18188.65593 2.103155 \n", "\n", " CO2E_INTENSITY_INDEX \n", "0 0.9312 \n", "1 0.8445 \n", "2 0.8629 \n", "3 0.6114 \n", "4 0.0001 " ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "aemo_df.head()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "#### Compute Error between Datasets\n", "The following function calculate the error for each dataset (energy, total emissions, emissions intensity). " ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "def calculate_dataset_errors(nemed_df, aemo_df):\n", " all_df = pd.merge(left=nemed_df, left_on=[\"TimeBeginning\", \"Region\"],\n", " right=aemo_df, right_on=[\"SETTLEMENTDATE\", \"REGIONID\"], how=\"inner\")\n", " all_df['ERR_Energy'] = 100 * (all_df['Energy'] - all_df['TOTAL_SENT_OUT_ENERGY'])\\\n", " / all_df['TOTAL_SENT_OUT_ENERGY']\n", " all_df['ERR_Total_Emissions'] = 100 * (all_df['Total_Emissions'] \\\n", " - all_df['TOTAL_EMISSIONS']) / all_df['TOTAL_EMISSIONS']\n", " all_df['ERR_Intensity_Index'] = 100 * (all_df['Intensity_Index'] \\\n", " - all_df['CO2E_INTENSITY_INDEX']) / all_df['CO2E_INTENSITY_INDEX']\n", " return all_df[['TimeBeginning','Region','Energy','TOTAL_SENT_OUT_ENERGY',\\\n", " 'ERR_Energy','Total_Emissions','TOTAL_EMISSIONS','ERR_Total_Emissions',\\\n", " 'Intensity_Index','CO2E_INTENSITY_INDEX','ERR_Intensity_Index']]\n", "\n", "plt_df = calculate_dataset_errors(nemed_df, aemo_df)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "The energy metrics of the dataframe are produced:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
TimeBeginningRegionEnergyTOTAL_SENT_OUT_ENERGYERR_Energy
02015-01-01NEM499240.152477475.87554.558194
12015-01-02NEM554330.260533685.27563.868382
22015-01-03NEM553499.542525521.79575.323803
32015-01-04NEM499399.915473576.60955.452825
42015-01-05NEM533848.633506759.74985.345508
\n", "
" ], "text/plain": [ " TimeBeginning Region Energy TOTAL_SENT_OUT_ENERGY ERR_Energy\n", "0 2015-01-01 NEM 499240.152 477475.8755 4.558194\n", "1 2015-01-02 NEM 554330.260 533685.2756 3.868382\n", "2 2015-01-03 NEM 553499.542 525521.7957 5.323803\n", "3 2015-01-04 NEM 499399.915 473576.6095 5.452825\n", "4 2015-01-05 NEM 533848.633 506759.7498 5.345508" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plt_df.iloc[0:5,0:5]" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "The next columns contain the emissions metrics:" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Total_EmissionsTOTAL_EMISSIONSERR_Total_Emissions
0446855.903444620.35690.502799
1474310.122472317.57420.421866
2482764.901476553.95801.303303
3445382.707439177.24531.412974
4481068.411475037.63771.269536
\n", "
" ], "text/plain": [ " Total_Emissions TOTAL_EMISSIONS ERR_Total_Emissions\n", "0 446855.903 444620.3569 0.502799\n", "1 474310.122 472317.5742 0.421866\n", "2 482764.901 476553.9580 1.303303\n", "3 445382.707 439177.2453 1.412974\n", "4 481068.411 475037.6377 1.269536" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plt_df.iloc[0:5,5:8]" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "The final columns with the intensity metrics:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Total_EmissionsTOTAL_EMISSIONSERR_Total_Emissions
0446855.903444620.35690.502799
1474310.122472317.57420.421866
2482764.901476553.95801.303303
3445382.707439177.24531.412974
4481068.411475037.63771.269536
\n", "
" ], "text/plain": [ " Total_Emissions TOTAL_EMISSIONS ERR_Total_Emissions\n", "0 446855.903 444620.3569 0.502799\n", "1 474310.122 472317.5742 0.421866\n", "2 482764.901 476553.9580 1.303303\n", "3 445382.707 439177.2453 1.412974\n", "4 481068.411 475037.6377 1.269536" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plt_df.iloc[0:5,5:8]" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "#### Plot Formatting\n", "Toggle the below code block to see the plot code" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "tags": [ "hide-cell", "full-width" ] }, "outputs": [], "source": [ "colors = ['#676765','#3b4252','#af7635','#8F6593','#4F759B', '#638b66','#b65551']\n", "def NORD_theme():\n", " plotly_NORD_theme = pio.templates[\"simple_white\"]\n", " plotly_NORD_theme.layout.plot_bgcolor = \"#f4f4f5\" \n", " plotly_NORD_theme.layout.paper_bgcolor = \"#FFFFFF\"\n", " plotly_NORD_theme.layout.xaxis.gridcolor = '#d8dee9'\n", " plotly_NORD_theme.layout.yaxis.gridcolor = '#d8dee9'\n", " return plotly_NORD_theme\n", "\n", "def set_font_size(layout, font_size=16):\n", " layout['titlefont']['size'] = font_size + 4\n", " layout.legend['font']['size'] = font_size\n", "\n", " for ax in [item for item in layout if item.__contains__('xaxis')]:\n", " layout[ax].titlefont.size = font_size\n", " layout[ax].tickfont.size = font_size\n", "\n", " for ax in [item for item in layout if item.__contains__('yaxis')]:\n", " layout[ax].titlefont.size = font_size\n", " layout[ax].tickfont.size = font_size\n", "\n", "def plot_energy(df, region, color_idx, yrange, ytickvals, yrange_err, ytickvals_err, save=None):\n", " sel_df = df[df['Region']==region].sort_values('TimeBeginning').reset_index(drop=True)\n", " fig = make_subplots(rows=4, cols=1, shared_xaxes=True, vertical_spacing=0.05,\n", " specs=[[{\"rowspan\": 3}],[{}],[{}],[{\"rowspan\":1}]])\n", " # Traces\n", " fig.add_trace(go.Scatter(x=sel_df['TimeBeginning'],\n", " y=sel_df['TOTAL_SENT_OUT_ENERGY'],\n", " name=\"CDEII Reported\",\n", " mode=\"lines+markers\",\n", " line_color=colors[0]), row=1, col=1)\n", " fig.add_trace(go.Scatter(x=sel_df['TimeBeginning'],\n", " y=sel_df['Energy'],\n", " name=\"NEMED Calculated\",\n", " mode=\"lines+markers\",\n", " line_color=colors[color_idx]), row=1, col=1)\n", " fig.add_trace(go.Scatter(x=sel_df['TimeBeginning'],\n", " y=sel_df['ERR_Energy'],\n", " name=\"Error\",\n", " mode=\"lines\",\n", " line_color=colors[color_idx],\n", " line_dash='dot'), row=4, col=1)\n", " # Layout\n", " fig.update_layout(title=f\"{region} Historical Daily Sent Out Generation
\"+\\\n", " \"NEMED | Average Emissions Methodology | CDEII Benchmark Comparison\",\n", " template=NORD_theme(),\n", " legend={'title':'Dataseries', 'orientation':'h', 'xanchor': 'center', 'x': 0.5, 'y':-0.1},\n", " hovermode=\"x\")\n", " fig.update_yaxes(title_text=\"Total Energy
(MWh)\", mirror=True, showgrid=True,\n", " autorange=False, range=yrange, tickvals=[i*10**3 for i in ytickvals], row=1, col=1)\n", " fig.update_yaxes(title_text=\"Error wrt.
CDEII (%)\", mirror=True, showgrid=True,\n", " autorange=False, range=yrange_err, tickvals=[i for i in ytickvals_err], row=4, col=1)\n", " fig.update_xaxes(title_text=\"Date (Day)\", mirror=True, row=4, col=1)\n", " fig.update_xaxes(mirror=True, row=1, col=1)\n", " FONT_SIZE = 16\n", " FONT_STYLE = \"Raleway\"\n", " fonts = dict(tickfont=dict(size=FONT_SIZE, family=FONT_STYLE),\n", " titlefont=dict(size=FONT_SIZE, family=FONT_STYLE))\n", " fig.update_layout(xaxis=fonts, yaxis=fonts, yaxis4=fonts, xaxis4=fonts,\n", " legend=dict(font=dict(size=FONT_SIZE-2, family=FONT_STYLE)),\n", " title_font_family=FONT_STYLE,\n", " title_font_size=22)\n", " fig.update_annotations(font=dict(size=FONT_SIZE, family=FONT_STYLE))\n", " if save != None:\n", " fig.write_html(os.path.join(save, f\"energy_{region}.html\"))\n", " else:\n", " fig.show()\n", " return\n", "\n", "def plot_emissions(df, region, color_idx, yrange, ytickvals, yrange_err, ytickvals_err, save=None, err_off=False):\n", " sel_df = df[df['Region']==region].sort_values('TimeBeginning').reset_index(drop=True)\n", " fig = make_subplots(rows=4, cols=1, shared_xaxes=True, vertical_spacing=0.1,\n", " specs=[[{\"rowspan\": 3}],[{}],[{}],[{\"rowspan\":1}]],)\n", " # Traces\n", " fig.add_trace(go.Scatter(x=sel_df['TimeBeginning'],\n", " y=sel_df['TOTAL_EMISSIONS'],\n", " name=\"CDEII Reported\",\n", " mode=\"lines+markers\",\n", " line_color=colors[0]), row=1, col=1)\n", " fig.add_trace(go.Scatter(x=sel_df['TimeBeginning'],\n", " y=sel_df['Total_Emissions'],\n", " name=\"NEMED Calculated\",\n", " mode=\"lines+markers\",\n", " line_color=colors[color_idx]), row=1, col=1)\n", " if not err_off:\n", " fig.add_trace(go.Scatter(x=sel_df['TimeBeginning'],\n", " y=sel_df['ERR_Total_Emissions'],\n", " name=\"Error\",\n", " mode=\"lines\",\n", " line_color=colors[color_idx],\n", " line_dash='dot'), row=4, col=1)\n", " else:\n", " fig.add_annotation(xref=\"x domain\", yref=\"y domain\", x=0.5, y=-0.3, \\\n", " text=\"Error chart omitted where zero values occur.\", showarrow=False)\n", " # Layout\n", " fig.update_layout(title=f\"{region} Historical Daily Emissions
\"+\\\n", " \"NEMED | Average Emissions Methodology | CDEII Benchmark Comparison\",\n", " template=NORD_theme(),\n", " legend={'title':'Dataseries', 'orientation':'h', 'xanchor': 'center', 'x': 0.5, 'y':-0.1},\n", " hovermode=\"x\")\n", " fig.update_yaxes(title_text=\"Total Emissions
(tCO2-e)\", mirror=True, showgrid=True,\n", " autorange=False, range=yrange, tickvals=[i*10**3 for i in ytickvals], row=1, col=1)\n", " fig.update_yaxes(title_text=\"Error wrt.
CDEII (%)\", mirror=True, showgrid=True,\n", " autorange=False, range=yrange_err, tickvals=[i for i in ytickvals_err], row=4, col=1)\n", " fig.update_xaxes(title_text=\"Date (Day)\", mirror=True, row=4, col=1)\n", " fig.update_xaxes(mirror=True, row=1, col=1)\n", " FONT_SIZE = 16\n", " FONT_STYLE = \"Raleway\"\n", " fonts = dict(tickfont=dict(size=FONT_SIZE, family=FONT_STYLE),\n", " titlefont=dict(size=FONT_SIZE, family=FONT_STYLE))\n", " fig.update_layout(xaxis=fonts, yaxis=fonts, yaxis4=fonts, xaxis4=fonts,\n", " legend=dict(font=dict(size=FONT_SIZE-2, family=FONT_STYLE)),\n", " title_font_family=FONT_STYLE,\n", " title_font_size=22)\n", " fig.update_annotations(font=dict(size=FONT_SIZE, family=FONT_STYLE))\n", " if save != None:\n", " fig.write_html(os.path.join(save, f\"emissions_{region}.html\"))\n", " else:\n", " fig.show()\n", " return\n", "\n", "def plot_intensity(df, region, color_idx, yrange, ytickvals, yrange_err, ytickvals_err, save=None, err_off=False):\n", " sel_df = df[df['Region']==region].sort_values('TimeBeginning').reset_index(drop=True)\n", " fig = make_subplots(rows=4, cols=1, shared_xaxes=True, vertical_spacing=0.1,\n", " specs=[[{\"rowspan\": 3}],[{}],[{}],[{\"rowspan\":1}]],)\n", " # Traces\n", " fig.add_trace(go.Scatter(x=sel_df['TimeBeginning'],\n", " y=sel_df['CO2E_INTENSITY_INDEX'],\n", " name=\"CDEII Reported\",\n", " mode=\"lines+markers\",\n", " line_color=colors[0]), row=1, col=1)\n", " fig.add_trace(go.Scatter(x=sel_df['TimeBeginning'],\n", " y=sel_df['Intensity_Index'],\n", " name=\"NEMED Calculated\",\n", " mode=\"lines+markers\",\n", " line_color=colors[color_idx]), row=1, col=1)\n", " if not err_off:\n", " fig.add_trace(go.Scatter(x=sel_df['TimeBeginning'],\n", " y=sel_df['ERR_Intensity_Index'],\n", " name=\"Error\",\n", " mode=\"lines\",\n", " line_color=colors[color_idx],\n", " line_dash='dot'), row=4, col=1)\n", " else:\n", " fig.add_annotation(xref=\"x domain\", yref=\"y domain\", x=0.5, y=-0.3, \\\n", " text=\"Error chart omitted where zero values occur.\", showarrow=False)\n", " # Layout\n", " fig.update_layout(title=f\"{region} Historical Daily Emissions Intensity
\"+\\\n", " \"NEMED | Average Emissions Methodology | CDEII Benchmark Comparison\",\n", " template=NORD_theme(),\n", " legend={'title':'Dataseries', 'orientation':'h', 'xanchor': 'center', 'x': 0.5, 'y':-0.1},\n", " hovermode=\"x\")\n", " fig.update_yaxes(title_text=\"Emissions Intensity
(tCO2-e/MWh)\", mirror=True, showgrid=True,\n", " autorange=False, range=yrange, tickvals=[i*10**-2 for i in ytickvals], row=1, col=1)\n", " fig.update_yaxes(title_text=\"Error wrt.
CDEII (%)\", mirror=True, showgrid=True,\n", " autorange=False, range=yrange_err, tickvals=[i for i in ytickvals_err], row=4, col=1)\n", " fig.update_xaxes(title_text=\"Date (Day)\", mirror=True, row=4, col=1)\n", " fig.update_xaxes(mirror=True, row=1, col=1)\n", " FONT_SIZE = 16\n", " FONT_STYLE = \"Raleway\"\n", " fonts = dict(tickfont=dict(size=FONT_SIZE, family=FONT_STYLE),\n", " titlefont=dict(size=FONT_SIZE, family=FONT_STYLE))\n", " fig.update_layout(xaxis=fonts, yaxis=fonts, yaxis4=fonts, xaxis4=fonts,\n", " legend=dict(font=dict(size=FONT_SIZE-2, family=FONT_STYLE)),\n", " title_font_family=FONT_STYLE,\n", " title_font_size=22)\n", " fig.update_annotations(font=dict(size=FONT_SIZE, family=FONT_STYLE))\n", " if save != None:\n", " fig.write_html(os.path.join(save, f\"intensity_{region}.html\"))\n", " else:\n", " fig.show()\n", " return" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### Execute Charts" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "save_path =r'E:\\PROJECTS\\nemed-fork\\NEMED\\docs\\source\\examples\\charts_benchmark'" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "#### Sent Out Energy" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "plot_energy(plt_df,\n", " region='NEM',\n", " color_idx=1,\n", " yrange=[380000,720000],\n", " ytickvals=range(400,701,50),\n", " yrange_err=[-2,12],\n", " ytickvals_err=range(0,11,5),\n", " save=save_path)" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "plot_energy(plt_df,\n", " region='NSW1',\n", " color_idx=2,\n", " yrange=[90000,260000],\n", " ytickvals=range(100,251,25),\n", " yrange_err=[-2,12],\n", " ytickvals_err=range(0,11,5),\n", " save=save_path)" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "plot_energy(plt_df,\n", " region='QLD1',\n", " color_idx=3,\n", " yrange=[110000,210000],\n", " ytickvals=range(120,201,20),\n", " yrange_err=[-10,10],\n", " ytickvals_err=range(-5,6,5),\n", " save=save_path)" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "plot_energy(plt_df,\n", " region='SA1',\n", " color_idx=4,\n", " yrange=[5000,65000],\n", " ytickvals=range(10,61,10),\n", " yrange_err=[-10,10],\n", " ytickvals_err=range(-5,6,5),\n", " save=save_path)" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "plot_energy(plt_df,\n", " region='TAS1',\n", " color_idx=5,\n", " yrange=[5000,65000],\n", " ytickvals=range(10,61,10),\n", " yrange_err=[-15,10],\n", " ytickvals_err=range(-15,11,5),\n", " save=save_path)" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "plot_energy(plt_df,\n", " region='VIC1',\n", " color_idx=6,\n", " yrange=[65000,195000],\n", " ytickvals=range(70,191,20),\n", " yrange_err=[-10,10],\n", " ytickvals_err=range(-10,11,5),\n", " save=save_path)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "#### Total Emissions" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [], "source": [ "plot_emissions(plt_df,\n", " region='NEM',\n", " color_idx=1,\n", " yrange=[225000,575000],\n", " ytickvals=range(250,561,50),\n", " yrange_err=[-10,15],\n", " ytickvals_err=range(-10,16,5),\n", " save=save_path)" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [], "source": [ "plot_emissions(plt_df,\n", " region='NSW1',\n", " color_idx=2,\n", " yrange=[70000,210000],\n", " ytickvals=range(80,201,20),\n", " yrange_err=[-7,7],\n", " ytickvals_err=range(-5,6,5),\n", " save=save_path)" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "plot_emissions(plt_df,\n", " region='QLD1',\n", " color_idx=3,\n", " yrange=[85000,175000],\n", " ytickvals=range(90,171,10),\n", " yrange_err=[-12,7],\n", " ytickvals_err=range(-10,6,5),\n", " save=save_path)" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [], "source": [ "plot_emissions(plt_df,\n", " region='SA1',\n", " color_idx=4,\n", " yrange=[-3000,33000],\n", " ytickvals=range(0,31,5),\n", " yrange_err=[-8,13],\n", " ytickvals_err=range(-5,11,5),\n", " save=save_path)" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [], "source": [ "plot_emissions(plt_df,\n", " region='TAS1',\n", " color_idx=5,\n", " yrange=[-300,7300],\n", " ytickvals=range(0,8,1),\n", " yrange_err=[-8,13],\n", " ytickvals_err=range(-5,11,5),\n", " save=save_path, err_off=True)" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [], "source": [ "plot_emissions(plt_df,\n", " region='VIC1',\n", " color_idx=6,\n", " yrange=[30000,210000],\n", " ytickvals=range(40,201,20),\n", " yrange_err=[-15,5],\n", " ytickvals_err=range(-15,6,5),\n", " save=save_path)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "#### Emissions Intensity" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [], "source": [ "plot_intensity(plt_df,\n", " region='NEM',\n", " color_idx=1,\n", " yrange=[0.45,1.05],\n", " ytickvals=range(50,101,10),\n", " yrange_err=[-12,7],\n", " ytickvals_err=range(-10,6,5),\n", " save=save_path)" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [], "source": [ "plot_intensity(plt_df,\n", " region='NSW1',\n", " color_idx=2,\n", " yrange=[0.45,1.05],\n", " ytickvals=range(50,101,10),\n", " yrange_err=[-12,2],\n", " ytickvals_err=range(-10,1,5),\n", " save=save_path)" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [], "source": [ "plot_intensity(plt_df,\n", " region='QLD1',\n", " color_idx=3,\n", " yrange=[0.55,1.05],\n", " ytickvals=range(60,101,10),\n", " yrange_err=[-15,5],\n", " ytickvals_err=range(-15,6,5),\n", " save=save_path)" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [], "source": [ "plot_intensity(plt_df,\n", " region='SA1',\n", " color_idx=4,\n", " yrange=[-0.05,0.95],\n", " ytickvals=range(0,96,10),\n", " yrange_err=[-7,12],\n", " ytickvals_err=range(-5,11,5),\n", " save=save_path)" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [], "source": [ "plot_intensity(plt_df,\n", " region='TAS1',\n", " color_idx=5,\n", " yrange=[-0.03,0.28],\n", " ytickvals=range(0,26,5),\n", " yrange_err=[-7,12],\n", " ytickvals_err=range(-5,11,5),\n", " save=save_path, err_off=True)" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [], "source": [ "plot_intensity(plt_df,\n", " region='VIC1',\n", " color_idx=6,\n", " yrange=[0.45,1.45],\n", " ytickvals=range(50,141,10),\n", " yrange_err=[-15,5],\n", " ytickvals_err=range(-15,6,5),\n", " save=save_path)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.9.12 ('nempy')", "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.9.12 (main, Apr 4 2022, 05:22:27) [MSC v.1916 64 bit (AMD64)]" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "4aab49ac747d4948ee2428bd46f4ac833ef94a37ecb38233c747c75e4d05fe4b" } } }, "nbformat": 4, "nbformat_minor": 2 }