lair.synoptic.hourly_mean#
- lair.synoptic.hourly_mean(df, speed='wind_speed_set_1', direction='wind_direction_set_1')[source]#
Hourly means of a
timeseries()frame, with wind averaged as a vector.Numeric columns are averaged over each clock hour (labeled by its start). Where
speedanddirectionexist,Uwind/Vwindare computed per observation and averaged, anddirectionis replaced by the direction of the mean vector (NaN for a dead-calm hour);speedstays the scalar mean.n_obscounts the wind observations in the hour. Hours with no data are dropped. Works per station when astidcolumn is present.- Parameters:
df (pd.DataFrame) – Observations as
timeseries()returns them, with aTimecolumn.speed (str, optional) – Column of wind speed. Default
"wind_speed_set_1".direction (str, optional) – Column of wind direction (degrees, blowing from). Default
"wind_direction_set_1".
- Returns:
pd.DataFrame –
stid(if given),Timeand the averaged columns.- Return type:
See also
timeseriesReturns the frame it takes.
lair.air.wind_componentsSplits a wind into u and v.
lair.air.wind_directionTurns u and v back into a direction.
Examples
Two observations in one hour, from 350 and 10 degrees, average to a wind from the north (0 degrees), where a mean of the two directions gives 180:
>>> import pandas as pd >>> from lair.synoptic import hourly_mean >>> obs = pd.DataFrame( ... { ... "Time": pd.to_datetime( ... ["2024-01-15 12:00", "2024-01-15 12:30"], utc=True ... ), ... "wind_speed_set_1": [4.0, 4.0], ... "wind_direction_set_1": [350.0, 10.0], ... } ... ) >>> hourly = hourly_mean(obs) >>> hourly[["wind_speed_set_1", "wind_direction_set_1", "n_obs"]].round(1) wind_speed_set_1 wind_direction_set_1 n_obs 0 4.0 0.0 2