ocf-data-sampler 0.0.25__py3-none-any.whl → 0.0.27__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ocf-data-sampler might be problematic. Click here for more details.

@@ -55,31 +55,19 @@ def test_select_time_slice(da_sat_like, t0_str):
55
55
 
56
56
  # Slice parameters
57
57
  t0 = pd.Timestamp(f"2024-01-02 {t0_str}")
58
- forecast_duration = pd.Timedelta("0min")
59
- history_duration = pd.Timedelta("60min")
58
+ interval_start = pd.Timedelta(-0, "min")
59
+ interval_end = pd.Timedelta(60, "min")
60
60
  freq = pd.Timedelta("5min")
61
61
 
62
62
  # Expect to return these timestamps from the selection
63
- expected_datetimes = pd.date_range(t0 - history_duration, t0 + forecast_duration, freq=freq)
63
+ expected_datetimes = pd.date_range(t0 +interval_start, t0 + interval_end, freq=freq)
64
64
 
65
- # Make the selection using the `[x]_duration` parameters
65
+ # Make the selection
66
66
  sat_sample = select_time_slice(
67
- ds=da_sat_like,
67
+ da_sat_like,
68
68
  t0=t0,
69
- history_duration=history_duration,
70
- forecast_duration=forecast_duration,
71
- sample_period_duration=freq,
72
- )
73
-
74
- # Check the returned times are as expected
75
- assert (sat_sample.time_utc == expected_datetimes).all()
76
-
77
- # Make the selection using the `interval_[x]` parameters
78
- sat_sample = select_time_slice(
79
- ds=da_sat_like,
80
- t0=t0,
81
- interval_start=-history_duration,
82
- interval_end=forecast_duration,
69
+ interval_start=interval_start,
70
+ interval_end=interval_end,
83
71
  sample_period_duration=freq,
84
72
  )
85
73
 
@@ -93,8 +81,8 @@ def test_select_time_slice_out_of_bounds(da_sat_like, t0_str):
93
81
 
94
82
  # Slice parameters
95
83
  t0 = pd.Timestamp(f"2024-01-02 {t0_str}")
96
- forecast_duration = pd.Timedelta("30min")
97
- history_duration = pd.Timedelta("60min")
84
+ interval_start = pd.Timedelta(-30, "min")
85
+ interval_end = pd.Timedelta(60, "min")
98
86
  freq = pd.Timedelta("5min")
99
87
 
100
88
  # The data is available between these times
@@ -102,14 +90,14 @@ def test_select_time_slice_out_of_bounds(da_sat_like, t0_str):
102
90
  max_time = da_sat_like.time_utc.max()
103
91
 
104
92
  # Expect to return these timestamps from the selection
105
- expected_datetimes = pd.date_range(t0 - history_duration, t0 + forecast_duration, freq=freq)
93
+ expected_datetimes = pd.date_range(t0 + interval_start, t0 + interval_end, freq=freq)
106
94
 
107
95
  # Make the partially out of bounds selection
108
96
  sat_sample = select_time_slice(
109
- ds=da_sat_like,
97
+ da_sat_like,
110
98
  t0=t0,
111
- history_duration=history_duration,
112
- forecast_duration=forecast_duration,
99
+ interval_start=interval_start,
100
+ interval_end=interval_end,
113
101
  sample_period_duration=freq,
114
102
  fill_selection=True
115
103
  )
@@ -138,8 +126,8 @@ def test_select_time_slice_nwp_basic(da_nwp_like, t0_str):
138
126
 
139
127
  # Slice parameters
140
128
  t0 = pd.Timestamp(f"2024-01-02 {t0_str}")
141
- forecast_duration = pd.Timedelta("6h")
142
- history_duration = pd.Timedelta("3h")
129
+ interval_start = pd.Timedelta(-6, "h")
130
+ interval_end = pd.Timedelta(3, "h")
143
131
  freq = pd.Timedelta("1h")
144
132
 
145
133
  # Make the selection
@@ -147,8 +135,8 @@ def test_select_time_slice_nwp_basic(da_nwp_like, t0_str):
147
135
  da_nwp_like,
148
136
  t0,
149
137
  sample_period_duration=freq,
150
- history_duration=history_duration,
151
- forecast_duration=forecast_duration,
138
+ interval_start=interval_start,
139
+ interval_end=interval_end,
152
140
  dropout_timedeltas = None,
153
141
  dropout_frac = 0,
154
142
  accum_channels = [],
@@ -156,7 +144,7 @@ def test_select_time_slice_nwp_basic(da_nwp_like, t0_str):
156
144
  )
157
145
 
158
146
  # Check the target-times are as expected
159
- expected_target_times = pd.date_range(t0 - history_duration, t0 + forecast_duration, freq=freq)
147
+ expected_target_times = pd.date_range(t0 + interval_start, t0 + interval_end, freq=freq)
160
148
  assert (da_slice.target_time_utc==expected_target_times).all()
161
149
 
162
150
  # Check the init-times are as expected
@@ -172,8 +160,8 @@ def test_select_time_slice_nwp_with_dropout(da_nwp_like, dropout_hours):
172
160
  """Test the functionality of select_time_slice_nwp with dropout"""
173
161
 
174
162
  t0 = pd.Timestamp("2024-01-02 12:00")
175
- forecast_duration = pd.Timedelta("6h")
176
- history_duration = pd.Timedelta("3h")
163
+ interval_start = pd.Timedelta(-6, "h")
164
+ interval_end = pd.Timedelta(3, "h")
177
165
  freq = pd.Timedelta("1h")
178
166
  dropout_timedelta = pd.Timedelta(f"-{dropout_hours}h")
179
167
 
@@ -181,8 +169,8 @@ def test_select_time_slice_nwp_with_dropout(da_nwp_like, dropout_hours):
181
169
  da_nwp_like,
182
170
  t0,
183
171
  sample_period_duration=freq,
184
- history_duration=history_duration,
185
- forecast_duration=forecast_duration,
172
+ interval_start=interval_start,
173
+ interval_end=interval_end,
186
174
  dropout_timedeltas = [dropout_timedelta],
187
175
  dropout_frac = 1,
188
176
  accum_channels = [],
@@ -190,7 +178,7 @@ def test_select_time_slice_nwp_with_dropout(da_nwp_like, dropout_hours):
190
178
  )
191
179
 
192
180
  # Check the target-times are as expected
193
- expected_target_times = pd.date_range(t0 - history_duration, t0 + forecast_duration, freq=freq)
181
+ expected_target_times = pd.date_range(t0 + interval_start, t0 + interval_end, freq=freq)
194
182
  assert (da_slice.target_time_utc==expected_target_times).all()
195
183
 
196
184
  # Check the init-times are as expected considering the delay
@@ -207,9 +195,9 @@ def test_select_time_slice_nwp_with_dropout_and_accum(da_nwp_like, t0_str):
207
195
 
208
196
  # Slice parameters
209
197
  t0 = pd.Timestamp(f"2024-01-02 {t0_str}")
210
- forecast_duration = pd.Timedelta("6h")
211
- history_duration = pd.Timedelta("3h")
212
- freq = pd.Timedelta("1h")
198
+ interval_start = pd.Timedelta(-6, "h")
199
+ interval_end = pd.Timedelta(3, "h")
200
+ freq = pd.Timedelta("1H")
213
201
  dropout_timedelta = pd.Timedelta("-2h")
214
202
 
215
203
  t0_delayed = (t0 + dropout_timedelta).floor(NWP_FREQ)
@@ -218,8 +206,8 @@ def test_select_time_slice_nwp_with_dropout_and_accum(da_nwp_like, t0_str):
218
206
  da_nwp_like,
219
207
  t0,
220
208
  sample_period_duration=freq,
221
- history_duration=history_duration,
222
- forecast_duration=forecast_duration,
209
+ interval_start=interval_start,
210
+ interval_end=interval_end,
223
211
  dropout_timedeltas=[dropout_timedelta],
224
212
  dropout_frac=1,
225
213
  accum_channels=["dswrf"],
@@ -227,7 +215,7 @@ def test_select_time_slice_nwp_with_dropout_and_accum(da_nwp_like, t0_str):
227
215
  )
228
216
 
229
217
  # Check the target-times are as expected
230
- expected_target_times = pd.date_range(t0 - history_duration, t0 + forecast_duration, freq=freq)
218
+ expected_target_times = pd.date_range(t0 + interval_start, t0 + interval_end, freq=freq)
231
219
  assert (da_slice.target_time_utc==expected_target_times).all()
232
220
 
233
221
  # Check the init-times are as expected considering the delay
@@ -254,7 +242,7 @@ def test_select_time_slice_nwp_with_dropout_and_accum(da_nwp_like, t0_str):
254
242
  init_time_utc=t0_delayed,
255
243
  channel="dswrf",
256
244
  ).diff(dim="step", label="lower")
257
- .sel(step=slice(t0-t0_delayed - history_duration, t0-t0_delayed + forecast_duration))
245
+ .sel(step=slice(t0-t0_delayed + interval_start, t0-t0_delayed + interval_end))
258
246
  )
259
247
 
260
248
  # Check the values are the same
@@ -275,7 +263,7 @@ def test_select_time_slice_nwp_with_dropout_and_accum(da_nwp_like, t0_str):
275
263
  init_time_utc=t0_delayed,
276
264
  channel="t",
277
265
  )
278
- .sel(step=slice(t0-t0_delayed - history_duration, t0-t0_delayed + forecast_duration))
266
+ .sel(step=slice(t0-t0_delayed + interval_start, t0-t0_delayed + interval_end))
279
267
  )
280
268
 
281
269
  # Check the values are the same
@@ -11,9 +11,9 @@ def pvnet_config_filename(tmp_path, config_filename, nwp_ukv_zarr_path, uk_gsp_z
11
11
 
12
12
  # adjust config to point to the zarr file
13
13
  config = load_yaml_configuration(config_filename)
14
- config.input_data.nwp['ukv'].nwp_zarr_path = nwp_ukv_zarr_path
15
- config.input_data.satellite.satellite_zarr_path = sat_zarr_path
16
- config.input_data.gsp.gsp_zarr_path = uk_gsp_zarr_path
14
+ config.input_data.nwp['ukv'].zarr_path = nwp_ukv_zarr_path
15
+ config.input_data.satellite.zarr_path = sat_zarr_path
16
+ config.input_data.gsp.zarr_path = uk_gsp_zarr_path
17
17
 
18
18
  filename = f"{tmp_path}/configuration.yaml"
19
19
  save_yaml_configuration(config, filename)
@@ -60,7 +60,7 @@ def test_pvnet_no_gsp(pvnet_config_filename):
60
60
  # load config
61
61
  config = load_yaml_configuration(pvnet_config_filename)
62
62
  # remove gsp
63
- config.input_data.gsp.gsp_zarr_path = ''
63
+ config.input_data.gsp.zarr_path = ''
64
64
 
65
65
  # save temp config file
66
66
  with tempfile.NamedTemporaryFile() as temp_config_file:
@@ -13,8 +13,8 @@ def site_config_filename(tmp_path, config_filename, nwp_ukv_zarr_path, sat_zarr_
13
13
 
14
14
  # adjust config to point to the zarr file
15
15
  config = load_yaml_configuration(config_filename)
16
- config.input_data.nwp["ukv"].nwp_zarr_path = nwp_ukv_zarr_path
17
- config.input_data.satellite.satellite_zarr_path = sat_zarr_path
16
+ config.input_data.nwp["ukv"].zarr_path = nwp_ukv_zarr_path
17
+ config.input_data.satellite.zarr_path = sat_zarr_path
18
18
  config.input_data.site = data_sites
19
19
  config.input_data.gsp = None
20
20