|
25 | 25 | import nowcasting_dataset |
26 | 26 | from nowcasting_dataset.config import load_yaml_configuration |
27 | 27 | 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 |
28 | 29 | from nowcasting_dataset.data_sources.sun.raw_data_load_save import ( |
29 | 30 | get_azimuth_and_elevation, |
30 | 31 | save_to_zarr, |
|
40 | 41 |
|
41 | 42 |
|
42 | 43 | # set up |
43 | | -PV_METADATA_FILENAME = config.input_data.pv.pv_metadata_filenames |
44 | 44 | sun_file_zarr = config.input_data.sun.sun_zarr_path |
45 | 45 |
|
46 | 46 | # set up variables |
47 | 47 | local_path = os.path.dirname(nowcasting_dataset.__file__) + "/.." |
48 | | -metadata_filename = f"gs://{PV_METADATA_FILENAME}" |
49 | 48 | start_dt = datetime.fromisoformat("2019-01-01 00:00:00.000+00:00") |
50 | 49 | end_dt = datetime.fromisoformat("2020-01-01 00:00:00.000+00:00") |
51 | 50 | datestamps = pd.date_range(start=start_dt, end=end_dt, freq="5T") |
52 | 51 |
|
53 | 52 | # 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, |
58 | 62 | ) |
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"]) |
61 | 65 |
|
62 | 66 | # GSP Metadata |
63 | 67 | gsp_metadata = get_gsp_metadata_from_eso() |
|
66 | 70 | gsp_y = gsp_metadata["centroid_y"] |
67 | 71 |
|
68 | 72 | # 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) |
71 | 75 |
|
72 | 76 | # make d |
73 | 77 | azimuth, elevation = get_azimuth_and_elevation( |
74 | 78 | x_centers=x_centers, y_centers=y_centers, datestamps=datestamps |
75 | 79 | ) |
76 | 80 |
|
77 | | -azimuth = azimuth.astype(int) |
78 | | -elevation = elevation.astype(int) |
| 81 | +azimuth = azimuth.astype("float32") |
| 82 | +elevation = elevation.astype("float32") |
79 | 83 |
|
80 | 84 | # save it locally and in the cloud, just in case when saving in the cloud it fails |
81 | 85 | save_to_zarr(azimuth=azimuth, elevation=elevation, zarr_path="./sun.zarr") |
|
0 commit comments