Getting information on netcdf file with unlimited dimensions #7517
Open
Description
What is your issue?
When one reads a netCDF file, there is not solution to determine if there is an unlimited dimension, and determine which one.
I really need to be able to handle that. I need to process a variable, and write the result with the exact same informations about dimensions and coordinates, with all attributes and characteristics.
Thanks,
Olivier
import xarray as xr, os
print ( '==== Get an example file' )
file = 'tas_Amon_IPSL-CM6A-LR_piControl_r1i1p1f1_gr_185001-234912.nc'
h_file = f"https://vesg.ipsl.upmc.fr/thredds/fileServer/cmip6/CMIP/IPSL/IPSL-CM6A-LR/piControl/r1i1p1f1/Amon/tas/gr/v20200326/{file}"
print ( '\n ==== Getting file ')
os.system ( f"wget --no-clobber {h_file}")
print ( '\n ==== File header : this file has an unlimited dimension "time"' )
os.system ( f"ncdump -h {file} | head")
dd = xr.open_dataset ( file, decode_times=True, use_cftime=True)
xr.set_options ( display_expand_attrs=True)
print ( '\n ==== General information : no information about the unlimited dimension(s)' )
print (dd)
print ( '\n ==== Dimensions : no information about the unlimited dimension(s)')
print ( dd.dims )
print ( '\n === Attributes : no information about the unlimited dimension(s)' )
for attr in dd.attrs :
print ( f'{attr} : {dd.attrs[attr]}' )