data_sources.satellite

Satellite data sources and functions

data_sources.satellite.satellite_model

Model for output of satellite data

Satellite Objects

class Satellite(DataSourceOutput)

Class to store satellite data as a xr.Dataset with some validation

model_validation

@classmethod
def model_validation(cls, v)

Check that all values are non negative

HRVSatellite Objects

class HRVSatellite(Satellite)

Class to store HRV satellite data as a xr.Dataset with some validation

data_sources.satellite.satellite_data_source

Satellite Data Source

SatelliteDataSource Objects

@dataclass
class SatelliteDataSource(ZarrDataSource)

Satellite Data Source.

__post_init__

def __post_init__(image_size_pixels: int, meters_per_pixel: int)

Post Init

open

def open() -> None

Open Satellite data

We don't want to open_sat_data in init. If we did that, then we couldn't copy SatelliteDataSource instances into separate processes. Instead, call open() after creating separate processes.

get_data_model_for_batch

@staticmethod
def get_data_model_for_batch()

Get the model that is used in the batch

get_spatial_region_of_interest

def get_spatial_region_of_interest(data_array: xr.DataArray, x_center_osgb: Number, y_center_osgb: Number) -> xr.DataArray

Gets the satellite image as a square around the center

Ignores x and y coordinates as for the original satellite projection each pixel varies in both its x and y distance from other pixels. See Issue 401 for more details.

This results, in 'real' spatial terms, each image covering about 2x as much distance in the x direction as in the y direction.

Arguments:

  • data_array - DataArray to subselect from
  • x_center_osgb - Center of the image x coordinate in OSGB coordinates
  • y_center_osgb - Center of image y coordinate in OSGB coordinates

Returns:

The selected data around the center

get_example

def get_example(t0_dt: pd.Timestamp, x_meters_center: Number, y_meters_center: Number) -> xr.Dataset

Get Example data

Arguments:

  • t0_dt - list of timestamps for the datetime of the batches. The batch will also include data for historic and future depending on history_minutes and future_minutes.
  • x_meters_center - x center batch locations
  • y_meters_center - y center batch locations

  • Returns - Example Data

datetime_index

def datetime_index(remove_night: bool = True) -> pd.DatetimeIndex

Returns a complete list of all available datetimes

Arguments:

  • remove_night - If True then remove datetimes at night. We're interested in forecasting solar power generation, so we don't care about nighttime data :)

In the UK in summer, the sun rises first in the north east, and sets last in the north west [1]. In summer, the north gets more hours of sunshine per day.

In the UK in winter, the sun rises first in the south east, and sets last in the south west [2]. In winter, the south gets more hours of sunshine per day.

Summer Winter
Sun rises first in N.E. S.E.
Sun sets last in N.W. S.W.
Most hours of sunlight North South

Before training, we select timesteps which have at least some sunlight. We do this by computing the clearsky global horizontal irradiance (GHI) for the four corners of the satellite imagery, and for all the timesteps in the dataset. We only use timesteps where the maximum global horizontal irradiance across all four corners is above some threshold.

The 'clearsky solar irradiance' is the amount of sunlight we'd expect on a clear day at a specific time and location. The SI unit of irradiance is watt per square meter. The 'global horizontal irradiance' (GHI) is the total sunlight that would hit a horizontal surface on the surface of the Earth. The GHI is the sum of the direct irradiance (sunlight which takes a direct path from the Sun to the Earth's surface) and the diffuse horizontal irradiance (the sunlight scattered from the atmosphere). For more info, see: https://en.wikipedia.org/wiki/Solar_irradiance

References:

  1. Video of June 2019
  2. Video of Jan 2019

HRVSatelliteDataSource Objects

class HRVSatelliteDataSource(SatelliteDataSource)

Satellite Data Source for HRV data.

remove_acq_time_from_dataset_and_fix_time_coords

def remove_acq_time_from_dataset_and_fix_time_coords(dataset: xr.Dataset) -> xr.Dataset

Preprocess datasets by dropping acq_time, which causes problems otherwise

Arguments:

  • dataset - xr.Dataset to preprocess

Returns:

dataset with acq_time dropped

open_sat_data

def open_sat_data(zarr_path: str, consolidated: bool) -> xr.DataArray

Lazily opens the Zarr store.

Adds 1 minute to the 'time' coordinates, so the timestamps are at 00, 05, ..., 55 past the hour.

Arguments:

  • zarr_path - Cloud URL or local path pattern. If GCP URL, must start with 'gs://'
  • consolidated - Whether or not the Zarr metadata is consolidated.