Skip to content

Commit

Permalink
Document .ssp.transport
Browse files Browse the repository at this point in the history
  • Loading branch information
khaeru committed Oct 3, 2024
1 parent cbbdbd3 commit 6cf3638
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
13 changes: 13 additions & 0 deletions doc/project/ssp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,16 @@ Data
.. autosummary::
SSPOriginal
SSPUpdate

2024 update
===========

Transport
---------

.. currentmodule:: message_ix_models.project.ssp.transport

.. automodule:: message_ix_models.project.ssp.transport
:members:

Use :program:`mix-models ssp transport --help in.xlsx out.xlsx` to invoke :func:`.main`.
21 changes: 18 additions & 3 deletions message_ix_models/project/ssp/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ def extract_dims(
def extract_dims1(qty: "AnyQuantity", dim: dict) -> "AnyQuantity": # pragma: no cover
"""Extract dimensions from IAMC-like ‘variable’ names expressions.
.. note:: This incomplete, non-working version uses :mod:`xarray` semantics.
.. note:: This incomplete, non-working version of :func:`extract_dims` uses
:mod:`xarray` semantics.
"""
from collections import defaultdict

Expand Down Expand Up @@ -148,12 +149,27 @@ def select_re(qty: "AnyQuantity", indexers: dict) -> "AnyQuantity":
return qty.sel(new_indexers)


#: Expression for IAMC ‘variable’ names used in :func:`main`.
EXPR = r"^Emissions\|(?P<e>[^\|]+)\|Energy\|Demand\|Transportation(?:\|(?P<t>.*))?$"


def main(path_in: "pathlib.Path", path_out: "pathlib.Path"):
"""Postprocess aviation emissions for SSP 2024.
1. Read input data from `path_in`.
2. Select data with variable names matching :data:`EXPR`.
3. Calculate (identical) values for:
- ``Emissions|*|Energy|Demand|Transportation|Aviation``
- ``Emissions|*|Energy|Demand|Transportation|Aviation|International``
These are currently calculated as the product of :func:`aviation_share` and
``Emissions|*|Energy|Demand|Transportation``.
4. Subtract (3) from:
``Emissions|*|Energy|Demand|Transportation|Road Rail and Domestic Shipping``
5. Recombine with all other, unmodified data.
6. Write to `path_out`.
Parameters
----------
path_in :
Expand Down Expand Up @@ -208,13 +224,12 @@ def main(path_in: "pathlib.Path", path_out: "pathlib.Path"):
c.add(
"broadcast:t:AIR emissions",
genno.Quantity(
[1, 1, -1, -1],
[1, 1, -1],
coords={
"t": [
"Aviation",
"Aviation|International",
"Road Rail and Domestic Shipping",
"_T",
]
},
),
Expand Down

0 comments on commit 6cf3638

Please sign in to comment.