data_sources.sun

Sun Data Source i.e azimuth and elevation angles

data_sources.sun.raw_data_load_save

Sun Data Source

get_azimuth_and_elevation

def get_azimuth_and_elevation(datestamps: List[datetime.datetime], x_centers: List[int], y_centers: List[int]) -> (pd.DataFrame, pd.DataFrame)

Get Azimuth and elevation positions of the sun

For a list of datestamps and a list of coordinates, get the azimuth and elevation degrees. Note that the degrees are rounded to 2 decimal places, as we at most need that.

Arguments:

  • datestamps - list of datestamps that are needed
  • x_centers - list of x coordinates - ref. OSGB
  • y_centers - list of y coordinates - ref. OSGB

  • Returns - Tuple of dataframes for azimuth and elevation. The index is timestamps, and the columns are the x and y coordinates in OSGB projection

save_to_zarr

def save_to_zarr(azimuth: pd.DataFrame, elevation: pd.DataFrame, zarr_path: Union[str, Path])

Save azimuth and elevation to zarr file

Arguments:

  • azimuth - data to be saved
  • elevation - data to be saved
  • zarr_path - the file name where it should be save, can be local of gcs

load_from_zarr

def load_from_zarr(zarr_path: Union[str, Path], start_dt: Optional[datetime.datetime] = None, end_dt: Optional[datetime.datetime] = None) -> (pd.DataFrame, pd.DataFrame)

Load sun data

Arguments:

  • zarr_path - the zarr_path to be loaded, can be local or gcs
  • start_dt - optional start datetime. Both start and end need to be set to be used.
  • end_dt - optional end datetime. Both start and end need to be set to be used.

  • Returns - Tuple of dataframes for azimuth and elevation. The index is timestamps, and the columns are the x and y coordinates

x_y_to_name

def x_y_to_name(x, y) -> str

Make name form x, y coords

Arguments:

  • x - x coordinate
  • y - y cooridante

  • Returns - name made from x and y

data_sources.sun.sun_model

Model for Sun features

Sun Objects

class Sun(DataSourceOutput)

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

model_validation

@classmethod
def model_validation(cls, v)

Check that all values are non NaNs

data_sources.sun.sun_data_source

Loading Raw data

SunDataSource Objects

@dataclass
class SunDataSource(DataSource)

Add azimuth and elevation angles of the sun.

__post_init__

def __post_init__()

Post Init

get_data_model_for_batch

@staticmethod
def get_data_model_for_batch()

Get the model that is used in the batch

check_input_paths_exist

def check_input_paths_exist() -> None

Check input paths exist. If not, raise a FileNotFoundError.

get_example

def get_example(t0_datetime_utc: pd.Timestamp, x_center_osgb: Number, y_center_osgb: Number) -> xr.Dataset

Get example data from t0_dt and x and y xoordinates

Arguments:

  • t0_datetime_utc - the timestamp to get the sun data for
  • x_center_osgb - the x coordinate (OSGB)
  • y_center_osgb - the y coordinate (OSGB)

  • Returns - Dictionary of azimuth and elevation data

get_locations

def get_locations(t0_datetimes_utc: pd.DatetimeIndex) -> Tuple[List[Number], List[Number]]

Sun data should not be used to get batch locations

datetime_index

def datetime_index() -> pd.DatetimeIndex

Get datetimes where elevation >= 10