solarpy.plotting.plot_time_drift_correlation#
- solarpy.plotting.plot_time_drift_correlation(times, ghi, ghi_clear, is_clearsky, window='5D', min_periods=240, plot_colorbar=True, colorbar_label='Correlation [-]', cmap='viridis_r', ax=None)#
Plot time-drift correlation between measured and clear-sky GHI.
For each time lag between −30 and +30 minutes, the Pearson correlation between measured GHI and the time-shifted clear-sky GHI is computed using a rolling window over clear-sky periods only. The result is resampled to daily means and displayed as a heatmap with date on the x-axis and lag on the y-axis. A trend in the correlation peak at a non-zero lag indicates a systematic timing offset in the measured data.
- Parameters:
times (array-like of datetime-like) – Timestamps corresponding to each observation.
ghi (array-like of float) – Measured global horizontal irradiance [W/m²].
ghi_clear (array-like of float) – Modelled clear-sky global horizontal irradiance [W/m²].
is_clearsky (array-like of bool) – Boolean mask that is
Truefor clear-sky periods. Only flagged periods are used to calculate correlation.window (str, optional) – Rolling window size passed to
pandas.Series.rolling(). Default is'5D'(five days).min_periods (int, optional) – Minimum number of observations required within the rolling window, passed to
pandas.Series.rolling(). Windows with fewer observations produceNaN. Default is240(4 hours of 1-min data).plot_colorbar (bool, optional) – Whether to add an inset colorbar. Default is
True.colorbar_label (str, optional) – Label displayed alongside the colorbar. Default is
"Correlation (-)".cmap (str, optional) – Matplotlib colormap name used for the correlation heatmap. Default is
'viridis_r'.ax (matplotlib.axes.Axes, optional) – Axes to draw on. If
None, a new figure and axes are created.
- Returns:
fig (matplotlib.figure.Figure) – The figure containing the plot.
ax (matplotlib.axes.Axes) – The axes containing the plot.
- Return type:
tuple[plt.Figure, plt.Axes]
Examples
>>> import pvlib >>> import solarpy >>> data, meta = solarpy.iotools.read_t16("data/LYN_2023.csv", map_variables=True) >>> location = pvlib.location.Location(meta["latitude"], meta["longitude"]) >>> cs = location.get_clearsky(data.index) >>> is_clearsky = pvlib.clearsky.detect_clearsky(data["ghi"], cs["ghi"], data.index) >>> fig, ax = solarpy.plotting.plot_time_drift_correlation( ... times=data.index, ... ghi=data["ghi"], ... ghi_clear=cs["ghi"], ... is_clearsky=is_clearsky, ... )