visualization

Visualization functions

visualization.data_sources.plot_pv

General functions for plotting PV data

get_trace_centroid_pv

def get_trace_centroid_pv(pv: PV, example_index: int) -> go.Scatter

Produce plot of centroid pv system

get_trace_all_pv_systems

def get_trace_all_pv_systems(pv: PV,
                             example_index: int,
                             center_system: bool = True) -> List[go.Scatter]

Produce plot of centroid pv system

get_traces_pv_intensity

def get_traces_pv_intensity(pv: PV, example_index: int)

Get traces of pv intensity map

get_trace_pv_intensity_one_time_step

def get_trace_pv_intensity_one_time_step(pv: PV,
                                         example_index: int,
                                         t_index: int,
                                         center: bool = False)

Get trace of pv intensity map

make_fig_of_animation_from_frames

def make_fig_of_animation_from_frames(traces, pv, example_index)

Make animated fig form traces

get_fig_pv_combined

def get_fig_pv_combined(pv: PV, example_index: int)

Create a combined plot

  1. Plot the pv intensity in time
  2. Plot the pv intensity with coords and animate in time

visualization.data_sources.plot_nwp

Tests to plot satellite data

make_traces_nwp_one_channel_one_time

def make_traces_nwp_one_channel_one_time(nwp: NWP, example_index: int,
                                         channel_index: int, time_index: int)

Make one trace for one channel and one time

Arguments:

  • nwp - nwp data
  • example_index - which example to use
  • channel_index - which channel to ise
  • time_index - which time to use

  • Returns - plotly trace

visualization.data_sources.plot_gsp

General functions for plotting PV data

get_trace_centroid_gsp

def get_trace_centroid_gsp(gsp: GSP, example_index: int) -> go.Scatter

Produce plot of centroid GSP

get_trace_all_gsps

def get_trace_all_gsps(gsp: GSP,
                       example_index: int,
                       plot_other_gsp: bool = False) -> List[go.Scatter]

Produce plot of centroid GSP

get_traces_gsp_intensity

def get_traces_gsp_intensity(gsp: GSP, example_index: int)

Get traces of pv intenisty map

get_trace_gsp_intensity_one_time_step

def get_trace_gsp_intensity_one_time_step(gsp: GSP, example_index: int,
                                          t_index: int)

Get trace of pv intensity map

make_fig_of_animation_from_frames

def make_fig_of_animation_from_frames(traces, gsp: GSP, example_index: int)

Make animated fig form traces

get_fig_gsp_combined

def get_fig_gsp_combined(gsp: GSP, example_index: int)

Create a combined plot

  1. Plot the gsp intensity in time
  2. Plot the gsp intensity with coords and animate in time

visualization.data_sources.plot_all

Tests to plot satellite data

make_trace_time_series_pv_and_gsp

def make_trace_time_series_pv_and_gsp(batch: Batch, example_index: int)

Make traces of time series gsp and pv systems

make_fig_time_series_pv_and_gsp

def make_fig_time_series_pv_and_gsp(batch: Batch, example_index: int)

Make figure of pv and gsp time series data

get_time_index

def get_time_index(times: xr.DataArray, time_value) -> int

Get the time index from a time value

make_satellite_gsp_pv_map_one_time_value

def make_satellite_gsp_pv_map_one_time_value(batch: Batch, example_index: int,
                                             satellite_channel_index,
                                             time_value)

Make plot of satellite, gps and pv for one time step

make_satellite_gsp_pv_map_still

def make_satellite_gsp_pv_map_still(batch: Batch, example_index: int,
                                    satellite_channel_index: int)

Make a still of the satellite, gsp and the pv data

make_satellite_gsp_pv_map

def make_satellite_gsp_pv_map(batch: Batch, example_index: int,
                              satellite_channel_index: int)

Make a animation of the satellite, gsp and the pv data

visualization.data_sources.plot_satellite

Tests to plot satellite data

make_traces_one_channel_one_time

def make_traces_one_channel_one_time(satellite: Satellite, example_index: int,
                                     channel_index: int, time_index: int)

Make one trace for one channel and one time

Arguments:

  • satellite - satetlite data
  • example_index - which example to use
  • channel_index - which channel to ise
  • time_index - which time to use

  • Returns - plotly trace

make_traces_one_channel

def make_traces_one_channel(satellite: Satellite, example_index: int,
                            channel_index: int)

Make traces for one channel

make_traces_one_timestep

def make_traces_one_timestep(satellite: Satellite, example_index: int,
                             time_index: int)

Make traces for one channel

make_animation_one_channels

def make_animation_one_channels(satellite: Satellite, example_index: int,
                                channel_index: int)

Make animation of one channel

make_animation_all_channels

def make_animation_all_channels(satellite: Satellite, example_index: int)

Make animation of all channels

An animation is made over time. Subplots show the different satellite channels

Arguments:

  • satellite - satellite data
  • example_index - which example to use

  • Returns - plotly figure

visualization.utils

Plotting utils functions

make_slider

def make_slider(labels: List[str]) -> dict

Make slider for animation

make_buttons

def make_buttons() -> dict

Make buttons Play and Pause

visualization.line

Several line plots of predictions and truths.

make_trace

def make_trace(x,
               y,
               truth: bool,
               show_legend: bool = True,
               name: str = None,
               mode: str = "lines+markers",
               marker_size: Union[int, List[int]] = 10,
               color: Union[str, List[str]] = None,
               opacity: Optional[float] = None)

Make a plotly trace data (x,y).

Arguments:

  • x - time series of data
  • y - values of data
  • truth - if y is the truth or predictions. The colour of the line changed depending on this
  • show_legend - option to show the legend for this trace or not.
  • name - name of the trace
  • color - the size of the markers
  • marker_size - the size of the markers
  • mode - the mode for plotting, see ref. https://plotly.com/python/reference/scatter/#scatter-mode
  • opacity - the opacity of the lines (and markers)

Returns:plotly trace

plot_one_result

def plot_one_result(x, y, y_hat)

Plot one result.

Arguments:

  • x - time series for the forecast predictions, should be size [forecast length]
  • y - the truth values of pv yield, should be size [forecast length]
  • y_hat - the predicted values of pv yield, should be size [forecast length]

Returns:a plotly figure

plot_batch_results

def plot_batch_results(x: Union[np.array, List],
                       y: np.array,
                       y_hat: np.array,
                       model_name: str,
                       x_hat: Union[np.array, List] = None)

Plot batch results.

Arguments:

  • x - is a list of time series for the different predictions in the batch, should be size [batch_size, forecast length]
  • y - the truth values of pv yield, should be size [batch_size, forecast length]
  • y_hat - the predicted values of pv yield, should be size [batch_size, forecast length]
  • model_name - the name of the model
  • x_hat - the x values for the predictions (y_hat), note that if none is supplied then x is used instead

  • Returns - a plotly figure

visualization.visualization

Matplotlib functions to plot a example dataset and model outputs.

Author: Jack Kelly

plot_example

def plot_example(batch: BatchML,
                 model_output,
                 history_minutes: int,
                 forecast_minutes: int,
                 nwp_channels: Iterable[str],
                 example_i: int = 0,
                 epoch: Optional[int] = None,
                 output_variable: str = "pv_yield") -> plt.Figure

Plots an example with the satellite imagery, timeseries and PV yield.

Arguments:

  • batch - The batch to plot
  • model_output - The output from the model
  • history_minutes - The number of minutes of the input history
  • forecast_minutes - The number minutes of forecast
  • nwp_channels - The names of nwp channels
  • example_i - Which example to plot from the batch
  • epoch - The optional epoch number
  • output_variable - this can be 'pv_yield' or 'gsp_yield'

Returns:

Matplotlib Figure containing the plotted graphs and images