Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit 0711c52

Browse files
adjust sun script (#644)
* adjust sun script * update for generation script * save as float32 * only load metadata for power data * tidy * adjust * fix * v2 sun on_premises.yaml Co-authored-by: Jacob Bieker <jacob@bieker.tech>
1 parent 7d87173 commit 0711c52

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

nowcasting_dataset/config/gcp.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ input_data:
7272
sun:
7373
forecast_minutes: 60
7474
history_minutes: 30
75-
sun_zarr_path: gs://solar-pv-nowcasting-data/Sun/v0/sun.zarr
75+
sun_zarr_path: gs://solar-pv-nowcasting-data/Sun/v2/sun.zarr
7676

7777
# ------------------------- Topographic ----------------
7878
topographic:

nowcasting_dataset/config/on_premises.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ input_data:
7171

7272
# ------------------------- Sun ------------------------
7373
sun:
74-
sun_zarr_path: /mnt/storage_b/data/ocf/solar_pv_nowcasting/nowcasting_dataset_pipeline/Sun/v1/sun.zarr
74+
sun_zarr_path: /mnt/storage_b/data/ocf/solar_pv_nowcasting/nowcasting_dataset_pipeline/Sun/v2/sun.zarr
7575

7676
# ------------------------- Topographic ----------------
7777
topographic:

scripts/generate_raw_data/get_raw_sun_data.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import nowcasting_dataset
2626
from nowcasting_dataset.config import load_yaml_configuration
2727
from nowcasting_dataset.data_sources.gsp.eso import get_gsp_metadata_from_eso
28+
from nowcasting_dataset.data_sources.pv.pv_data_source import PVDataSource
2829
from nowcasting_dataset.data_sources.sun.raw_data_load_save import (
2930
get_azimuth_and_elevation,
3031
save_to_zarr,
@@ -40,24 +41,27 @@
4041

4142

4243
# set up
43-
PV_METADATA_FILENAME = config.input_data.pv.pv_metadata_filenames
4444
sun_file_zarr = config.input_data.sun.sun_zarr_path
4545

4646
# set up variables
4747
local_path = os.path.dirname(nowcasting_dataset.__file__) + "/.."
48-
metadata_filename = f"gs://{PV_METADATA_FILENAME}"
4948
start_dt = datetime.fromisoformat("2019-01-01 00:00:00.000+00:00")
5049
end_dt = datetime.fromisoformat("2020-01-01 00:00:00.000+00:00")
5150
datestamps = pd.date_range(start=start_dt, end=end_dt, freq="5T")
5251

5352
# PV metadata
54-
pv_metadata = pd.read_csv(metadata_filename, index_col="system_id")
55-
pv_metadata = pv_metadata.dropna(subset=["longitude", "latitude"])
56-
pv_metadata["location_x"], pv_metadata["location_y"] = lat_lon_to_osgb(
57-
pv_metadata["latitude"], pv_metadata["longitude"]
53+
54+
pv = PVDataSource(
55+
history_minutes=30,
56+
forecast_minutes=60,
57+
files_groups=config.input_data.pv.pv_files_groups,
58+
start_datetime=datetime(2010, 1, 1),
59+
end_datetime=datetime(2030, 1, 2),
60+
image_size_pixels=128,
61+
meters_per_pixel=2000,
5862
)
59-
pv_x = pv_metadata["location_x"]
60-
pv_y = pv_metadata["location_y"]
63+
64+
pv_x, pv_y = lat_lon_to_osgb(pv.pv_metadata["latitude"], pv.pv_metadata["longitude"])
6165

6266
# GSP Metadata
6367
gsp_metadata = get_gsp_metadata_from_eso()
@@ -66,16 +70,16 @@
6670
gsp_y = gsp_metadata["centroid_y"]
6771

6872
# join all sites together
69-
x_centers = list(pv_x.values) + list(gsp_x.values)
70-
y_centers = list(pv_y.values) + list(gsp_y.values)
73+
x_centers = list(pv_x) + list(gsp_x.values)
74+
y_centers = list(pv_y) + list(gsp_y.values)
7175

7276
# make d
7377
azimuth, elevation = get_azimuth_and_elevation(
7478
x_centers=x_centers, y_centers=y_centers, datestamps=datestamps
7579
)
7680

77-
azimuth = azimuth.astype(int)
78-
elevation = elevation.astype(int)
81+
azimuth = azimuth.astype("float32")
82+
elevation = elevation.astype("float32")
7983

8084
# save it locally and in the cloud, just in case when saving in the cloud it fails
8185
save_to_zarr(azimuth=azimuth, elevation=elevation, zarr_path="./sun.zarr")

0 commit comments

Comments
 (0)