I've created a xarray.DataArray and I save it using xarray.DataArray.to_netcdf.
I create it using:
datatmp = np.full([nens, len(modanom.coords['time'].values), len(modanom.coords['latitude'].values), len(modanom.coords['longitude'].values)], np.nan)
b = xr.DataArray(datatmp, coords=[range(1,nens + 1), modanom.coords['time'], modanom.coords['latitude'], modanom.coords['longitude']], dims=['ensemble', 'time', 'latitude', 'longitude'])
i.e. I don't specify a name such as:
b = xr.DataArray({'windspeed': (('ensemble', 'time', 'latitude', 'longitude'), datatmp)}, coords=[range(1,nens + 1), modanom.coords['time'], modanom.coords['latitude'], modanom.coords['longitude']], dims=['en