Skip to content

Model

Models are mathematical representations of the energy system. They help us with technology assessment and decarbonisation pathway studies. To do this they need to represent as reliably as possible various energy-related problems.

System models in the TransitionZero platform are composed of three objects - Models, Scenarios and Runs.

Models in the TransitionZero platform describe the geographic, temporal, and sectoral scope of the systems model.

To access data for models, you can use this Jupyter Notebook on Github.

Bases: ModelBase

Source code in tz/client/model.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
class Model(schemas.ModelBase):
    @classmethod
    def from_id(cls, id: str) -> "Model":
        """
        Initialize the Model object from an ID.

        Args:
            id (str): A model ID, e.g. `feo-global-indonesia`.

        Returns:
            Model: A Model object.
        """
        model = api.models.get(slug=id)
        return cls(**model.model_dump())

    @classmethod
    def search(
        cls,
        model_slug: str | None = None,
        includes: str | None = None,
        owner: str | None = None,
        sort: str | None = None,
        featured: bool | None = None,
        public: bool | None = None,
        limit: int = 10,
        page: int = 0,
    ) -> List["Model"]:
        """
        Search for models.

        Args:
            model_slug (str | None): The target model slug to search.
            includes (str | None): Related resources to be included in the search result.
            owner (str | None): The owner of the models to filter.
            sort (str | None): The sorting criteria for the search result.
            featured (bool | None): Filter models by featured status.
            public (bool | None): Filter models by public status.
            limit (int): The maximum number of search results to return per page.
            page (int): The page number of search results to return.

        Returns:
            List[Model]: A list of Model objects.
        """

        search_results = api.models.search(
            model_slug=model_slug,
            includes=includes,
            owner=owner,
            sort=sort,
            featured=featured,
            public=public,
            limit=limit,
            page=page,
        )

        return [cls(**model.model_dump()) for model in search_results]

    @property
    def id(self) -> str:
        """The ID of the model."""
        return self.slug

    @property
    def scenarios(self) -> list["Scenario"]:
        """A collection of scenarios associated with this model."""
        model_data = api.models.get(slug=self.id, includes="scenarios")
        if model_data.scenarios is None:
            return []
        return [factory.scenario(**s.model_dump()) for s in model_data.scenarios]

    @property
    def featured_scenario(self) -> Optional["Scenario"]:
        """The featured scenario associated with this model."""
        model_data = api.models.get(slug=self.id, includes="featured_scenario")
        if model_data.featured_scenario is None:
            return None
        return factory.scenario(**model_data.featured_scenario.model_dump())

    def __str__(self) -> str:
        return f"Model: {self.name} (id={self.id})"

featured_scenario: Optional[Scenario] property

The featured scenario associated with this model.

id: str property

The ID of the model.

scenarios: list[Scenario] property

A collection of scenarios associated with this model.

from_id(id) classmethod

Initialize the Model object from an ID.

Parameters:

Name Type Description Default
id str

A model ID, e.g. feo-global-indonesia.

required

Returns:

Name Type Description
Model Model

A Model object.

Source code in tz/client/model.py
11
12
13
14
15
16
17
18
19
20
21
22
23
@classmethod
def from_id(cls, id: str) -> "Model":
    """
    Initialize the Model object from an ID.

    Args:
        id (str): A model ID, e.g. `feo-global-indonesia`.

    Returns:
        Model: A Model object.
    """
    model = api.models.get(slug=id)
    return cls(**model.model_dump())

search(model_slug=None, includes=None, owner=None, sort=None, featured=None, public=None, limit=10, page=0) classmethod

Search for models.

Parameters:

Name Type Description Default
model_slug str | None

The target model slug to search.

None
includes str | None

Related resources to be included in the search result.

None
owner str | None

The owner of the models to filter.

None
sort str | None

The sorting criteria for the search result.

None
featured bool | None

Filter models by featured status.

None
public bool | None

Filter models by public status.

None
limit int

The maximum number of search results to return per page.

10
page int

The page number of search results to return.

0

Returns:

Type Description
List[Model]

List[Model]: A list of Model objects.

Source code in tz/client/model.py
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
@classmethod
def search(
    cls,
    model_slug: str | None = None,
    includes: str | None = None,
    owner: str | None = None,
    sort: str | None = None,
    featured: bool | None = None,
    public: bool | None = None,
    limit: int = 10,
    page: int = 0,
) -> List["Model"]:
    """
    Search for models.

    Args:
        model_slug (str | None): The target model slug to search.
        includes (str | None): Related resources to be included in the search result.
        owner (str | None): The owner of the models to filter.
        sort (str | None): The sorting criteria for the search result.
        featured (bool | None): Filter models by featured status.
        public (bool | None): Filter models by public status.
        limit (int): The maximum number of search results to return per page.
        page (int): The page number of search results to return.

    Returns:
        List[Model]: A list of Model objects.
    """

    search_results = api.models.search(
        model_slug=model_slug,
        includes=includes,
        owner=owner,
        sort=sort,
        featured=featured,
        public=public,
        limit=limit,
        page=page,
    )

    return [cls(**model.model_dump()) for model in search_results]