diff --git a/message_ix_models/project/ssp/transport.py b/message_ix_models/project/ssp/transport.py index 148e7efbae..626192e9dc 100644 --- a/message_ix_models/project/ssp/transport.py +++ b/message_ix_models/project/ssp/transport.py @@ -13,13 +13,18 @@ from genno.types import AnyQuantity -# TODO Retrieve from a package data code list -EMISSION = "BC CH4 CO CO2 N2O NH3 NOx OC Sulfur VOC".split() - -def aviation_share() -> "AnyQuantity": +def aviation_share(ref: "AnyQuantity") -> "AnyQuantity": """Return (dummy) data for the share of aviation in emissions. + Currently this returns exactly the value `0.2`. + + Parameters + ---------- + ref : + Reference quantity. The dimensions and coordinates :math:`(n, e, y)` of the + returned value exactly match `ref`. + Returns ------- genno.Quantity @@ -27,9 +32,9 @@ def aviation_share() -> "AnyQuantity": """ return ( genno.Quantity(0.2, units="dimensionless") - .expand_dims({"e": EMISSION}) # Full list - .expand_dims({"n": ["CHN", "NAM"]}) # Test data specimen - .expand_dims({"y": list(range(1990, 2110 + 1))}) # Crudely cover the full list + .expand_dims({"e": sorted(ref.coords["e"].data)}) + .expand_dims({"n": sorted(ref.coords["n"].data)}) + .expand_dims({"y": sorted(ref.coords["y"].data)}) ) @@ -69,7 +74,7 @@ def _expand(qty): .reset_index() .assign( Variable=lambda df: ( - "Emission|" + df["e"] + "|Energy|Demand|Transportation|" + df["t"] + "Emissions|" + df["e"] + "|Energy|Demand|Transportation|" + df["t"] ).str.replace("|_T", "") ) .drop(["e", "t"], axis=1) @@ -213,7 +218,7 @@ def main(path_in: "pathlib.Path", path_out: "pathlib.Path"): # Share from aviation # TODO Compute this using an emission factor and the energy use totals k_share = genno.Key("AIR emission share", tuple("eny")) - c.add(k_share, aviation_share) + c.add(k_share, aviation_share, k[2] / "t") # Product of the total and aviation share → aviation emissions c.add(k[3] / t, "mul", k[2] / t, k_share) @@ -234,10 +239,10 @@ def main(path_in: "pathlib.Path", path_out: "pathlib.Path"): }, ), ) - c.add(k[5], "mul", k[3] / t, "broadcast:t:AIR emissions") + c.add(k[4], "mul", k[3] / t, "broadcast:t:AIR emissions") # Add to the input data - c.add(k[6], "add", k[1], k[5]) + c.add(k[5], "add", k[1], k[4]) # - Collapse to IAMC "VARIABLE" dimension name # - Recombine with other data @@ -246,10 +251,11 @@ def main(path_in: "pathlib.Path", path_out: "pathlib.Path"): "target", finalize, k_input, - k[6], + k[5], "model name", "scenario name", path_out=path_out, ) + # Execute c.get("target")