Skip to content

Commit 08dc7fc

Browse files
authored
Merge pull request #259 from iiasa/transport/2024-W49
Transport improvements from 2024-W49
2 parents 29ec892 + 3c589c0 commit 08dc7fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2002
-648
lines changed

doc/api/data-sources.rst

+8-7
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,16 @@ The data:
6363

6464
The approach to handling proprietary data is the same as in :mod:`.project.advance` and :mod:`.project.ssp`:
6565

66-
- Copies of the data are stored in the (private) :mod:`message_data` repository using Git LFS.
66+
- Copies of the data are stored in the (private) `message-static-data` repository using Git LFS.
6767
This respository is accessible only to users who have a license for the data.
6868
- :mod:`message_ix_models` contains only a ‘fuzzed’ version of the data (same structure, random values) for testing purposes.
6969
- Non-IIASA users must obtain their own license to access and use the data; obtain the data themselves; and place it on the system where they use :mod:`message_ix_models`.
7070

7171
The module :mod:`message_ix_models.tools.iea.web` attempts to detect and support both the providers/formats described below.
7272
The code supports using data from any of the above locations and formats, in multiple ways:
7373

74-
- Use :func:`.tools.iea.web.load_data` to load data as :class:`pandas.DataFrame` and apply further pandas processing.
75-
- Use :class:`.IEA_EWEB` via :func:`.tools.exo_data.prepare_computer` to use the data in :mod:`genno` structured calculations.
74+
- Use :class:`.IEA_EWEB` via :func:`.exo_data.prepare_computer` to use the data in :mod:`genno` structured calculations.
75+
- Use :func:`.iea.web.load_data` to load data as :class:`pandas.DataFrame` and apply further processing using pandas.
7676

7777
The **documentation** for the `2023 edition <https://iea.blob.core.windows.net/assets/0acb1453-1221-421b-9131-632ce71a4c1a/WORLDBAL_Documentation.pdf>`__ of the IEA source/format is publicly available.
7878

@@ -82,8 +82,8 @@ Structure
8282
The data have the following conceptual dimensions, each enumerated by a different list of codes:
8383

8484
- ``FLOW``, ``PRODUCT``: for both of these, the lists of codes appearing in the data are the same from 2021 and 2023 inclusive.
85-
- ``COUNTRY``: The data provided by IEA directly contain codes that are all caps, abbreviated country names, for instance "DOMINICANR".
86-
The data provided by the OECD contain ISO 3166-1 alpha-3 codes, for instance "DOM".
85+
- ``COUNTRY``: The data provided by IEA directly contain codes that are all caps, abbreviated country names, for instance 'DOMINICANR'.
86+
The data provided by the OECD contain ISO 3166-1 alpha-3 codes, for instance 'DOM'.
8787
In both cases, there are additional labels denoting country groupings; these are defined in the documentation linked above.
8888

8989
Changes visible in these lists include:
@@ -98,8 +98,9 @@ The data have the following conceptual dimensions, each enumerated by a differen
9898
- New codes: GNQ, MDG, MKD, RWA, SWZ, UGA.
9999
- Removed: EQGUINEA, GREENLAND, MALI, MBURKINAFA, MCHAD, MMADAGASCA, MMAURITANI, MPALESTINE, MRWANDA, MUGANDA, NORTHMACED.
100100

101-
- TIME: always a year.
102-
- MEASURE: unit of measurement, either "TJ" or "ktoe".
101+
See the :py:`transform=...` source keyword argument and :meth:`.IEA_EWEB.transform` for different methods of handling this dimension.
102+
- ``TIME``: always a year.
103+
- ``UNIT_MEASURE`` (not labeled): unit of measurement, either 'TJ' or 'ktoe'.
103104

104105
:mod:`message_ix_models` is packaged with SDMX structure data (stored in :file:`message_ix_models/data/sdmx/`) comprising code lists extracted from the raw data for the COUNTRY, FLOW, and PRODUCT dimensions.
105106
These can be used with other package utilities, for instance:

doc/api/util.rst

+9
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ Submodules:
1010

1111
click
1212
context
13+
genno
1314
importlib
1415
_logging
1516
node
1617
pooch
18+
pycountry
1719
scenarioinfo
1820
sdmx
1921

@@ -158,6 +160,13 @@ Commonly used:
158160

159161
If no base scenario can be loaded, :func:`.bare.create_res` is called to generate a base scenario.
160162

163+
:mod:`.util.genno`
164+
==================
165+
166+
.. currentmodule:: message_ix_models.util.genno
167+
168+
.. automodule:: message_ix_models.util.genno
169+
:members:
161170

162171
:mod:`.util.importlib`
163172
======================

doc/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@
7474
.. role:: strike
7575
.. role:: underline
7676
77+
.. |c| replace:: :math:`c`
7778
.. |n| replace:: :math:`n`
79+
.. |t| replace:: :math:`t`
7880
.. |y| replace:: :math:`y`
7981
.. |y0| replace:: :math:`y_0`
8082

doc/project/ssp.rst

+17
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,20 @@ Transport
5454
:members:
5555

5656
Use :program:`mix-models ssp transport --help in.xlsx out.xlsx` to invoke :func:`.main`.
57+
Data are read from PATH_IN, in :file:`.xlsx` or :file:`.csv` format.
58+
If :file:`.xlsx`, the data are first temporarily converted to :file:`.csv`.
59+
Data are written to PATH_OUT; if not given, this defaults to the same path and suffix as PATH_IN, with "_out" added to the stem.
60+
61+
For example:
62+
63+
.. code-block:: shell
64+
65+
mix-models ssp transport --method=B \
66+
SSP_SSP2_v2.1_baseline.xlsx
67+
68+
…produces a file :file:`SSP_SSP2_v2.1_baseline_out.xlsx` in the same directory.
69+
70+
As of 2025-01-25:
71+
72+
- Method 'B' (that is, :func:`.prepare_method_B`; see its documentation) is the preferred method.
73+
- The code is tested on :file:`.xlsx` files in the (internal) directories under `SharePoint > ECE > Documents > SharedSocioeconomicPathways2023 > Scenario_Vetting <https://iiasahub.sharepoint.com/sites/eceprog/Shared%20Documents/Forms/AllItems.aspx?csf=1&web=1&e=APKv0Z&CID=23fa0a51%2Dc303%2D4381%2D8c6d%2D143305cbc5a1&FolderCTID=0x012000AA9481BF7BE9264E85B14105F7F082FF&id=%2Fsites%2Feceprog%2FShared%20Documents%2FSharedSocioEconomicPathways2023%2FScenario%5FVetting&viewid=956acd8a%2De1e7%2D4ae9%2Dab1b%2D0506911bae11>`_, for example :file:`v2.1_Internal_version_Dec13_2024/Reporting_output/SSP_SSP2_v2.1_baseline.xlsx`.

doc/transport/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Run the entire workflow
142142
The options result in the following behaviour:
143143

144144
- :program:`--platform=ixmp-dev`: store MESSAGEix-Transport scenarios on the :mod:`ixmp` platform named "ixmp-dev".
145-
- :program:`--base=auto`: identify the base scenario URLs using :func:`.base_scenario_url` / the file :file:`base-scenario-url.json`, according to other config settings.
145+
- :program:`--base=auto`: identify the base scenario URLs using :func:`.base_scenario_url` / the file :ref:`CL_TRANSPORT_SCENARIO`, according to other config settings.
146146
- :program:`--model-extra="ci nightly"`: append the string " ci nightly" to the model name of any created Scenario.
147147
This avoids accidentally producing new versions of ‘production’ (model name, scenario name) combinations.
148148
- :program:`--from=""`: start from the very first step in the workflow—load the identified base scenario—and perform all subsequent workflow steps, up to and including…

doc/transport/input.rst

+49-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ This value is retrieved from the :attr:`.model.Config.regions` setting on a :cla
2020

2121
.. _transport-config:
2222

23-
Configuration
24-
=============
23+
Configuration and model structure
24+
=================================
2525

2626
General (:file:`config.yaml`, required)
2727
---------------------------------------
@@ -50,13 +50,45 @@ This file gives code lists for other MESSAGE concepts/sets/dimensions.
5050

5151
→ View :source:`message_ix_models/data/transport/set.yaml` on GitHub
5252

53+
.. _CL_TRANSPORT_SCENARIO:
54+
55+
Code list ``CL_TRANSPORT_SCENARIO``
56+
-----------------------------------
57+
58+
This code list, stored in the file :file:`message_ix_models/data/sdmx/IIASA_ECE_CL_TRANSPORT_SCENARIO(1.0.0).xml`, contains an SDMX code list for distinct MESSAGEix-Transport scenarios.
59+
The codes have IDs like ``LED-SSP1`` that give a short identifier used in :mod:`.transport.workflow` and elsewhere, and names that give a complete, human-readable description.
60+
Every code has all of following annotations:
61+
62+
``SSP-URN``
63+
Complete URN of a code in ``ICONICS:SSP(2024)`` or another code list for the SSP used for sociodemographic input data and to control other settings in :mod:`.transport.build`.
64+
65+
Example annotation text: ``'urn:sdmx:org.sdmx.infomodel.codelist.Code=ICONICS:SSP(2024).1'``
66+
67+
``is-LED-Scenario``
68+
Example annotation text: ``True``
69+
70+
:func:`repr` of Python :any:`True` or :any:`False`, the former indicating that "Low Energy Demand (LED)" settings should be used.
71+
See also :attr:`Config.project <.transport.config.Config.project>`.
72+
73+
``EDITS-activity-id``
74+
Example annotation text: ``'HA'``
75+
76+
For :doc:`/project/edits`, the identity of an ITF PASTA scenario providing exogenous transport activity.
77+
78+
``base-scenario-URL``
79+
Example annotation text: ``'ixmp://ixmp-dev/SSP_SSP1_v1.1/baseline_DEFAULT_step_13'``
80+
81+
URL of a base scenario used to build the corresponding MESSAGEix-Transport scenario.
82+
83+
5384
.. _transport-data-files:
5485

5586
Input data files
5687
================
5788

5889
:data:`.transport.files.FILES` gives a list of all data files.
59-
Through :func:`.transport.build.main` (ultimately, :func:`.transport.build.add_exogenous_data`), each of these files is connected to a :class:`genno.Computer` used for model-building, and its contents appear at the key given in the list below.
90+
Through :func:`.transport.build.main` (ultimately, :func:`.transport.build.add_exogenous_data`), each of these files is connected to a :class:`genno.Computer` used for model-building.
91+
Its content are available at the corresponding key, which is used as an input for further model-building computations.
6092

6193
.. admonition:: Example
6294

@@ -67,9 +99,22 @@ Through :func:`.transport.build.main` (ultimately, :func:`.transport.build.add_e
6799
Not all files are currently or always used in model-building computations.
68100
Some submodules of :mod:`~.model.transport` use additional data files via other mechanisms.
69101
Most of the files have a header comment including a precise description of the quantity, source of the data, and units of measurement.
70-
In some cases extended information is below (where a header comment would be too long).
102+
In some caseswhere a header comment would be too long—extended information is below.
71103
The :program:`git` history of files, or the GitHub "blame" view can also be used to inspect the edit history of each file, line by line.
72104

105+
.. _transport-input-emi-intensity:
106+
107+
:file:`emi-intensity.csv` → ``emissions intensity:t-c-e:transport``
108+
-------------------------------------------------------------------
109+
110+
Measure
111+
Emissions intensity of energy use
112+
Units
113+
g (of emissions species) / MJ (of input energy)
114+
115+
See the file :source:`on GitHub <message_ix_models/data/transport/emi-intensity.csv>` for inline comments and commit history.
116+
Currently only used in :mod:`.ssp.transport`.
117+
73118
:file:`ldv-activity.csv` → ``ldv activity:n:exo``
74119
-------------------------------------------------
75120

doc/whatsnew.rst

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
What's new
22
**********
33

4-
.. Next release
5-
.. ============
4+
Next release
5+
============
6+
7+
- Update :class:`.IEA_EWEB` to support :py:`transform="B"` / :func:`.transform_B` (:issue:`230`, :pull:`259`).
8+
- Update :doc:`/transport/index` (:pull:`259`).
9+
10+
- Adjust constraints on :py:`t="conm_ar"`.
11+
- Recompute :attr:`.minimum_activity` for transport technologies.
12+
- Adjust freight activity, freight and passenger mode shares for some regions.
13+
- Drop :file:`base-scenario-url.json`; store base scenario URLs in :ref:`CL_TRANSPORT_SCENARIO`.
14+
- Simplify and consolidate tests.
15+
16+
- Add :func:`.prepare_method_B` to :mod:`.ssp.transport` (:pull:`259`).
17+
- New utility :class:`.sdmx.AnnotationsMixIn` (:pull:`259`).
618

719
v2025.1.10
820
==========

message_ix_models/data/emission.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ CO2:
1313

1414
N2O:
1515
name: Nitrous oxide
16+
units: kt
1617

1718
NH3:
1819
name: Ammonia

0 commit comments

Comments
 (0)