@@ -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