简体   繁体   English

使用 CDO 删除 NetCDF 属性

[英]Delete NetCDF attributes with CDO

How can I use the CDO delete operator to remove variable-specific and/or global attributes of a NetCDF?如何使用 CDO delete运算符删除 NetCDF 的特定于变量和/或全局属性?

As far as I understand from the help pages of the operator, I should provide a comma-separated list of attributes, keyed by param , but:据我从操作员的帮助页面了解到,我应该提供一个以逗号分隔的属性列表,以param键,但是:

$ cdo delete,param="pr@missing_value,Title" ifile.nc ofile.n
cdo    delete (Warning): Parameter >pr:missing_value< not found!
cdo    delete (Warning): Parameter >Title< not found!

NOTE: this is the list of attributes of my test file:注意:这是我的测试文件的属性列表:

$ cdo showattribute ifile.nc
pr:
   long_name = "precipitation"
   units = "mm"
   missing_value = -999
Global:
   Conventions = "CF-1.5" 
   Title = "Ninja Title"
   Created on = "Wed Aug 25 03:29:12 2021"

Using CDO version 1.9.9使用CDO version 1.9.9

Actually I usually find nco is much more appropriate for this kind of task.实际上我通常发现 nco 更适合这种任务。

You can delete the attribute of the variable using ncatted您可以使用ncatted删除变量的属性

ncatted -a att_nm,var_nm,mode,att_type,att_val

so in your case it would be所以在你的情况下

ncatted -O -a missing_value,pr,d,, file.nc 

d is for "delete", see this page for usage d 用于“删除”,请参阅此页面以了解用法

To delete the global attribute, using this answer , you would instead write要删除全局属性,请使用此答案,而是编写

ncatted -O -a title,global,d,, file.nc

Hint: you can also add the -h option to prevent additions to the netcdf history global attribute提示:您还可以添加 -h 选项以防止添加到 netcdf 历史全局属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM