簡體   English   中英

使用 CDO 刪除 NetCDF 屬性

[英]Delete NetCDF attributes with CDO

如何使用 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

實際上我通常發現 nco 更適合這種任務。

您可以使用ncatted刪除變量的屬性

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

所以在你的情況下

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

d 用於“刪除”,請參閱此頁面以了解用法

要刪除全局屬性,請使用此答案,而是編寫

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

提示:您還可以添加 -h 選項以防止添加到 netcdf 歷史全局屬性

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM