CDO - 选择(切片)操作

本篇随笔将介绍 CDO 根据给定参数或条件进行选择和删除字段的功能

切片操作 Selection Operators

Select 切片

Select 相关的操作是根据所选择的参数列表或范围对输入数据集 infile 进行选择,并输出到输出数据集 outfile 中

列表的表示方式:a,b,c
范围的表示方式:first/last[/inc]

<operator>,parameter=<list/range> infiles outfile

OperatorsDescription
select根据给定的参数列表选择字段
delete根据给定的参数列表删除字段
ParametersTypeDescription
nameSTRING逗号分隔的变量 name 列表
paramSTRING逗号分隔的变量 ID 列表
codeINTEGER逗号分隔的 code number 列表或 first/last[/inc] 表示的范围
levelFLOAT逗号分隔的 levels 列表
levrangeFLOAT逗号分隔表示的 levels 范围
levidxINTEGER逗号分隔的 levels index 列表或 first/last[/inc] 表示的 levels index 范围
zaxisnameSTRING逗号分隔的 z 轴名称列表
zaxisnumINTEGER逗号分隔的 zaxisID 列表或 first/last[/inc] 表示的 zaxisID 范围
ltypeINTEGER逗号分隔的 GRIB level type 的列表或 first/last[/inc] 表示的范围
gridnameSTRING逗号分隔的网格名称(gridtype)列表
gridnumINTEGER逗号分隔的 gridID 列表或 first/last[/inc] 表示的 gridID 范围
steptypeSTRING逗号分隔的 timestep types 列表
dateSTRING逗号分隔的日期列表(YYYY-MM-DDThh:mm:ss)
startdateSTRING开始时间(YYYY-MM-DDThh:mm:ss)
enddateSTRING结束时间(YYYY-MM-DDThh:mm:ss)
minuteINTEGER逗号分隔的 minutes 列表或 first/last[/inc] 表示的 minutes 范围
hourINTEGER逗号分隔的 hours 列表或 first/last[/inc] 表示的 hours 范围
dayINTEGER逗号分隔的 days 列表或 first/last[/inc] 表示的 days 范围
monthINTEGER逗号分隔的 months 列表或 first/last[/inc] 表示的 months 范围
seasonSTRING逗号分隔的 seasons 列表(DJFMAMJJASOND or ANN)
yearINTEGER逗号分隔的 years 列表或 first/last[/inc] 表示的 years 范围
domSTRING逗号分隔的日期列表(如:29feb)
timestepINTEGER逗号分隔的时间步 timesteps 列表或 first/last[/inc] 表示的范围
timestep_of_yearINTEGER逗号分隔的 timesteps of year 列表或 first/last[/inc] 表示的范围
timestepmaskSTRINGRead timesteps from a mask file

<operator>,parameters infile outfile

OperatorsTypeDescription
selparam,paramsSTRING根据参数给定的变量 ID 列表选择字段
delparam,paramsSTRING根据参数给定的变量 ID 列表删除字段
selcode,codesINTEGER根据参数给定的 code number 列表或范围选择字段
delcode,codesINTEGER根据参数给定的 code number 列表或范围删除字段
selname,namesSTRING根据参数给定的变量 name 列表选择字段
delname,namesSTRING根据参数给定的变量 name 列表删除字段
selstdname,stdnamesSTRING根据参数给定的变量 standard_name 列表选择字段
sellevel,levelsFLOAT根据参数给定的 levels 列表选择字段
sellevidx,levidxINTEGER根据参数给定的 levels index 列表或范围选择字段
selgrid,gridsSTRING根据参数给定的网格名称(gridtype)列表选择字段
selzaxis,zaxesSTRING根据参数给定的 zaxistype 列表选择字段
selzaxisname,zaxisnamesSTRING根据参数给定的 z 轴名称列表选择字段
selltype,ltypesINTEGER根据参数给定的 GRIB level type 列表或范围选择字段
seltabnum,tabnumsINTEGER根据参数给定的 parameter table numbers 列表或范围选择
seltimestep,timestepsINTEGER根据参数给定的时间步 timestep 列表或范围选择字段
seltime,timesSTRING根据参数给定的时间列表或范围选择字段(hh:mm:ss)
selhour,hoursINTEGER根据参数给定的 hours 列表或范围选择字段
selday,daysINTEGER根据参数给定的 days 列表或范围选择字段
selmonth,monthsINTEGER根据参数给定的 months 列表或范围选择字段
selyear,yearsINTEGER根据参数给定的 years 列表或范围选择字段
selseason,seasonsSTRING根据参数给定的 seasons 列表选择字段(DJFMAMJJASOND or ANN)
seldate,startdate[,enddate]STRING根据参数给定的 date 范围选择字段(YYYY-MM-DDThh:mm:ss)
selsmon,month[,nts1[,nts2]]INTEGER选择指定单个月以及该月之前和之后任意数量时间步的字段

<operator>,x1,x2,y1,y2 infile outfile

OperatorsTypeDescription
sellonlatbox,lon1,lon2,lat1,lat2FLOAT根据经纬度的值选择 [lon1, lon2] 和 [lat1, lat2] 区间的字段
selindexbox,idx1,idx2,idy1,idy2INTEGER根据经纬度的索引选择 [idx1, idx2] 和 [idy1, idy2] 区间的字段

<operator>,indices infile outfile

OperatorsTypeDescription
selgridcell,indicesINTEGER根据参数给定的 index of grid cell 列表或范围选择字段
delgridcell,indicesINTEGER根据参数给定的 index of grid cell 列表或范围删除字段

<operator> infile1 infile2 outfile

OperatorsDescription
selyearidx根据 infile1 的 年度指数(yearly indices) 从 infile2 中选择字段,yearly indices 可以由 yearminidxyearmaxidx 这两个操作得出

<operator> infile outfile

OperatorsDescription
bottomvalue对三维的变量,选择底层的字段
topvalue对三维的变量,选择顶层的字段
isosurface,isovalue对三维的变量,计算等值面;等值面的值由参数 isovalue 指定,通过两层之间的线性插值来计算

Resample 重采样

<operator>,factor infile outfile

OperatorsTypeDescription
samplegrid,factorINTEGER对水平网格重采样,给定参数 factor 为 2 意味着网格点 2 个中取 1 个

Conditional Selection 条件切片

ifthen infile1 infile2 outfile
ifnotthen infile1 infile2 outfile

  • 描述
    从 infile2 中选择相对于 infile1 的字段元素输出到 outfile ;infile1 的字段个数必须与 infile2 相同,或与 infile2 的一个时间步相同,或仅为一个;

    ifthen

    ifnotthen

ifthenelse infile1 infile2 infile3 outfile

  • 描述
    从 infile2 和 infile3 中选择相对于 infile1 的字段元素输出到 outfile

ifthenc,c infile outfile
ifnotthenc,c infile outfile

  • 描述
    ifthenc

    ifnotthenc

  • 参数
    c,FLOAT,常量

  • 例子
    如果 infile 中对应的字段元素大于 0 ,则创建常量值为 7 的字段:

    1
    cdo ifthenc,7 infile outfile