Skip to content

Commit

Permalink
Remove .projects.shape, .tools.{gea,iea_eei}
Browse files Browse the repository at this point in the history
migrated and improved in #162
  • Loading branch information
khaeru committed Jul 29, 2024
1 parent 4111154 commit b9852b1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
5 changes: 4 additions & 1 deletion message_ix_models/model/transport/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
from sdmx.model.v21 import Code

from message_data.projects.navigate import T35_POLICY
from message_data.tools import iea_eei

from .config import Config

Expand Down Expand Up @@ -271,6 +270,8 @@ def distance_ldv(config: dict) -> "AnyQuantity":
def distance_nonldv(config: dict) -> "AnyQuantity":
"""Return annual travel distance per vehicle for non-LDV transport modes."""
# Load from IEA EEI
from message_data.tools import iea_eei # type: ignore [attr-defined]

dfs = iea_eei.get_eei_data(config["regions"])
df = (
dfs["vehicle use"]
Expand Down Expand Up @@ -607,6 +608,8 @@ def merge_data(

def iea_eei_fv(name: str, config: Dict) -> "AnyQuantity":
"""Returns base-year demand for freight from IEA EEI, with dimensions n-c-y."""
from message_data.tools import iea_eei # type: ignore [attr-defined]

result = iea_eei.as_quantity(name, config["regions"])
ym1 = result.coords["y"].data[-1]

Expand Down
4 changes: 1 addition & 3 deletions message_ix_models/model/transport/roadmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
from message_ix_models.util import private_data_path
from plotnine import save_as_pdf_pages

from message_data.tools.iea_eei import plot_params_per_mode

#: Name of the file containing the data.
FILE = "RoadmapResults_2017.xlsx"

Expand Down Expand Up @@ -168,7 +166,7 @@ def get_roadmap_data(context, region=("Africa", "R11_AFR"), years=None, plot=Fal
debug_path.mkdir(parents=True, exist_ok=True)
# Plot all indicators as grid, per mode, and store them into PNG images
save_as_pdf_pages(
plot_params_per_mode(df),
# plot_params_per_mode(df), # TODO Convert to use genno.core.plotnine.Plot
filename=f"{context.model.regions}_AFR_Indicators_per_mode.pdf",
path=debug_path,
)
Expand Down
8 changes: 0 additions & 8 deletions message_ix_models/tests/model/transport/test_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
distance_nonldv,
factor_input,
factor_ssp,
iea_eei_fv,
pdt_per_capita,
transport_check,
)
Expand Down Expand Up @@ -133,13 +132,6 @@ def test_factor_ssp(test_context, ssp: SSP_2024) -> None:
assert {"n", "y"} == set(result.dims)


def test_iea_eei_fv():
# TODO expand with additional cases
result = iea_eei_fv("tonne-kilometres", dict(regions="R12"))

assert 12 == len(result)


DATA = """
n y value
R11_AFR 2020 0
Expand Down

0 comments on commit b9852b1

Please sign in to comment.