Skip to content

Scenario

All TransitionZero models employ scenario analysis to investigate different assumptions about the technical and economic conditions at play. Scenarios are designed to be used as a set to explore and navigate what might happen, not what should happen or what we want to happen.

For example, in the Indonesia JETP model currently available in the TransitionZero platform, we have four scenarios:

  • Coal Phaseout
  • Current Policies
  • Least Cost
  • NetZero 2060

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

Bases: ScenarioBase

Source code in tz/client/scenario.py
 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
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
class Scenario(schemas.ScenarioBase):
    @classmethod
    def from_id(cls, id: str) -> "Scenario":
        """
        Initialize the Scenario object from an ID.

        Args:
            id (str): A scenario ID, e.g. `model-slug:scenario-slug`.

        Returns:
            Scenario: A Scenario object.
        """
        scenario = api.scenarios.get(fullslug=id)
        return cls(**scenario.model_dump())

    @classmethod
    def search(
        cls,
        scenario_slug: str | None = None,
        model_slug: str | None = None,
        includes: str | None = None,
        owner_id: str | None = None,
        featured: bool | None = None,
        public: bool | None = None,
        limit: int = 5,
        page: int = 0,
    ) -> List["Scenario"]:
        """
        Search for scenarios based on various filters.

        Args:
            scenario_slug (str | None): The slug of the scenario to search for.
            model_slug (str | None): The slug of the model to filter scenarios by.
            includes (str | None): Related resources to be included in the search result.
            owner_id (str | None): The ID of the owner to filter scenarios by.
            featured (bool | None): Whether to filter scenarios by featured status.
            public (bool | None): Whether to filter scenarios 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[Scenario]: A list of Scenario objects matching the search criteria.
        """

        search_results = api.scenarios.search(
            scenario_slug=scenario_slug,
            model_slug=model_slug,
            includes=includes,
            owner_id=owner_id,
            featured=featured,
            public=public,
            limit=limit,
            page=page,
        )

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

    @property
    def id(self) -> str:
        """
        The ID of the scenario. A combination of the model slug and scenario slug.
        """
        return f"{self.model_slug}:{self.slug}"

    @property
    def model(self) -> Optional["Model"]:
        """The model associated with this scenario."""
        scenario_data = api.scenarios.get(fullslug=self.id, includes="model")
        if scenario_data.model is None:
            return None
        return factory.model(**scenario_data.model.model_dump())

    @property
    def featured_run(self) -> Optional["Run"]:
        """The featured run associated with this scenario."""
        scenario_data = api.scenarios.get(fullslug=self.id, includes="featured_run")
        if scenario_data.featured_run is None:
            return None
        return factory.run(**scenario_data.featured_run.model_dump())

    @property
    def runs(self) -> list["Run"]:
        """The featured run associated with this scenario."""
        scenario_data = api.scenarios.get(fullslug=self.id, includes="runs")
        if scenario_data.runs is None:
            return []
        return [factory.run(**r.model_dump()) for r in scenario_data.runs]

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

featured_run: Optional[Run] property

The featured run associated with this scenario.

id: str property

The ID of the scenario. A combination of the model slug and scenario slug.

model: Optional[Model] property

The model associated with this scenario.

runs: list[Run] property

The featured run associated with this scenario.

from_id(id) classmethod

Initialize the Scenario object from an ID.

Parameters:

Name Type Description Default
id str

A scenario ID, e.g. model-slug:scenario-slug.

required

Returns:

Name Type Description
Scenario Scenario

A Scenario object.

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

    Args:
        id (str): A scenario ID, e.g. `model-slug:scenario-slug`.

    Returns:
        Scenario: A Scenario object.
    """
    scenario = api.scenarios.get(fullslug=id)
    return cls(**scenario.model_dump())

search(scenario_slug=None, model_slug=None, includes=None, owner_id=None, featured=None, public=None, limit=5, page=0) classmethod

Search for scenarios based on various filters.

Parameters:

Name Type Description Default
scenario_slug str | None

The slug of the scenario to search for.

None
model_slug str | None

The slug of the model to filter scenarios by.

None
includes str | None

Related resources to be included in the search result.

None
owner_id str | None

The ID of the owner to filter scenarios by.

None
featured bool | None

Whether to filter scenarios by featured status.

None
public bool | None

Whether to filter scenarios by public status.

None
limit int

The maximum number of search results to return per page.

5
page int

The page number of search results to return.

0

Returns:

Type Description
List[Scenario]

List[Scenario]: A list of Scenario objects matching the search criteria.

Source code in tz/client/scenario.py
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
@classmethod
def search(
    cls,
    scenario_slug: str | None = None,
    model_slug: str | None = None,
    includes: str | None = None,
    owner_id: str | None = None,
    featured: bool | None = None,
    public: bool | None = None,
    limit: int = 5,
    page: int = 0,
) -> List["Scenario"]:
    """
    Search for scenarios based on various filters.

    Args:
        scenario_slug (str | None): The slug of the scenario to search for.
        model_slug (str | None): The slug of the model to filter scenarios by.
        includes (str | None): Related resources to be included in the search result.
        owner_id (str | None): The ID of the owner to filter scenarios by.
        featured (bool | None): Whether to filter scenarios by featured status.
        public (bool | None): Whether to filter scenarios 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[Scenario]: A list of Scenario objects matching the search criteria.
    """

    search_results = api.scenarios.search(
        scenario_slug=scenario_slug,
        model_slug=model_slug,
        includes=includes,
        owner_id=owner_id,
        featured=featured,
        public=public,
        limit=limit,
        page=page,
    )

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