Skip to content

odys.parameters.coordinates

Internal implementation detail. Most users do not need this page directly.

Coordinate labels along one dimension of parameter arrays and model variables.

Coordinates

Bases: BaseModel

Coordinate labels along a single dimension.

Source code in src/odys/parameters/coordinates.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
class Coordinates(BaseModel):
    """Coordinate labels along a single dimension."""

    model_config = ConfigDict(frozen=True, extra="forbid")

    dimension: str
    labels: tuple[str, ...]

    @classmethod
    def of_entities(cls, dimension: str, entities: Sequence[EnergyEntity]) -> Self:
        """Return coordinates labelled by the entities' names, in order.

        Args:
            dimension: The dimension the entities are indexed along.
            entities: The entities, such as all generators of the portfolio.

        Returns:
            The coordinates.

        """
        return cls(dimension=dimension, labels=tuple(entity.name for entity in entities))

    @property
    def dimension_coordinates_map(self) -> dict[str, list[str]]:
        """Return the xarray coordinate mapping for this dimension."""
        return {self.dimension: list(self.labels)}

dimension_coordinates_map property

Return the xarray coordinate mapping for this dimension.

of_entities(dimension, entities) classmethod

Return coordinates labelled by the entities' names, in order.

Parameters:

Name Type Description Default
dimension str

The dimension the entities are indexed along.

required
entities Sequence[EnergyEntity]

The entities, such as all generators of the portfolio.

required

Returns:

Type Description
Self

The coordinates.

Source code in src/odys/parameters/coordinates.py
19
20
21
22
23
24
25
26
27
28
29
30
31
@classmethod
def of_entities(cls, dimension: str, entities: Sequence[EnergyEntity]) -> Self:
    """Return coordinates labelled by the entities' names, in order.

    Args:
        dimension: The dimension the entities are indexed along.
        entities: The entities, such as all generators of the portfolio.

    Returns:
        The coordinates.

    """
    return cls(dimension=dimension, labels=tuple(entity.name for entity in entities))