Skip to content

Commit

Permalink
Add solar +date/times to site numpy (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sukh-P authored Jan 23, 2025
1 parent 2b7db44 commit c9ecedc
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions ocf_data_sampler/numpy_sample/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ class SiteSampleKey:
capacity_kwp = "site_capacity_kwp"
time_utc = "site_time_utc"
t0_idx = "site_t0_idx"
id = "site_id"
solar_azimuth = "site_solar_azimuth"
solar_elevation = "site_solar_elevation"
id = "site_id"
date_sin = "site_date_sin"
date_cos = "site_date_cos"
time_sin = "site_time_sin"
time_cos = "site_time_cos"

# TODO update to include trig datetime + solar coords
def convert_site_to_numpy_sample(da: xr.DataArray, t0_idx: int | None = None) -> dict:
"""Convert from Xarray to NumpySample"""

Expand All @@ -23,6 +26,12 @@ def convert_site_to_numpy_sample(da: xr.DataArray, t0_idx: int | None = None) ->
SiteSampleKey.capacity_kwp: da.isel(time_utc=0)["capacity_kwp"].values,
SiteSampleKey.time_utc: da["time_utc"].values.astype(float),
SiteSampleKey.id: da["site_id"].values,
SiteSampleKey.solar_azimuth: da["solar_azimuth"].values,
SiteSampleKey.solar_elevation: da["solar_elevation"].values,
SiteSampleKey.date_sin: da["date_sin"].values,
SiteSampleKey.date_cos: da["date_cos"].values,
SiteSampleKey.time_sin: da["time_sin"].values,
SiteSampleKey.time_cos: da["time_cos"].values,
}

if t0_idx is not None:
Expand Down

0 comments on commit c9ecedc

Please sign in to comment.