CDO - 修改操作
本篇随笔将介绍 CDO 对输入数据集进行修改的操作
修改操作 Modification Operators
Set 设置
<operator>,parameter infile outfile
Operators | Type | Description |
---|---|---|
setattribute,attributes | STRING | 设置数据集的属性,并将结果写入 outfile ; attributes:[var_nm@]att_nm[:s|d|i]=[att_val|{[var_nm@]att_nm}] var_nm:变量名,比如: temperature ; var_nm 为 * ,对所有变量修改; var_nm 缺失时, 将设置全局属性; att_nm:属性名,比如: units ; 定义属性 att_nm 的类型:字符串( att_nm:s )、双精度( att_nm:d )和整型( att_nm:i ) att_val:赋予属性 att_nm 的值,比如: K ; att_val 可以复制现有属性( {[var_nm@]att_nm} );如果省略 att_val ,则属性 att_nm 将被删除; |
setpartabp,table[,convert] | STRING | 根据变量的 ID 搜索参数表文件 table ,对 infile 的数据进行修改,并写入 outfile ; 参数 convert 控制是否进行单位换算; |
setpartabn,table[,convert] | STRING | 根据变量的 name 搜索参数表文件 table ,对 infile 的数据进行修改,并写入 outfile ; 参数 convert 控制是否进行单位换算;cdo setpartabn,mypartab,convert infile outfile |
setcodetab,table | STRING | 根据参数表文件 table ,对 infile 所有变量的 code number 进行修改,并写入 outfile |
setcode,code | INTEGER | 设置 所有变量的 code number 为相同的给定值 code |
setparam,param | STRING | 设置 第一个变量的 ID 为 param |
setname,name | STRING | 设置 第一个变量的 name 为 name |
setunit,unit | STRING | 设置 第一个变量的 unit 为 unit |
setlevel,level | FLOAT | 设置 所有变量的 level 为 level |
setltype,ltype | INTEGER | 设置 所有变量的 GRIB level type 为 ltype |
setdate,date | STRING | 将每个时间步中的日期设置为相同的给定值(YYYY-MM-DD) |
settime,time | STRING | 将每个时间步中的时间设置为相同的给定值(hh:mm:ss) |
setday,day | INTEGER | 将每个时间步中的天设置为相同的给定值 |
setmon,month | INTEGER | 将每个时间步中的月份设置为相同的给定值 |
setyear,year | INTEGER | 将每个时间步中的年份设置为相同的给定值 |
settaxis,date,time[,inc] | STRING | 设置时间轴cdo settaxis,2020-01-01,12:00:00,1mon infile outfile |
settbounds,frequency | STRING | 设定时间范围(hour, day, month, year)cdo settbounds,day infile outfile |
setreftime,date,time[,units] | STRING | 设置 相对时间轴 的参考时间cdo setreftime,2020-01-01,12:00:00,days infile outfile |
settunits,units | STRING | 设置 相对时间轴 的基本单位(seconds, minutes, hours, days, months, years)cdo settunits,days infile outfile |
setcalendar,calendar | STRING | 设置 相对时间轴 的日历(tandard, proleptic_gregorian, 360_day, 365_day, 366_day)cdo setcalendar,365_day infile outfile |
setgrid,grid | STRING | Sets a new grid description. The parameter grid is the grid description file or name. |
setgridtype,gridtype | STRING | Sets the grid type of all input fields. (curvilinear, unstructured, dereference, regular, regularnn, lonlat) |
setgridarea,gridarea | STRING | Sets the grid cell area. The parameter gridarea is the path to a data file. |
setgridmask,gridmask | STRING | Sets the grid mask. The parameter gridmask is the path to a data file. |
setzaxis,zaxis | STRING | Sets the z-axis description of all variables with the same number of level as the new z-axis. The parameter zaxis is the z-axis description file or name of the target z-axis. |
genlevelbounds[,zbot[,ztop]] | FLOAT | Generates the layer bounds of the z-axis. |
setmissval,newmiss | FLOAT | 设置一个新的缺失值 |
setctomiss,c | FLOAT | 将常数替换为缺失值 |
setmisstoc,c | FLOAT | 将缺失值替换为常数 |
setrtomiss,rmin,rmax | FLOAT | 设置缺失值的范围 |
setvrange,rmin,rmax | FLOAT | 设置有效值的范围 |
setmisstonn | FLOAT | 将所有缺失值替换为最邻近的非缺失值 |
setmisstodis[,neighbors] | INTEGER | 将所有缺失值替换为周围最近的 neighbors 个非缺失值邻居的距离加权平均 |
setgridcell,value[,cell][,mask] | FLOAT, INTEGER, STRING | 设置所选网格的值;可以通过网格单元索引列表 cell 或掩码 mask 来选择网格单元;如果指定网格单元,则对所有网格进行操作; value :网格单元的值; cell :逗号分隔的网格单元的索引列表; mask :包含 mask 的数据文件; |
setvals,oldval,newval[,...] | STRING | 将变量的旧值 oldval 设置为新值 newval |
setrtoc,rmin,rmax,c | STRING | 将变量满足在 [rmin,rmax] 区间的值设为常数 c |
setrtoc2,rmin,rmax,c,c2 | STRING | 将变量满足在 [rmin,rmax] 区间的值设为常数 c ,否则设为常数 c2 |
Change 更改
<operator>,parameter infile outfile
Operators | Type | Description |
---|---|---|
chcode,oldcode,newcode[,oldcode,newcode,...] | INTEGER | 根据 oldcode 和 newcode 更改 code number |
chparam,oldparam,newparam,... | STRING | 根据 oldparam 和 newparam 更改变量 ID |
chname,oldname,newname,... | STRING | 根据 oldname 和 newname 更改变量 name |
chunit,oldunit,newunit,... | STRING | 根据 oldunit 和 newunit 更改变量单位 |
chlevel,oldlev,newlev,... | FLOAT | 根据 oldlev 和 newlev 更改 level |
chlevelc,code,oldlev,newlev | INTEGER, FLOAT | 更改给定 code number 的变量的 level |
chlevelv,name,oldlev,newlev | STRING, FLOAT | 更改给定 变量 name 对应的 level |
Invert 反转
<operator> infile outfile
Operators | Type | Description |
---|---|---|
invertlat | INTEGER | 反转纬度 |
invertlev | INTEGER | 反转 levels |
Shift 移动
<operator>,parameter infile outfile
Operators | Type | Description |
---|---|---|
shifttime,sval | STRING | 通过参数 sval 移动所有的时间步cdo shifttime,-12hour infile outfile |
shiftx,nshift[,cyclic][,coord] | INTEGER | 在 x 方向上移动所有的场 参数 cyclic 设置对单元格进行循环填充,缺失则对单元格进行缺失填充参数 coord 控制是否同时移动坐标 |
shifty,nshift[,cyclic][,coord] | INTEGER | 在 y 方向上移动所有的场cdo shifty,1,cyclic infile outfile |
Mask
<operator>,parameter infile outfile
Operators | Type | Description |
---|---|---|
maskregion,regions | STRING | 用规则的 lon/lat 网格 mask 不同区域的字段;区域内的元素不变,区域外的元素设为缺失; 参数 regions 为区域的描述文件,描述文件每一行为多边形一个点的经度和纬度; cdo maskregion,myregion infile outfile |
masklonlatbox,lon1,lon2,lat1,lat2 | FLOAT | 根据经纬度的值 mask 一个矩形框区域,框内元素不变,框外元素设为缺失 |
maskindexbox,idx1,idx2,idy1,idy2 | INTEGER | 根据经纬度的索引 mask 一个矩形框区域,框内元素不变,框外元素设为缺失 |
setclonlatbox,c,lon1,lon2,lat1,lat2 | FLOAT, FLOAT | 根据经纬度的值确定一个矩形框区域,框内元素设为常数 c ,框外元素不变 |
setcindexbox,c,idx1,idx2,idy1,idy2 | FLOAT, INTEGER | 根据经纬度的索引确定一个矩形框区域,框内元素设为常数 c ,框外元素不变 |
enlarge,grid | STRING | 根据目标网格描述文件或名称 grid 对 infile 进行广播操作,将 infile 的水平网格广播到与给定的水平网格 grid 相同; 例子: infile1 的水平网格为全局区域, infile2 为一个点,如果想将 infile1 和 infile2 相加,则需要先对 infile2 广播: cdo add infile1 -enlarge,infile1 infile2 outfile |