{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Performing unit conversions\n", "\n", "Conversion of timeseries data units is one of the most tedious aspects of modelling and scenario analysis -\n", "and it is a frequent source for errors!\n", "\n", "The **pyam** function [convert_unit()](https://pyam-iamc.readthedocs.io/en/stable/api/iamdataframe.html#pyam.IamDataFrame.convert_unit) can support and simplify this task.\n", "The function uses the Python package [pint](https://pint.readthedocs.io),\n", "which natively handles conversion of standard (SI) units and commonly used equivalents \n", "(e.g., exajoule to terawatt-hours, `EJ -> TWh`).\n", "The **pint** package can also parse combined units (e.g., exajoule per year, `EJ/yr`).\n", "\n", "To better support common use cases when working with energy systems analysis and integrated-assessment scenarios,\n", "the default [pint.UnitRegistry](https://pint.readthedocs.io/en/stable/developers_reference.html#pint.UnitRegistry)\n", "used by **pyam** loads the unit definitions collected at [IAMconsortium/units](https://github.com/IAMconsortium/units).\n", "This repository provides a wide range of conversion factors in a **pint**-compatible format\n", "so that they can easily be used across multiple applications (**pyam** is just one of them).\n", "\n", "