Skip to content

Commit 8dee3e5

Browse files
authored
Clessig/develop/fix empty io 819 2 (ecmwf#822)
* Fix to io problems. * Fix issues in input
1 parent 2cadb57 commit 8dee3e5

File tree

1 file changed

+5
-2
lines changed
  • packages/common/src/weathergen/common

1 file changed

+5
-2
lines changed

packages/common/src/weathergen/common/io.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ def as_xarray(self, chunk_nsamples=CHUNK_N_SAMPLES) -> xr.Dataset:
153153
"ipoint": self.datapoints,
154154
"channel": self.channels, # TODO: make sure channel names align with data
155155
"valid_time": ("ipoint", times.astype("datetime64[ns]")),
156-
"lat": ("ipoint", coords[:, 0]),
157-
"lon": ("ipoint", coords[:, 1]),
156+
"lat": ("ipoint", coords[..., 0]),
157+
"lon": ("ipoint", coords[..., 1]),
158158
**geoinfo,
159159
},
160160
name=self.name,
@@ -436,6 +436,9 @@ def _offset_key(self, key: ItemKey):
436436

437437
def _extract_coordinates(self, stream_idx, offset_key, datapoints) -> DataCoordinates:
438438
_coords = self.targets_coords[offset_key.forecast_step][stream_idx][datapoints].numpy()
439+
# ensure _coords has size (?,2)
440+
if len(_coords) == 0:
441+
_coords = np.zeros((0, 2), dtype=np.float32)
439442
coords = _coords[..., :2] # first two columns are lat,lon
440443
geoinfo = _coords[..., 2:] # the rest is geoinfo => potentially empty
441444
if geoinfo.size > 0: # TODO: set geoinfo to be empty for now

0 commit comments

Comments
 (0)