@@ -2271,8 +2271,10 @@ def gen_sources(): # iterator over proc,sub_g,map_fn
22712271 g = grids [proc ]
22722272 yield [proc ,g ,ds ]
22732273 elif merged :
2274- map_fn = self .map_outputs ()[0 ]
2275- g = unstructured_grid .UnstructuredGrid .from_ugrid (map_fn )
2274+ # not split into subdomains, but outputs may potentially be split by timesteps
2275+ map_fn = self .map_outputs ()
2276+ # use the first output to get the grid (they should all be the same)
2277+ g = unstructured_grid .UnstructuredGrid .from_ugrid (map_fn [0 ])
22762278 yield [0 ,g ,map_fn ]
22772279 else :
22782280 for proc in range (self .num_procs ):
@@ -2316,8 +2318,20 @@ def time_to_isel(ds,times,mode='nearest'):
23162318 if c is not None :
23172319 proc_point_cell [proc ,pnti ]= c
23182320 if ds is None :
2319- if isinstance (map_fn ,str ):
2320- ds = xr .open_dataset (map_fn )
2321+ if isinstance (map_fn , list ) and len (map_fn ) == 1 :
2322+ # if we only have one output in the map_output list, open it as a single file
2323+ ds = xr .open_dataset (map_fn [0 ])
2324+ elif isinstance (map_fn , list ):
2325+ # otherwise, open multi-file dataset
2326+ def clean_nc (ds ):
2327+ ds ['Nk_c' ] = ds [
2328+ 'Nk' ] # poorly named variable.
2329+ del ds ['Nk' ]
2330+ for d in ['Nc' , 'Nk' , 'numsides' , 'Ne' , 'Two' , 'Nkw' ]:
2331+ ds [d ] = np .arange (ds .dims [d ])
2332+ ds = ds .set_coords (['xp' , 'yp' ])
2333+ return ds
2334+ ds = xr .open_mfdataset (map_fn , preprocess = clean_nc , data_vars = 'minimal' )
23212335 else :
23222336 ds = map_fn .copy ()
23232337 # doctor up the Nk dimensions
0 commit comments