How to extract mapping between raw and cf-python's coordinate names #644
Replies: 2 comments
-
Hi @robertjwilson, Thanks for the question. In this example >>> import cf
>>> f = cf.example_field(0)
>>> x = f.coordinate('X')
>>> x.nc_get_variable() # will give the name from the file (if read from one)
'lon'
>>> x.nc_set_variable('newlon') # set a new name
>>> x.nc_get_variable()
'newlon'
>>> cf.write(f, 'test_file.nc') # writes the X coordinate with netCDF name given by x.nc_get_variable() If no netCDF variable exists (either because you created the Field ab initio and didn't set one, or you deleted it with Hope that helps, |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick response @davidhassell. That has solved my problem succicently. Much appreciated Robert |
Beta Was this translation helpful? Give feedback.
-
cf-python does an excellent job of giving proper names to coordinates (time, lon, lat etc.) after using
cf.read
. However, is it possibly to extract how the new coordinate names map to those in the raw netCDF file?Is that something that is purely internal or is it preserved somewhere?
Beta Was this translation helpful? Give feedback.
All reactions