how to change the variables name by using 'chname'
Added by Wi Du over 8 years ago
Hello, Everyone,
I just wanted to change the variables name from a netcdf file because the name of variables are contain '.'(dot) and I cannot display them with GRADS software. The information of the file is as follows.
ga-> sdfopen Interim_yearmean_1980_2011.nc
Scanning self-describing file: Interim_yearmean_1980_2011.nc
SDF file Interim_yearmean_1980_2011.nc is open as file 1
LON set to 0 180
LAT set to 0 60
LEV set to 0 0
Time values set: 1980:12:1:0 1980:12:1:0
E set to 1 1
ga-> q file
File 1 :
Descriptor: Interim_yearmean_1980_2011.nc
Binary: Interim_yearmean_1980_2011.nc
Type = Gridded
Xsize = 241 Ysize = 81 Zsize = 1 Tsize = 32 Esize = 1
Number of Variables = 7
rsn 0 t,y,x Snow density
p55.162 0 t,y,x Vertical integral of water vapour
p71.162 0 t,y,x Vertical integral of eastward water vapour flux
p72.162 0 t,y,x Vertical integral of northward water vapour flux
p84.162 0 t,y,x Vertical integral of divergence of moisture flux
tcwv 0 t,y,x Total column water vapour
t2m 0 t,y,x 2 metre temperature
So here I just used 'chname' to change the variable 'p55.162', but it failed. The error is as follows.
duan@duan-dynabook-T451-57DB:~/Hokkaidorainfall$ cdo chname, p55.162,viwv Interim_total_1980_2011.nc Interim_new_1980_2011.nc
Error (cdo chname) : Too many streams! Operator needs 1 input and 1 output streams.
duan@duan-dynabook-T451-57DB:~/Hokkaidorainfall$
So, anyone can help me how to use the right method to change the variables name including p55.162, p71.162, p72.162, and p84.162.
Thank you in advance!
Duan
Replies (4)
RE: how to change the variables name by using 'chname' - Added by Uwe Schulzweida over 8 years ago
Remove the blank character after the first comma:
cdo chname, p55.162,viwv Interim_total_1980_2011.nc Interim_new_1980_2011.nc ^
cdo chname,p55.162,viwv Interim_total_1980_2011.nc Interim_new_1980_2011.nc
RE: how to change the variables name by using 'chname' - Added by Frida Perez over 3 years ago
Hi all,
I used this "chname" to change the name of one of my variables and it worked. However, the new file is missing the other 2 variables "lat" and "lon". Is there a way to change the name while keeping all the variables from the original file?
Thanks!
RE: how to change the variables name by using 'chname' - Added by Ralf Mueller over 3 years ago
If you want to keep everything the same, you can also use the NCO ncrename
.
I cannot comment on why CDO didn't take over lon and lat, maybe they were not used by any data variable. With the input uploaded I can say more.
cheers
ralf
RE: how to change the variables name by using 'chname' - Added by Frida Perez over 3 years ago
Hey ralf, that worked. I think you are right when you say they were not used by the data variable. Thanks!