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

Commit 662ac2d

Browse files
Merge pull request #246 from openclimatefix/issue/239-more-gsp
Issue/239 more gsp
2 parents 91813dc + d4037ee commit 662ac2d

File tree

12 files changed

+22
-16
lines changed

12 files changed

+22
-16
lines changed

nowcasting_dataset/data_sources/gsp/gsp_data_source.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,13 +403,13 @@ def load_solar_gsp_data(
403403
gsp_power = gsp_power.sel(datetime_gmt=slice(start_dt, end_dt))
404404

405405
# only take generation data
406-
gsp_power = gsp_power.generation_mw
406+
gsp_power = gsp_power.generation_normalised
407407

408408
# make dataframe with index datetime_gmt and columns og gsp_id
409409
gsp_power_df = gsp_power.to_dataframe()
410410
gsp_power_df.reset_index(inplace=True)
411411
gsp_power_df = gsp_power_df.pivot(
412-
index="datetime_gmt", columns="gsp_id", values="generation_mw"
412+
index="datetime_gmt", columns="gsp_id", values="generation_normalised"
413413
)
414414

415415
# Save memory

scripts/generate_data_for_tests/get_test_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
nwp_data.to_zarr(f"{local_path}/tests/data/nwp_data/test.zarr")
8383

8484
# ### GSP data
85-
filename = "gs://solar-pv-nowcasting-data/PV/GSP/v1/pv_gsp.zarr"
85+
filename = "gs://solar-pv-nowcasting-data/PV/GSP/v2/pv_gsp.zarr"
8686

8787
gsp_power = xr.open_dataset(filename, engine="zarr")
8888
gsp_power = gsp_power.sel(datetime_gmt=slice(start_dt, end_dt))

scripts/get_raw_pv_gsp_data.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
logging.getLogger().setLevel(logging.DEBUG)
2626
logging.getLogger("urllib3").setLevel(logging.WARNING)
2727

28-
start = datetime(2018, 1, 1, tzinfo=pytz.utc)
29-
end = datetime(2021, 1, 1, tzinfo=pytz.utc)
30-
gcp_path = "gs://solar-pv-nowcasting-data/PV/GSP/v1"
28+
start = datetime(2016, 1, 1, tzinfo=pytz.utc)
29+
end = datetime(2021, 10, 1, tzinfo=pytz.utc)
30+
gcp_path = "gs://solar-pv-nowcasting-data/PV/GSP/v2"
3131

3232
config = {"start": start, "end": end, "gcp_path": gcp_path}
3333

@@ -40,20 +40,19 @@
4040

4141
# pivot to index as datetime_gmt, and columns as gsp_id
4242
data_generation = data_df.pivot(index="datetime_gmt", columns="gsp_id", values="generation_mw")
43-
data_generation.columns = [str(col) for col in data_generation.columns]
4443
data_generation_xarray = xr.DataArray(
4544
data_generation, name="generation_mw", dims=["datetime_gmt", "gsp_id"]
4645
)
4746

4847
data_capacity = data_df.pivot(
4948
index="datetime_gmt", columns="gsp_id", values="installedcapacity_mwp"
5049
)
51-
data_capacity.columns = [str(col) for col in data_capacity.columns]
5250
data_capacity_xarray = xr.DataArray(
5351
data_capacity, name="installedcapacity_mwp", dims=["datetime_gmt", "gsp_id"]
5452
)
5553

5654
data_xarray = xr.merge([data_generation_xarray, data_capacity_xarray])
55+
data_xarray = data_xarray.rename({"generation_mw": "generation_normalised"})
5756

5857
# save config to file
5958
with open(os.path.join(LOCAL_TEMP_PATH, "configuration.yaml"), "w+") as f:
@@ -69,3 +68,10 @@
6968

7069
# upload to gcp
7170
upload_and_delete_local_files(dst_path=gcp_path, local_path=LOCAL_TEMP_PATH)
71+
72+
73+
# # code to change 'generation_mw' to 'generation_normalised'
74+
# data_xarray = xr.open_dataset(gcp_path + '/pv_gsp.zarr', engine="zarr")
75+
# data_xarray.__setitem__('gsp_id', [int(gsp_id) for gsp_id in data_xarray.gsp_id])
76+
# data_xarray = data_xarray.rename({"generation_mw": "generation_normalised"})
77+
# data_xarray.to_zarr(gcp_path + '/pv_gsp.zarr', mode="w", encoding=encoding)

tests/data/gsp/test.zarr/.zmetadata

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"datetime_gmt/.zarray": {
88
"chunks": [
9-
49
9+
26305
1010
],
1111
"compressor": {
1212
"blocksize": 0,
@@ -29,9 +29,9 @@
2929
"datetime_gmt"
3030
],
3131
"calendar": "proleptic_gregorian",
32-
"units": "minutes since 2019-01-01"
32+
"units": "minutes since 2018-01-01"
3333
},
34-
"generation_mw/.zarray": {
34+
"generation_normalised/.zarray": {
3535
"chunks": [
3636
49,
3737
21
@@ -53,7 +53,7 @@
5353
],
5454
"zarr_format": 2
5555
},
56-
"generation_mw/.zattrs": {
56+
"generation_normalised/.zattrs": {
5757
"_ARRAY_DIMENSIONS": [
5858
"datetime_gmt",
5959
"gsp_id"
@@ -70,7 +70,7 @@
7070
"id": "blosc",
7171
"shuffle": 1
7272
},
73-
"dtype": "<U2",
73+
"dtype": "<U21",
7474
"fill_value": null,
7575
"filters": null,
7676
"order": "C",

tests/data/gsp/test.zarr/datetime_gmt/.zarray

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"chunks": [
3-
49
3+
26305
44
],
55
"compressor": {
66
"blocksize": 0,

tests/data/gsp/test.zarr/datetime_gmt/.zattrs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"datetime_gmt"
44
],
55
"calendar": "proleptic_gregorian",
6-
"units": "minutes since 2019-01-01"
6+
"units": "minutes since 2018-01-01"
77
}
906 Bytes
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)