{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Getting Started\n", "\n", "This is a simple example of the basic capabilities of `aneris`.\n", "\n", "First, model and history data are read in. The model is then harmonized. Finally, output is analyzed." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import seaborn as sns\n", "import matplotlib.pyplot as plt\n", "\n", "import aneris\n", "from aneris.tutorial import load_data\n", "\n", "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `driver` is used to execute the harmonization. It will handle the data formatting needed to execute the harmonizaiton operation and stores the harmonized results until they are needed.\n", "\n", "Some logging output is provided. It can be suppressed with \n", "\n", "```\n", "aneris.logger().setLevel('WARN')\n", "```" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/gidden/.local/lib/python2.7/site-packages/pandas/util/_decorators.py:118: FutureWarning: The `sheetname` keyword is deprecated, use `sheet_name` instead\n", " return func(*args, **kwargs)\n", "INFO:root:Downselecting prefix|suffix variables\n", "INFO:root:Translating to standard format\n", "INFO:root:Aggregating historical values to native regions\n", "INFO:root:Harmonizing (with example methods):\n", "INFO:root: method default \\\n", "region gas sector units \n", "regionc BC prefix|sector1|suffix kt reduce_ratio_2100 reduce_ratio_2080 \n", " prefix|sector2|suffix kt reduce_ratio_2100 reduce_ratio_2080 \n", "\n", " override \n", "region gas sector units \n", "regionc BC prefix|sector1|suffix kt reduce_ratio_2100 \n", " prefix|sector2|suffix kt reduce_ratio_2100 \n", "INFO:root:and override methods:\n", "INFO:root:region gas sector units\n", "regionc BC prefix|sector1|suffix kt reduce_ratio_2100\n", " prefix|sector2|suffix kt reduce_ratio_2100\n", "Name: method, dtype: object\n", "INFO:root:Harmonizing with reduce_ratio_2100\n", "INFO:root:Translating to IAMC template\n" ] } ], "source": [ "model, hist, driver = load_data()\n", "for scenario in driver.scenarios():\n", " driver.harmonize(scenario)\n", "harmonized, metadata, diagnostics = driver.harmonized_results()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "All data of interest is combined in order to easily view it. We will specifically investigate output for the `World` in this example. A few operations are performed in order to get the data into a plotting-friendly format." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "data = pd.concat([hist, model, harmonized])\n", "df = data[data.Region.isin(['World'])]" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "df = pd.melt(df, id_vars=aneris.iamc_idx, value_vars=aneris.numcols(df), \n", " var_name='Year', value_name='Emissions')\n", "df['Label'] = df['Model'] + ' ' + df['Variable']" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Model | \n", "Scenario | \n", "Region | \n", "Variable | \n", "Year | \n", "Emissions | \n", "Label | \n", "
---|---|---|---|---|---|---|---|
0 | \n", "History | \n", "scen | \n", "World | \n", "prefix|Emissions|BC|sector1|suffix | \n", "2000 | \n", "4.0 | \n", "History prefix|Emissions|BC|sector1|suffix | \n", "
1 | \n", "History | \n", "scen | \n", "World | \n", "prefix|Emissions|BC|sector2|suffix | \n", "2000 | \n", "6.0 | \n", "History prefix|Emissions|BC|sector2|suffix | \n", "
2 | \n", "History | \n", "scen | \n", "World | \n", "prefix|Emissions|BC|suffix | \n", "2000 | \n", "10.0 | \n", "History prefix|Emissions|BC|suffix | \n", "
3 | \n", "model | \n", "sspn | \n", "World | \n", "prefix|Emissions|BC|sector1|suffix | \n", "2000 | \n", "NaN | \n", "model prefix|Emissions|BC|sector1|suffix | \n", "
4 | \n", "model | \n", "sspn | \n", "World | \n", "prefix|Emissions|BC|sector2|suffix | \n", "2000 | \n", "NaN | \n", "model prefix|Emissions|BC|sector2|suffix | \n", "