metobs_toolkit.analysis.Analysis.get_diurnal_statistics_with_reference#

Analysis.get_diurnal_statistics_with_reference(refstation, colorby='name', obstype='temp', tolerance='30min', stations=None, startdt=None, enddt=None, plot=True, title=None, y_label=None, legend=True, errorbands=False, show_zero_horizontal=True, _return_all_stats=False)[source]#

Create an average diurnal cycle for the observation differences of a reference station.

All observational values are converted to differences with the closest (in time) reference observation. No reference observation is found when the time difference is larger than the tolerance.

(In the plot, each station is represed by a line.)

Parameters:
  • refstation (str,) – Name of the station to use as a reference.

  • colorby ('name' or 'lcz', optional) – If ‘name’ the plotted lines will be colored per station, if ‘lcz’ the colors represent the stations lcz. The default is ‘name’.

  • obstype (str, optional) – Element of the metobs_toolkit.observation_types The default is ‘temp’.

  • tolerance (Timedelta or str, optional) – The tolerance string or object representing the maximum translation in time to find a reference observation for each observation. Ex: ‘5min’ is 5 minutes, ‘1h’, is one hour. The default is ‘30min’.

  • stations (list, optional) – List of station names to use. If None, all present stations will be used. The default is None.

  • startdt (datetime.datetime, optional) – The start datetime of the observations to use. If None, all timestamps will be used. The default is None.

  • enddt (datetime.datetime, optional) – The end datetime of the observations to use. If None, all timestamps will be used. The default is None.

  • plot (bool, optional) – If True, a diurnal plot is made. The default is True.

  • title (string, optional) – Title of the figure, if None a default title is generated. The default is None.

  • y_label (string, optional) – y-axes label of the figure, if None a default label is generated. The default is None.

  • legend (bool, optional) – I True, a legend is added to the plot. The default is True.

  • errorbands (bool, optional) – If True, the std is representd in the plot by colored bands. The upper bound represents +1 x std, the lower bound -1 x std. The default is False.

  • show_zero_horizontal (bool, optional) – If True a horizontal line is drawn in the plot at zero. The default is True.

Returns:

df – The dataframe containing the aggregated values.

Return type:

pandas.DataFrame()

Note

If a timezone unaware datetime is given as an argument, it is interpreted as if it has the same timezone as the observations.