You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a preprocessing option that can be added to open_mfdataset? I'd like to add a time dimension based on the filename for a suite of > 300 files that has only 2D longitude-latitude data.
for example, in Python I can do:
importxarrayasxrimportnumpyasnpdefpreprocessing(ds):
time_str=os.path.basename(ds.encoding['source']).split('_')[0:2] # get year and month from filenametime_str.append('01') # add a hardcoded day to list of timetime_str="-".join(time_str) # create a single date stringds['time'] =np.datetime64(time_str, 'ns') # assign to dataset dsds=ds.set_coords('time') # specify time as a coordinatereturndsds_crps=xr.open_mfdataset(list_of_files, concat_dim='time', combine='nested', preprocess=preprocessing)
How does one open a dataset spread over multiple files (like with xarray's
open_mfdataset
function)?The text was updated successfully, but these errors were encountered: