【问题标题】:Delete NetCDF attributes with CDO使用 CDO 删除 NetCDF 属性
【发布时间】:2021-12-23 05:03:44
【问题描述】:

如何使用 CDO delete 运算符删除 NetCDF 的变量特定和/或全局属性?

据我从运营商的帮助页面了解,我应该提供一个以逗号分隔的属性列表,以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!

注意:这是我的测试文件的属性列表:

$ 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"

使用CDO version 1.9.9

【问题讨论】:

    标签: netcdf cdo-climate nco


    【解决方案1】:

    其实我通常觉得 nco 更适合这种任务。

    您可以使用ncatted删除变量的属性

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

    所以在你的情况下它会是

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

    d 代表“删除”,see this page for usage

    要删除全局属性using this answer,您可以改写

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

    提示:您还可以添加 -h 选项以防止添加到 netcdf 历史全局属性

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-20
      • 1970-01-01
      • 2021-11-28
      • 2011-08-16
      • 1970-01-01
      • 2021-09-07
      • 2014-05-31
      • 1970-01-01
      相关资源
      最近更新 更多