Skip to content

Input profile schema

Classes:

Name Description
InputProfile

Class containing the temperature and load profiles for the switchgear thermal model Model().

InputProfile

Bases: BaseModel

Class containing the temperature and load profiles for the switchgear thermal model Model().

This class is also capable of converting the results to a single dataframe with the timestamp as the index for convenience.

This class is a simplified version of the transformer_thermal_model input_profile class (TTM 0.2.1).

Attributes:

Name Type Description
datetime_index NDArray[datetime64]

A 1d array with the datetime index for the profiles.

load_profile NDArray[float64]

A 1d array with the load profile for the switchgear.

ambient_temperature_profile NDArray[float64]

A 1d array with the ambient temperature profile for the switchgear.

Methods:

Name Description
create

Create an InputProfile.

from_dataframe

Create an InputProfile from a dataframe.

load_profile_array property

load_profile_array: NDArray[float64]

Return the single load profile for the switchgear.

dt property

dt: ndarray

The time step between the data points in minutes, with zero for the first element.

Returns:

Type Description
ndarray

np.ndarray[np.timedelta64]: The time step between the data points in minutes.

ambient_temperature_is_constant property

ambient_temperature_is_constant: bool

Check if the ambient temperature profile is constant up to a tolerance of 1e-6.

create classmethod

create(
    datetime_index: Collection[datetime],
    load_profile: Collection[float],
    ambient_temperature_profile: Collection[float],
) -> Self

Create an InputProfile.

Parameters:

Name Type Description Default
datetime_index Collection[datetime]

The datetime index for the profiles.

required
load_profile Collection[float]

The load profile for the switchgear.

required
ambient_temperature_profile Collection[float]

The ambient temperature profile for the switchgear.

required

Returns:

Type Description
Self

An InputProfile object.

Creating an InputProfile from collections.
>>> from datetime import datetime
>>> from switchgear_thermal_model.schemas import InputProfile

>>> datetime_index = [
...     datetime(2023, 1, 1, 0, 0),
...     datetime(2023, 1, 1, 1, 0),
...     datetime(2023, 1, 1, 2, 0),
... ]
>>> load_profile = [0.8, 0.9, 1.0]
>>> ambient_temperature_profile = [25.0, 24.5, 24.0]
>>> input_profile = InputProfile.create(
...     datetime_index=datetime_index,
...     load_profile=load_profile,
...     ambient_temperature_profile=ambient_temperature_profile,
... )
>>> input_profile
InputProfile(datetime_index=array(['2023-01-01T00:00:00.000000',
'2023-01-01T01:00:00.000000', '2023-01-01T02:00:00.000000'],
dtype='datetime64[us]'), ambient_temperature_profile=array([25. , 24.5, 24. ]),
load_profile=array([0.8, 0.9, 1. ]))
Directly creating an InputProfile object using numpy arrays.
>>> import numpy as np
>>> from datetime import datetime
>>> from switchgear_thermal_model.schemas import InputProfile

>>> input_profile = InputProfile(
...     datetime_index=np.array(
...         [
...             datetime(2023, 1, 1, 0, 0),
...             datetime(2023, 1, 1, 1, 0),
...             datetime(2023, 1, 1, 2, 0)
...         ],
...         dtype=np.datetime64,
...     ),
...     load_profile=np.array([0.8, 0.9, 1.0], dtype=float),
...     ambient_temperature_profile=np.array([25.0, 24.5, 24.0], dtype=float)
... )
>>> input_profile
InputProfile(datetime_index=array(['2023-01-01T00:00:00.000000',
'2023-01-01T01:00:00.000000', '2023-01-01T02:00:00.000000'],
dtype='datetime64[us]'), ambient_temperature_profile=array([25. , 24.5, 24. ]),
load_profile=array([0.8, 0.9, 1. ]))
Source code in switchgear_thermal_model/schemas/input_profile.py
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
@classmethod
def create(
    cls,
    datetime_index: Collection[datetime],
    load_profile: Collection[float],
    ambient_temperature_profile: Collection[float],
) -> Self:
    """Create an InputProfile.

    Args:
        datetime_index: The datetime index for the profiles.
        load_profile: The load profile for the switchgear.
        ambient_temperature_profile: The ambient temperature profile for the switchgear.

    Returns:
        An InputProfile object.

    Example: Creating an InputProfile from collections.
        ```python
        >>> from datetime import datetime
        >>> from switchgear_thermal_model.schemas import InputProfile

        >>> datetime_index = [
        ...     datetime(2023, 1, 1, 0, 0),
        ...     datetime(2023, 1, 1, 1, 0),
        ...     datetime(2023, 1, 1, 2, 0),
        ... ]
        >>> load_profile = [0.8, 0.9, 1.0]
        >>> ambient_temperature_profile = [25.0, 24.5, 24.0]
        >>> input_profile = InputProfile.create(
        ...     datetime_index=datetime_index,
        ...     load_profile=load_profile,
        ...     ambient_temperature_profile=ambient_temperature_profile,
        ... )
        >>> input_profile
        InputProfile(datetime_index=array(['2023-01-01T00:00:00.000000',
        '2023-01-01T01:00:00.000000', '2023-01-01T02:00:00.000000'],
        dtype='datetime64[us]'), ambient_temperature_profile=array([25. , 24.5, 24. ]),
        load_profile=array([0.8, 0.9, 1. ]))

        ```

    Example: Directly creating an InputProfile object using numpy arrays.
        ```python
        >>> import numpy as np
        >>> from datetime import datetime
        >>> from switchgear_thermal_model.schemas import InputProfile

        >>> input_profile = InputProfile(
        ...     datetime_index=np.array(
        ...         [
        ...             datetime(2023, 1, 1, 0, 0),
        ...             datetime(2023, 1, 1, 1, 0),
        ...             datetime(2023, 1, 1, 2, 0)
        ...         ],
        ...         dtype=np.datetime64,
        ...     ),
        ...     load_profile=np.array([0.8, 0.9, 1.0], dtype=float),
        ...     ambient_temperature_profile=np.array([25.0, 24.5, 24.0], dtype=float)
        ... )
        >>> input_profile
        InputProfile(datetime_index=array(['2023-01-01T00:00:00.000000',
        '2023-01-01T01:00:00.000000', '2023-01-01T02:00:00.000000'],
        dtype='datetime64[us]'), ambient_temperature_profile=array([25. , 24.5, 24. ]),
        load_profile=array([0.8, 0.9, 1. ]))

        ```
    """
    return cls(
        datetime_index=np.array(datetime_index, dtype=np.datetime64),
        load_profile=np.array(load_profile, dtype=float),
        ambient_temperature_profile=np.array(ambient_temperature_profile, dtype=float),
    )

from_dataframe classmethod

from_dataframe(df: DataFrame) -> Self

Create an InputProfile from a dataframe.

Source code in switchgear_thermal_model/schemas/input_profile.py
156
157
158
159
160
161
162
163
164
165
166
167
168
@classmethod
def from_dataframe(cls, df: pd.DataFrame) -> Self:
    """Create an InputProfile from a dataframe."""
    required_columns = {"datetime_index", "load_profile", "ambient_temperature_profile"}
    missing_columns = required_columns - set(df.columns)
    if missing_columns:
        raise ValueError(f"The dataframe is missing the following required columns: {', '.join(missing_columns)}")

    return cls(
        datetime_index=df["datetime_index"].to_numpy(),
        load_profile=df["load_profile"].to_numpy(),
        ambient_temperature_profile=df["ambient_temperature_profile"].to_numpy(),
    )