@@ -440,15 +440,24 @@ def get_example(self, location: SpaceTimeLocation) -> xr.Dataset:
440
440
f"Getting example for { t0_datetime_utc = } , " f"{ x_center_osgb = } and { y_center_osgb = } "
441
441
)
442
442
443
- selected_data = self ._get_time_slice (t0_datetime_utc )
443
+ selected_data_time = self ._get_time_slice (t0_datetime_utc )
444
444
bounding_box = self ._rectangle .bounding_box_centered_on (
445
445
x_center_osgb = x_center_osgb , y_center_osgb = y_center_osgb
446
446
)
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 ),
450
450
)
451
451
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
+
452
461
# selected_sat_data is likely to have 1 too many pixels in x and y
453
462
# because sel(x=slice(a, b)) is [a, b], not [a, b). So trim:
454
463
selected_data = selected_data .isel (
0 commit comments