{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# EDGAR Temporal profiles\n", "\n", "This tutorial demonstrates how to use the auxiliary temporal profiles from edgar.\n", "\n", "The function we will use is :py:func:`emiproc.inventories.edgar.temporal.read_edgar_auxilary_profiles`.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Loading EDGAR\n", "\n", "Similarly to the EDGAR tutorial, we first load the inventory.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Inventory(EDGARv8)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from pathlib import Path\n", "from emiproc.inventories.edgar import download_edgar_files\n", "from emiproc.inventories.edgar import EDGARv8\n", "\n", "year = 2022\n", "\n", "local_dir = Path(\"./edgar\") / str(year)\n", "local_dir.mkdir(exist_ok=True, parents=True)\n", "\n", "# download_edgar_files(local_dir, year=year, substances=[\"CH4\", \"CO2\", \"CO2bio\"])\n", "inv = EDGARv8(\n", " local_dir / \"EDGAR_*.nc\",\n", " year=year,\n", " # Use short names, as this is how they are defined in the axilary table\n", " use_short_category_names=True,\n", ")\n", "inv" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Download the auxilliary data\n", "\n", "Now you have to make a manual step to download the auxilliary data from EDGAR website.\n", "\n", "You can find the `auxilliary_tables.rar` file at https://edgar.jrc.ec.europa.eu/dataset_temp_profile \n", "\n", "Download it and extract its files in a local directory.\n", "You should have 4 `.csv` files." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Read the profiles" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "from emiproc.inventories.edgar.temporal import read_edgar_auxilary_profiles\n", "\n", "path_to_auxiliary_filesdir = Path(\"/home/coli/Data/emiproc/aux_edgar/\")\n", "profiles, indices = read_edgar_auxilary_profiles(\n", " auxiliary_filesdir=path_to_auxiliary_filesdir,\n", " inventory=inv,\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### What is in the profiles ?\n", "\n", "There are two components to emiproc profiles: \n", "* the `profiles` themselves, which are objects of different temporal profile classes. \n", "* the `indices`, a xarray dataset that tells for each sector/pollutant/gridcell/... which profile to use." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "CompositeProfiles(76 profiles from ['HourOfWeekPerMonthProfile', 'WeeklyProfile'])" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "profiles" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We have 2 types of profiles:\n", "\n", "Weekly profiles that specify for each weekday how much of emissions are there.\n", "\n", "HourOfWeekPerMonth: which sounds scary, but it means that for each hour of a week\n", "there is a profile value and also for each month this value is different." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.DataArray (country: 234, category: 24)> Size: 45kB\n",
"array([[40, 63, 52, ..., 3, 24, 24],\n",
" [10, 39, 34, ..., 4, 16, 16],\n",
" [40, 63, 52, ..., 3, 24, 24],\n",
" ...,\n",
" [40, 63, 52, ..., 3, 24, 24],\n",
" [40, 63, 52, ..., 3, 24, 24],\n",
" [40, 63, 52, ..., 3, 24, 24]], shape=(234, 24))\n",
"Coordinates:\n",
" * category (category) object 192B 'ENE' 'CHE' ... 'TNR_Aviation_CRS'\n",
" * country (country) object 2kB 'ABW' 'AFG' 'AGO' 'AIA' ... 'PSE' 'ATA' 'ATF'<xarray.DataArray (country: 234, category: 24)> Size: 45kB\n",
"array([[40, 63, 52, ..., 3, 24, 24],\n",
" [10, 39, 34, ..., 4, 16, 16],\n",
" [40, 63, 52, ..., 3, 24, 24],\n",
" ...,\n",
" [40, 63, 52, ..., 3, 24, 24],\n",
" [40, 63, 52, ..., 3, 24, 24],\n",
" [40, 63, 52, ..., 3, 24, 24]], shape=(234, 24))\n",
"Coordinates:\n",
" * category (category) object 192B 'ENE' 'CHE' ... 'TNR_Aviation_CRS'\n",
" * country (country) object 2kB 'ABW' 'AFG' 'AGO' 'AIA' ... 'PSE' 'ATA' 'ATF'