{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"mystnb": {
"nb_execution_mode": "off"
}
},
"source": [
"# Marginal Emissions\n",
"**Exploring the functionality of NEMED to extract regional marginal emitters from price setting and generator emissions data**
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Data Preparation\n",
"#### Import Packages"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"tags": [
"hide-cell"
]
},
"outputs": [],
"source": [
"import nemed\n",
"\n",
"import pandas as pd\n",
"# To generate plots shown\n",
"import plotly.graph_objects as go\n",
"import plotly.express as px\n",
"import string\n",
"\n",
"# Open plot in browser (optional)\n",
"import plotly.io as pio\n",
"pio.renderers.default = \"browser\""
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"tags": [
"full-width"
]
},
"source": [
"#### Processing Marginal Emissions Data\n",
"Regional Marginal Emissions can be extracted in NEMED using `get_marginal_emissions`. The following inputs must be specified:\n",
"- `start_time` define the start of the historical period to collect data for. Must be in the format: \"yyyy/mm/dd HH:MM\"\n",
"- `end_time` define the end of the historical period to collect data for. Must be in the format: \"yyyy/mm/dd HH:MM\"\n",
"- `cache` specify the local file directory to temporarily store downloaded files\n",
"\n",
"The returned dataframe will contain timeseries data with columns:\n",
"| Column | Type | Description |\n",
"| ------ | ---- | ----------- |\n",
"| Time | datetime | Timestamp reported as end of dispatch interval. |\n",
"| Region | string | The NEM region corresponding to the marginal emitter data. |\n",
"| Intensity_Index | float | The intensity index [tCO2e/MWh] (as by weighted contributions) of the price-setting generators. |\n",
"| DUID | string | Unit identifier of the generator with the largest contribution on the margin for that Time-Region. |\n",
"| CO2E_ENERGY_SOURCE | string | Unit energy source with the largest contribution on the margin for that Time-Region. |"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"The simpliest way to collect emissions data is:\n",
"```{note} \n",
"Extracting 1 month of marginal emissions data was found to take approx. 2 minutes in testing.
\n",
"Extracting 1 year of marginal emissions data was found to take approx. 30 minutes. Cached files amount to 3 GB.\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"tags": [
"hide-output"
]
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING: Warning: Gen_info table only has most recent NEM registration and exemption list. Does not account for retired generators\n",
"INFO: Processing Price Setter Files...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"0it [00:00, ?it/s]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Reading selected 366 JSON files to pandas, of cached files\n",
"INFO: Loading Cached Price Setter Files...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 366/366 [01:42<00:00, 3.56it/s]\n"
]
}
],
"source": [
"result = nemed.get_marginal_emissions(start_time=\"2021/01/01 00:00\",\n",
" end_time=\"2022/01/01 00:00\",\n",
" cache=\"E:/TEMPCACHE2/\")"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"```{info}\n",
" Q: Why is the Intensity_Index different below although it shows same DUID?\n",
"The Intensity_Index considers numerous generators that may be on the margin, and their contribution to price-setting. However, the DUID and CO2E_ENERGY_SOURCE shown only reflects a single generator with the largest influence on the margin.\n",
"\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
| \n", " | Time | \n", "Region | \n", "Intensity_Index | \n", "DUID | \n", "CO2E_ENERGY_SOURCE | \n", "
|---|---|---|---|---|---|
| 0 | \n", "2021-01-01 00:05:00 | \n", "NSW1 | \n", "0.908305 | \n", "VP6 | \n", "Black coal | \n", "
| 1 | \n", "2021-01-01 00:05:00 | \n", "QLD1 | \n", "0.855969 | \n", "VP6 | \n", "Black coal | \n", "
| 2 | \n", "2021-01-01 00:05:00 | \n", "SA1 | \n", "0.867177 | \n", "VP5 | \n", "Black coal | \n", "
| 3 | \n", "2021-01-01 00:05:00 | \n", "TAS1 | \n", "0.000000 | \n", "GORDON | \n", "Hydro | \n", "
| 4 | \n", "2021-01-01 00:05:00 | \n", "VIC1 | \n", "0.895716 | \n", "VP6 | \n", "Black coal | \n", "