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

Commit 7bcdbd3

Browse files
Merge pull request #338 from openclimatefix/issue/135-remove-nwp-temporary
dont interpolate nwp data
2 parents d7b3537 + 76d7967 commit 7bcdbd3

File tree

6 files changed

+22
-13
lines changed

6 files changed

+22
-13
lines changed

nowcasting_dataset/config/gcp.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ input_data:
77
gsp:
88
forecast_minutes: 60
99
gsp_zarr_path: gs://solar-pv-nowcasting-data/PV/GSP/v2/pv_gsp.zarr
10-
history_minutes: 30
10+
history_minutes: 60
1111
nwp:
1212
forecast_minutes: 60
1313
history_minutes: 30

nowcasting_dataset/config/on_premises.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ input_data:
2323
- hcc
2424
nwp_image_size_pixels: 64
2525
nwp_zarr_path: /mnt/storage_b/data/ocf/solar_pv_nowcasting/nowcasting_dataset_pipeline/NWP/UK_Met_Office/UKV/zarr/UKV__2018-01_to_2019-12__chunks__variable10__init_time1__step1__x548__y704__.zarr
26+
history_minutes: 60
2627

2728
#---------------------- PV -------------------
2829
pv:

nowcasting_dataset/data_sources/data_source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __post_init__(self):
5757
assert self.forecast_length >= 0
5858
assert self.history_minutes % self.sample_period_minutes == 0, (
5959
f"sample period ({self.sample_period_minutes}) minutes "
60-
f"does not fit into historic minutes ({self.forecast_minutes})"
60+
f"does not fit into historic minutes ({self.history_minutes})"
6161
)
6262
assert self.forecast_minutes % self.sample_period_minutes == 0, (
6363
f"sample period ({self.sample_period_minutes}) minutes "

nowcasting_dataset/data_sources/nwp/nwp_data_source.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ def _post_process_example(
114114
"""Resamples to 5 minutely."""
115115
start_dt = self._get_start_dt(t0_dt)
116116
end_dt = self._get_end_dt(t0_dt)
117-
selected_data = selected_data.resample({"target_time": "5T"})
118-
selected_data = selected_data.interpolate()
117+
119118
selected_data = selected_data.sel(target_time=slice(start_dt, end_dt))
120119
selected_data = selected_data.rename({"target_time": "time", "variable": "channels"})
121120
selected_data.data = selected_data.data.astype(np.float16)
@@ -133,8 +132,12 @@ def datetime_index(self) -> pd.DatetimeIndex:
133132
target_times = np.unique(target_times)
134133
target_times = np.sort(target_times)
135134
target_times = pd.DatetimeIndex(target_times)
136-
resampler = pd.Series(0, index=target_times).resample("5T")
137-
return resampler.ffill(limit=11).dropna().index
135+
return target_times
136+
137+
@property
138+
def sample_period_minutes(self) -> int:
139+
"""Override the default sample minutes"""
140+
return 60
138141

139142

140143
def open_nwp(zarr_path: str, consolidated: bool) -> xr.Dataset:

tests/config/test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ input_data:
1010
- t
1111
nwp_image_size_pixels: 2
1212
nwp_zarr_path: tests/data/nwp_data/test.zarr
13+
history_minutes: 60
1314
pv:
1415
pv_filename: tests/data/pv_data/test.nc
1516
pv_metadata_filename: tests/data/pv_metadata/UK_PV_metadata.csv

tests/data_sources/test_nwp_data_source.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
def test_nwp_data_source_init(): # noqa: D103
1616
_ = NWPDataSource(
1717
zarr_path=NWP_ZARR_PATH,
18-
history_minutes=30,
18+
history_minutes=60,
1919
forecast_minutes=60,
2020
)
2121

2222

2323
def test_nwp_data_source_open(): # noqa: D103
2424
nwp = NWPDataSource(
2525
zarr_path=NWP_ZARR_PATH,
26-
history_minutes=30,
26+
history_minutes=60,
2727
forecast_minutes=60,
2828
channels=["t"],
2929
)
@@ -34,7 +34,7 @@ def test_nwp_data_source_open(): # noqa: D103
3434
def test_nwp_data_source_batch(): # noqa: D103
3535
nwp = NWPDataSource(
3636
zarr_path=NWP_ZARR_PATH,
37-
history_minutes=30,
37+
history_minutes=60,
3838
forecast_minutes=60,
3939
channels=["t"],
4040
)
@@ -47,13 +47,17 @@ def test_nwp_data_source_batch(): # noqa: D103
4747

4848
batch = nwp.get_batch(t0_datetimes=t0_datetimes, x_locations=x, y_locations=y)
4949

50-
assert batch.data.shape == (4, 1, 19, 2, 2)
50+
# batch size 4
51+
# channel 1
52+
# time series, 1 int he past, 1 now, 1 in the future
53+
# x,y of size 2
54+
assert batch.data.shape == (4, 1, 3, 2, 2)
5155

5256

5357
def test_nwp_get_contiguous_time_periods(): # noqa: D103
5458
nwp = NWPDataSource(
5559
zarr_path=NWP_ZARR_PATH,
56-
history_minutes=30,
60+
history_minutes=60,
5761
forecast_minutes=60,
5862
channels=["t"],
5963
)
@@ -68,13 +72,13 @@ def test_nwp_get_contiguous_time_periods(): # noqa: D103
6872
def test_nwp_get_contiguous_t0_time_periods(): # noqa: D103
6973
nwp = NWPDataSource(
7074
zarr_path=NWP_ZARR_PATH,
71-
history_minutes=30,
75+
history_minutes=60,
7276
forecast_minutes=60,
7377
channels=["t"],
7478
)
7579

7680
contiguous_time_periods = nwp.get_contiguous_t0_time_periods()
7781
correct_time_periods = pd.DataFrame(
78-
[{"start_dt": pd.Timestamp("2019-01-01 00:30"), "end_dt": pd.Timestamp("2019-01-02 01:00")}]
82+
[{"start_dt": pd.Timestamp("2019-01-01 01:00"), "end_dt": pd.Timestamp("2019-01-02 01:00")}]
7983
)
8084
pd.testing.assert_frame_equal(contiguous_time_periods, correct_time_periods)

0 commit comments

Comments
 (0)