CDO - 选择(切片)操作
本篇随笔将介绍 CDO 根据给定参数或条件进行选择和删除字段的功能
切片操作 Selection Operators
Select 切片
Select 相关的操作是根据所选择的参数列表或范围对输入数据集 infile 进行选择,并输出到输出数据集 outfile 中
列表的表示方式:a,b,c
范围的表示方式:first/last[/inc]
<operator>,parameter=<list/range> infiles outfile
| Operators | Description |
|---|---|
| select | 根据给定的参数列表选择字段 |
| delete | 根据给定的参数列表删除字段 |
| Parameters | Type | Description |
|---|---|---|
| name | STRING | 逗号分隔的变量 name 列表 |
| param | STRING | 逗号分隔的变量 ID 列表 |
| code | INTEGER | 逗号分隔的 code number 列表或 first/last[/inc] 表示的范围 |
| level | FLOAT | 逗号分隔的 levels 列表 |
| levrange | FLOAT | 逗号分隔表示的 levels 范围 |
| levidx | INTEGER | 逗号分隔的 levels index 列表或 first/last[/inc] 表示的 levels index 范围 |
| zaxisname | STRING | 逗号分隔的 z 轴名称列表 |
| zaxisnum | INTEGER | 逗号分隔的 zaxisID 列表或 first/last[/inc] 表示的 zaxisID 范围 |
| ltype | INTEGER | 逗号分隔的 GRIB level type 的列表或 first/last[/inc] 表示的范围 |
| gridname | STRING | 逗号分隔的网格名称(gridtype)列表 |
| gridnum | INTEGER | 逗号分隔的 gridID 列表或 first/last[/inc] 表示的 gridID 范围 |
| steptype | STRING | 逗号分隔的 timestep types 列表 |
| date | STRING | 逗号分隔的日期列表(YYYY-MM-DDThh:mm:ss) |
| startdate | STRING | 开始时间(YYYY-MM-DDThh:mm:ss) |
| enddate | STRING | 结束时间(YYYY-MM-DDThh:mm:ss) |
| minute | INTEGER | 逗号分隔的 minutes 列表或 first/last[/inc] 表示的 minutes 范围 |
| hour | INTEGER | 逗号分隔的 hours 列表或 first/last[/inc] 表示的 hours 范围 |
| day | INTEGER | 逗号分隔的 days 列表或 first/last[/inc] 表示的 days 范围 |
| month | INTEGER | 逗号分隔的 months 列表或 first/last[/inc] 表示的 months 范围 |
| season | STRING | 逗号分隔的 seasons 列表(DJFMAMJJASOND or ANN) |
| year | INTEGER | 逗号分隔的 years 列表或 first/last[/inc] 表示的 years 范围 |
| dom | STRING | 逗号分隔的日期列表(如:29feb) |
| timestep | INTEGER | 逗号分隔的时间步 timesteps 列表或 first/last[/inc] 表示的范围 |
| timestep_of_year | INTEGER | 逗号分隔的 timesteps of year 列表或 first/last[/inc] 表示的范围 |
| timestepmask | STRING | Read timesteps from a mask file |
<operator>,parameters infile outfile
| Operators | Type | Description |
|---|---|---|
| selparam,params | STRING | 根据参数给定的变量 ID 列表选择字段 |
| delparam,params | STRING | 根据参数给定的变量 ID 列表删除字段 |
| selcode,codes | INTEGER | 根据参数给定的 code number 列表或范围选择字段 |
| delcode,codes | INTEGER | 根据参数给定的 code number 列表或范围删除字段 |
| selname,names | STRING | 根据参数给定的变量 name 列表选择字段 |
| delname,names | STRING | 根据参数给定的变量 name 列表删除字段 |
| selstdname,stdnames | STRING | 根据参数给定的变量 standard_name 列表选择字段 |
| sellevel,levels | FLOAT | 根据参数给定的 levels 列表选择字段 |
| sellevidx,levidx | INTEGER | 根据参数给定的 levels index 列表或范围选择字段 |
| selgrid,grids | STRING | 根据参数给定的网格名称(gridtype)列表选择字段 |
| selzaxis,zaxes | STRING | 根据参数给定的 zaxistype 列表选择字段 |
| selzaxisname,zaxisnames | STRING | 根据参数给定的 z 轴名称列表选择字段 |
| selltype,ltypes | INTEGER | 根据参数给定的 GRIB level type 列表或范围选择字段 |
| seltabnum,tabnums | INTEGER | 根据参数给定的 parameter table numbers 列表或范围选择 |
| seltimestep,timesteps | INTEGER | 根据参数给定的时间步 timestep 列表或范围选择字段 |
| seltime,times | STRING | 根据参数给定的时间列表或范围选择字段(hh:mm:ss) |
| selhour,hours | INTEGER | 根据参数给定的 hours 列表或范围选择字段 |
| selday,days | INTEGER | 根据参数给定的 days 列表或范围选择字段 |
| selmonth,months | INTEGER | 根据参数给定的 months 列表或范围选择字段 |
| selyear,years | INTEGER | 根据参数给定的 years 列表或范围选择字段 |
| selseason,seasons | STRING | 根据参数给定的 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
| Operators | Type | Description |
|---|---|---|
| sellonlatbox,lon1,lon2,lat1,lat2 | FLOAT | 根据经纬度的值选择 [lon1, lon2] 和 [lat1, lat2] 区间的字段 |
| selindexbox,idx1,idx2,idy1,idy2 | INTEGER | 根据经纬度的索引选择 [idx1, idx2] 和 [idy1, idy2] 区间的字段 |
<operator>,indices infile outfile
| Operators | Type | Description |
|---|---|---|
| selgridcell,indices | INTEGER | 根据参数给定的 index of grid cell 列表或范围选择字段 |
| delgridcell,indices | INTEGER | 根据参数给定的 index of grid cell 列表或范围删除字段 |
<operator> infile1 infile2 outfile
| Operators | Description |
|---|---|
| selyearidx | 根据 infile1 的 年度指数(yearly indices) 从 infile2 中选择字段,yearly indices 可以由 yearminidx 和 yearmaxidx 这两个操作得出 |
<operator> infile outfile
| Operators | Description |
|---|---|
| bottomvalue | 对三维的变量,选择底层的字段 |
| topvalue | 对三维的变量,选择顶层的字段 |
| isosurface,isovalue | 对三维的变量,计算等值面;等值面的值由参数 isovalue 指定,通过两层之间的线性插值来计算 |
Resample 重采样
<operator>,factor infile outfile
| Operators | Type | Description |
|---|---|---|
| samplegrid,factor | INTEGER | 对水平网格重采样,给定参数 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