Weather#
smart_control.simulator.weather_controller
#
Controls ambient temperature in simulator.
BaseWeatherController
#
Represents the weather on any specific time.
get_current_temp
abstractmethod
#
Gets outside temp at specified timestamp.
ReplayWeatherController
#
ReplayWeatherController(
local_weather_path: str = WEATHER_CSV_FILEPATH,
convection_coefficient: float = 12.0,
humidity_column: str = "Humidity",
)
Bases: BaseWeatherController
Weather controller that interplolates real weather from past observations.
Attributes:
| Name | Type | Description |
|---|---|---|
local_weather_path |
Path to local weather CSV file. |
|
weather_df |
Pandas dataframe of historical weather data. |
|
convection_coefficient |
Air convection coefficient (W/m2/K). |
|
humidity_column |
Column name of the humidity in the weather CSV file. |
times_in_seconds
property
#
Returns the timestamps of the weather data, as seconds since epoch.
get_current_humidity
#
For a given timestamp, returns the current humidity level in percent.
get_current_temp
#
For a given timestamp, returns the current temperature in Kelvin.
read_weather_csv
#
Loads time series weather data from the specified CSV file.
The CSV file is expected to have at least the following columns:
Time: the time, as a string, in the format:%Y%m%d-%H%M(e.g.20230701-0000). Assumed to be in UTC.TempF: the temperature in Fahrenheit at the specified time.Humidity: the relative humidity in percent at the specified time (0 to 100).
Coerces the times to UTC. Updates the index to be seconds since epoch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
csv_filepath
|
str
|
Path to local weather CSV file. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Pandas dataframe of weather data. |
WeatherController
#
WeatherController(
default_low_temp: float,
default_high_temp: float,
special_days: Optional[Mapping[int, TemperatureBounds]] = None,
convection_coefficient: float = 12.0,
)
Bases: BaseWeatherController
Represents the weather on any given day.
Weather operates as a sinusoid: low at midnight and high at noon.
Attributes:
| Name | Type | Description |
|---|---|---|
default_low_temp |
Default low temperature in K at midnight. |
|
default_high_temp |
Default high temperature in K at noon. |
|
special_days |
Map of day of year (1-365) to 2-tuple (low_temp, high_temp). |
|
convection_coefficient |
Air convection coefficient (W/m2/K). |
get_air_convection_coefficient
#
Returns the convection coefficient (W/m2/K) based on the current wind.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timestamp
|
Timestamp
|
Pandas timestamp to get convection coefficient for. |
required |
get_current_temp
#
Returns current temperature in K.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timestamp
|
Timestamp
|
Pandas timestamp to get temperature for. |
required |
seconds_to_rads
#
Returns radians corresponding to number of second in the day.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seconds_in_day
|
int
|
Seconds that have passed so far in the day. |
required |
get_replay_temperatures
#
get_replay_temperatures(
observation_responses: Sequence[ObservationResponse],
) -> Mapping[str, float]
Returns temperature replays from past observations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observation_responses
|
Sequence[ObservationResponse]
|
array of observations to extract weather from |
required |
Returns: map from timestamp to temp