weather
frequenz.client.weather ¤
The Weather Forecast API client.
Classes¤
frequenz.client.weather.Client ¤
Bases: BaseApiClient[WeatherForecastServiceStub]
Weather forecast client.
Source code in frequenz/client/weather/_client.py
Attributes¤
channel
property
¤
channel: Channel
The underlying gRPC channel used to communicate with the server.
Warning
This channel is provided as a last resort for advanced users. It is not recommended to use this property directly unless you know what you are doing and you don't care about being tied to a specific gRPC library.
RAISES | DESCRIPTION |
---|---|
ClientNotConnected
|
If the client is not connected to the server. |
channel_defaults
property
¤
The default options for the gRPC channel.
Functions¤
__aexit__
async
¤
__aexit__(
_exc_type: type[BaseException] | None,
_exc_val: BaseException | None,
_exc_tb: Any | None,
) -> bool | None
Exit a context manager.
Source code in frequenz/client/base/client.py
__init__ ¤
__init__(
server_url: str,
*,
connect: bool = True,
channel_defaults: ChannelOptions = ChannelOptions()
) -> None
Initialize the client.
PARAMETER | DESCRIPTION |
---|---|
server_url |
The URL of the server to connect to.
TYPE:
|
connect |
Whether to connect to the server as soon as a client instance is
created. If
TYPE:
|
channel_defaults |
Default options for the gRPC channel.
TYPE:
|
Source code in frequenz/client/weather/_client.py
connect ¤
connect(server_url: str | None = None) -> None
Connect to the server, possibly using a new URL.
If the client is already connected and the URL is the same as the previous URL, this method does nothing. If you want to force a reconnection, you can call disconnect() first.
PARAMETER | DESCRIPTION |
---|---|
server_url |
The URL of the server to connect to. If not provided, the previously used URL is used.
TYPE:
|
Source code in frequenz/client/base/client.py
disconnect
async
¤
Disconnect from the server.
If the client is not connected, this method does nothing.
hist_forecast_iterator ¤
hist_forecast_iterator(
locations: list[Location],
features: list[ForecastFeature],
start: datetime,
end: datetime,
) -> HistoricalForecastIterator
Stream historical weather forecast data.
PARAMETER | DESCRIPTION |
---|---|
locations |
locations to stream data for. |
features |
features to stream data for.
TYPE:
|
start |
start of the time range to stream data for.
TYPE:
|
end |
end of the time range to stream data for.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
HistoricalForecastIterator
|
A channel receiver for weather forecast data. |
Source code in frequenz/client/weather/_client.py
stream_live_forecast
async
¤
stream_live_forecast(
locations: list[Location],
features: list[ForecastFeature],
) -> Receiver[Forecasts]
Stream live weather forecast data.
PARAMETER | DESCRIPTION |
---|---|
locations |
locations to stream data for. |
features |
features to stream data for.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Receiver[Forecasts]
|
A channel receiver for weather forecast data. |
Source code in frequenz/client/weather/_client.py
frequenz.client.weather.ForecastFeature ¤
Bases: Enum
Weather forecast features available through the API.
Source code in frequenz/client/weather/_types.py
Attributes¤
SURFACE_NET_SOLAR_RADIATION
class-attribute
instance-attribute
¤
Surface net solar radiation.
SURFACE_SOLAR_RADIATION_DOWNWARDS
class-attribute
instance-attribute
¤
Surface solar radiation downwards.
TEMPERATURE_2_METRE
class-attribute
instance-attribute
¤
Temperature at 2m above the earth's surface.
UNSPECIFIED
class-attribute
instance-attribute
¤
Unspecified forecast feature.
U_WIND_COMPONENT_100_METRE
class-attribute
instance-attribute
¤
Eastward wind component at 100m altitude.
U_WIND_COMPONENT_10_METRE
class-attribute
instance-attribute
¤
Eastward wind component at 10m altitude.
V_WIND_COMPONENT_100_METRE
class-attribute
instance-attribute
¤
Northward wind component at 100m altitude.
V_WIND_COMPONENT_10_METRE
class-attribute
instance-attribute
¤
Northward wind component at 10m altitude.
Functions¤
from_pb
classmethod
¤
from_pb(forecast_feature: ValueType) -> ForecastFeature
Convert a protobuf ForecastFeature value to ForecastFeature enum.
PARAMETER | DESCRIPTION |
---|---|
forecast_feature |
protobuf forecast feature to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ForecastFeature
|
Enum value corresponding to the protobuf message. |
Source code in frequenz/client/weather/_types.py
frequenz.client.weather.Forecasts
dataclass
¤
Weather forecast data.
Source code in frequenz/client/weather/_types.py
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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
|
Functions¤
from_pb
classmethod
¤
from_pb(
forecasts: ReceiveLiveWeatherForecastResponse,
) -> Forecasts
Convert a protobuf Forecast message to Forecast object.
PARAMETER | DESCRIPTION |
---|---|
forecasts |
protobuf message with live forecast data. |
RETURNS | DESCRIPTION |
---|---|
Forecasts
|
Forecast object corresponding to the protobuf message. |
Source code in frequenz/client/weather/_types.py
to_ndarray_vlf ¤
to_ndarray_vlf(
validity_times: list[datetime] | None = None,
locations: list[Location] | None = None,
features: list[ForecastFeature] | None = None,
) -> ndarray[tuple[Any, Any, Any], dtype[float64]]
Convert a Forecast object to numpy array and use NaN to mark irrelevant data.
If any of the filters are None, all values for that parameter will be returned.
PARAMETER | DESCRIPTION |
---|---|
validity_times |
The validity times to filter by. |
locations |
The locations to filter by. |
features |
The features to filter by.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ndarray[tuple[Any, Any, Any], dtype[float64]]
|
Numpy array of shape (num_validity_times, num_locations, num_features) |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the forecasts data is missing or invalid. |
Source code in frequenz/client/weather/_types.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
|
frequenz.client.weather.Location
dataclass
¤
Location data.
ATTRIBUTE | DESCRIPTION |
---|---|
latitude |
latitude of the location.
TYPE:
|
longitude |
longitude of the location.
TYPE:
|
country_code |
ISO 3166-1 alpha-2 country code of the location.
TYPE:
|
Source code in frequenz/client/weather/_types.py
Functions¤
from_pb
classmethod
¤
from_pb(location: Location) -> Location
Convert a protobuf Location message to Location object.
PARAMETER | DESCRIPTION |
---|---|
location |
protobuf location to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Location
|
Location object corresponding to the protobuf message. |
Source code in frequenz/client/weather/_types.py
to_pb ¤
Convert a Location object to protobuf Location message.
RETURNS | DESCRIPTION |
---|---|
Location
|
Protobuf message corresponding to the Location object. |