preprocess removes attrs
As pointed out by @rlorenz EC-Earth models get removed from the archive due to missing attrs
in lat.
This happens in https://git.iac.ethz.ch/cmip6-ng/cmip6-ng/-/blob/master/cmip6-ng/core/core_functions.py#L187
To reproduce:
module load conda/2019
conda activate iacpy_cmip6_ng
ipython
import numpy as np
import xarray as xr
file = "/net/atmos/data/cmip6/ssp126/day/pr/EC-Earth3-Veg/r3i1p1f1/gr/pr_day_EC-Earth3-Veg_ssp126_r3i1p1f1_gr_20950101-20951231.nc"
ds = xr.open_dataset(file)
print(ds.lat.attrs)
ds = ds.assign_coords(lat=np.around(ds['lat'], 2))
print(ds.lat.attrs)
This can be fixed as:
ds = xr.open_dataset(file)
print(ds.lat.attrs)
ds.lat.values = np.around(ds['lat'].values, 2)
print(ds.lat.attrs)
Note - this no longer happens with newer versions of numpy and xarray:
module load conda
conda activate iacpy3_2022
ipython
import numpy as np
import xarray as xr
file = "/net/atmos/data/cmip6/ssp126/day/pr/EC-Earth3-Veg/r3i1p1f1/gr/pr_day_EC-Earth3-Veg_ssp126_r3i1p1f1_gr_20950101-20951231.nc"
ds = xr.open_dataset(file)
print(ds.lat.attrs)
ds = ds.assign_coords(lat=np.around(ds['lat'], 2))
print(ds.lat.attrs)