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

Commit f455863

Browse files
Merge pull request #729 from openclimatefix/issue/bug-int
NWP example size
2 parents bdacff2 + ca1fc2b commit f455863

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

nowcasting_dataset/data_sources/data_source.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -440,15 +440,24 @@ def get_example(self, location: SpaceTimeLocation) -> xr.Dataset:
440440
f"Getting example for {t0_datetime_utc=}, " f"{x_center_osgb=} and {y_center_osgb=}"
441441
)
442442

443-
selected_data = self._get_time_slice(t0_datetime_utc)
443+
selected_data_time = self._get_time_slice(t0_datetime_utc)
444444
bounding_box = self._rectangle.bounding_box_centered_on(
445445
x_center_osgb=x_center_osgb, y_center_osgb=y_center_osgb
446446
)
447-
selected_data = selected_data.sel(
448-
x_osgb=slice(int(bounding_box.left), int(bounding_box.right)),
449-
y_osgb=slice(int(bounding_box.top), int(bounding_box.bottom)),
447+
selected_data = selected_data_time.sel(
448+
x_osgb=slice(bounding_box.left, bounding_box.right),
449+
y_osgb=slice(bounding_box.top, bounding_box.bottom),
450450
)
451451

452+
# This is a horrible fix
453+
# Sometimes the data has 1 less pixel it. This came around with new nwp-consumer.
454+
# This is due the data not being regridded to osgb. Then plan is to move to lat/lon.
455+
if selected_data.shape[2] == self._rectangle.size_pixels_height - 1:
456+
selected_data = selected_data_time.sel(
457+
x_osgb=slice(bounding_box.left, bounding_box.right),
458+
y_osgb=slice(bounding_box.top + self.meters_per_pixel, bounding_box.bottom),
459+
)
460+
452461
# selected_sat_data is likely to have 1 too many pixels in x and y
453462
# because sel(x=slice(a, b)) is [a, b], not [a, b). So trim:
454463
selected_data = selected_data.isel(

0 commit comments

Comments
 (0)