How to rename long_name in netCDF file
Added by Eléonore R over 2 years ago
I want to rename the variable "time" long_name in a netCDF file with the date of observed data ("2018.1-2018.12"). I read in different forums that I should use "ncatted." However, even after having well-installed nco. I obtain the error message "SyntaxError: invalid syntax" while running the ncatted command (in Windows 10).
from nco import Nco
nco = Nco
from netCDF4 import Dataset
data = Dataset("C://pre_2018_2018.nc", mode='r')
print(time.long_name)
time
ncatted -a longname,time,o,c,"2018.1-2018.12" pre_2018_2018.nc
SyntaxError: invalid syntax
Do you know where I make a mistake?
Replies (1)
RE: How to rename long_name in netCDF file - Added by Karin Meier-Fleischer over 2 years ago
Hi Eleonore,
you ask the question in the wrong forum, this forum answers questions about CDO (that is not NCO).
But here comes a hint: you try to use the ncatted call as you can do in the terminal command line, but you want to do it in a Python script.
In the Readme.md of https://github.com/nco/pynco is a nice example how to use ncatted in Python.