Skip to content

Commit 228f512

Browse files
committed
Add .edits.PASTA exogenous data source
1 parent a45fce4 commit 228f512

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

message_ix_models/project/edits/__init__.py

+16
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from sdmx.model.common import Codelist
1212
from sdmx.model.v21 import DataStructureDefinition
1313

14+
from message_ix_models.tools.exo_data import ExoDataSource
1415
from message_ix_models.util import local_data_path
1516

1617
if TYPE_CHECKING:
@@ -159,6 +160,21 @@ def _transform(value: Any) -> str:
159160
}
160161

161162

163+
class PASTA(ExoDataSource):
164+
"""Retrieve and process PASTA data for use in MESSAGEix-Transport."""
165+
166+
id = "PASTA"
167+
168+
def __init__(self, source, source_kw):
169+
if not source == self.id:
170+
raise ValueError(source)
171+
172+
self.raise_on_extra_kw(source_kw)
173+
174+
def __call__(self):
175+
raise NotImplementedError
176+
177+
162178
def gen_demand(context: "Context") -> dict[str, "AnyQuantity"]:
163179
"""Generate MESSAGEix-Transport demand data from PASTA.
164180

message_ix_models/tests/project/test_edits.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import pytest
44

5-
from message_ix_models.project.edits import gen_demand, pasta_native_to_sdmx
5+
from message_ix_models.project.edits import PASTA, gen_demand, pasta_native_to_sdmx
66
from message_ix_models.util import package_data_path
77

88

@@ -15,6 +15,11 @@ def test_pasta_data(test_context):
1515
copyfile(package_data_path("test", *parts), target)
1616

1717

18+
class TestPASTA:
19+
def test_init(self) -> None:
20+
PASTA("PASTA", {})
21+
22+
1823
def test_pasta_native_to_sdmx(test_context, test_pasta_data):
1924
pasta_native_to_sdmx()
2025

0 commit comments

Comments
 (0)