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

Commit 2c4ce32

Browse files
committed
Only reverse y axis if necessary. Unittests pass.
1 parent c97cbab commit 2c4ce32

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

nowcasting_dataset/data_sources/nwp/nwp_data_source.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,14 @@ def open_nwp(zarr_path: str, consolidated: bool) -> xr.DataArray:
182182
ukv = nwp["UKV"]
183183

184184
# Reverse `y` so it's top-to-bottom (so ZarrDataSource.get_example() works correctly!)
185-
# Adapted from:
185+
# if necessary. Adapted from:
186186
# 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)
187+
if ukv.y[0] < ukv.y[1]:
188+
_LOG.warning(
189+
"NWP y axis runs from bottom-to-top. Will reverse y axis so it runs top-to-bottom."
190+
)
191+
y_reversed = ukv.y[::-1]
192+
ukv = ukv.reindex(y=y_reversed)
189193

190194
# Sanity checks.
191195
# If there are any duplicated init_times then drop the duplicated init_times:

0 commit comments

Comments
 (0)