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

Commit c97cbab

Browse files
committed
reverse y index of NWPs
1 parent 5ff3fe6 commit c97cbab

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

nowcasting_dataset/data_sources/nwp/nwp_data_source.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class NWPDataSource(ZarrDataSource):
2323
Attributes:
2424
_data: xr.DataArray of Numerical Weather Predictions, opened by open().
2525
x is left-to-right.
26-
y is bottom-to-top.
26+
y is top-to-bottom (after reversing the `y` index in open_nwp()).
2727
consolidated: Whether or not the Zarr store is consolidated.
2828
channels: The NWP forecast parameters to load. If None then don't filter.
2929
See: http://cedadocs.ceda.ac.uk/1334/1/uk_model_data_sheet_lores1.pdf
@@ -181,6 +181,12 @@ def open_nwp(zarr_path: str, consolidated: bool) -> xr.DataArray:
181181

182182
ukv = nwp["UKV"]
183183

184+
# Reverse `y` so it's top-to-bottom (so ZarrDataSource.get_example() works correctly!)
185+
# Adapted from:
186+
# https://stackoverflow.com/questions/54677161/xarray-reverse-an-array-along-one-coordinate
187+
y_reversed = ukv.y[::-1]
188+
ukv = ukv.reindex(y=y_reversed)
189+
184190
# Sanity checks.
185191
# If there are any duplicated init_times then drop the duplicated init_times:
186192
init_time = pd.DatetimeIndex(ukv["init_time"])

0 commit comments

Comments
 (0)