Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions nowcasting_dataset/data_sources/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,15 +440,24 @@ def get_example(self, location: SpaceTimeLocation) -> xr.Dataset:
f"Getting example for {t0_datetime_utc=}, " f"{x_center_osgb=} and {y_center_osgb=}"
)

selected_data = self._get_time_slice(t0_datetime_utc)
selected_data_time = self._get_time_slice(t0_datetime_utc)
bounding_box = self._rectangle.bounding_box_centered_on(
x_center_osgb=x_center_osgb, y_center_osgb=y_center_osgb
)
selected_data = selected_data.sel(
x_osgb=slice(int(bounding_box.left), int(bounding_box.right)),
y_osgb=slice(int(bounding_box.top), int(bounding_box.bottom)),
selected_data = selected_data_time.sel(
x_osgb=slice(bounding_box.left, bounding_box.right),
y_osgb=slice(bounding_box.top, bounding_box.bottom),
)

# This is a horrible fix
# Sometimes the data has 1 less pixel it. This came around with new nwp-consumer.
# This is due the data not being regridded to osgb. Then plan is to move to lat/lon.
if selected_data.shape[2] == self._rectangle.size_pixels_height - 1:
selected_data = selected_data_time.sel(
x_osgb=slice(bounding_box.left, bounding_box.right),
y_osgb=slice(bounding_box.top + self.meters_per_pixel, bounding_box.bottom),
)

# selected_sat_data is likely to have 1 too many pixels in x and y
# because sel(x=slice(a, b)) is [a, b], not [a, b). So trim:
selected_data = selected_data.isel(
Expand Down