• CDO学习1 CDO简介


    参考自如下网站 

    http://www.ceda.ac.uk/static/media/uploads/ncas-reading-2015/cdo.pdf

    介绍

    • 一个有几百种操作符的单独命令
    • CDO受NCO启发,通过命令行,提供了一系列的气候数据相关的操作
    • 主要是被设计用在操作netCDF3/4,GRIB1/2
    • 众多的函数可以被用在任何NetCDF/格点化数据
    • 非常适合与特定任务
    • 有效的调动内存

    CDO:一个命令行工具

    $ cdo <operator> [options] <files>

    CDO操作的类别

    1. 文件信息和文件操作符
    2. 选择和比较
    3. 元数据的修改
    4. 算术操作符
    5. 统计分析
    6. 回归和内插
    7. 矢量和谱转换
    8. 格式化I/O
    9. 气候指数

    众多操作符

    CDO将其的功能分解成单独的操作符

    当前(2015年)有超过650个操作符。如

    showstdname Show standard names

    sellonlatbox Select a longitude/latitude box

    setmissval Set a new missing value

    monadd Add monthly time series

    zonstd Zonal standard deviation

    eca_hd Heating degree days per time period

    得到操作符的参考

    如需参考,只需输入:cdo -h <operator>

     操作符:1.文件信息

     $ cdo infov ifile 

    这是一个带有一个2D变量的数据集的示例结果,包括3个时间步长:

    -1 : Date Time Varname Level Size Miss : Minimum Mean Maximum
    1 : 1987?01?31 12:00:00 SST 0 2048 1361 : 232.77 266.65 305.31
    2 : 1987?02?28 12:00:00 SST 0 2048 1361 : 233.64 267.11 307.15
    3 : 1987?03?31 12:00:00 SST 0 2048 1361 : 225.31 267.52 307.67
    $ cdo showtimestamp ggas2014121200_00-18.nc
    2014-12-12T00:00:00 2014-12-12T06:00:00 2014-12-12T12:00:00 2014-12-12T18:00:00
    $ cdo pardes ggas2014121200_00-18.nc
    -1 CI Sea-ice cover [(0 - 1)]
    -2 SSTK Sea surface temperature [K]
    -3 MSL Mean sea-level pressure [Pa]
    -4 TCC Total cloud cover [(0 - 1)]
    -5 U10 10 metre U wind component [m s**-1]
    -6 V10 10 metre V wind component [m s**-1]
    -7 SKT Skin temperature [K]

    很容易看到2个文件之间数值差异的概况:

    $ cdo diff tas_rcp45_2055_ann_95p_change.nc tas_rcp45_2055_ann_05p_change.nc
    Date Time Param Level Size Miss : S Z Max_Absdiff Max_Reldiff
    1 : 2065-12-30 12:00:00 -1 0 64800 0 : T F 16.693 0.99997
    1 of 1 records differ

    操作符的所有文件列表包括

    • 赋值和连接
    • 合并场和时间
    • 按变量/层次/格点/时间分割场

    一些例子

    To copy a file and convert the output to NetCDF:

     $ cdo −f nc copy ifile ofile.nc 

    To merge all files along the time axis:
     $ cdo mergetime ifile1 ifile2 ifile3 ofile 

    可以用一些不同的方法选择数据包括:

    • 变量码,名称或者属性
    • 层次
    • 时间
    • 空间区域(纬度/经度)

     

    操作符:2.选择

    用id选择变量:“SSTK”和"CI":

     $ cdo selname,SSTK,CI infile.nc outfile.nc 

    To select a lat/lon bounding box:
     $ cdo sellonlatbox,120,-90,20,-20 infile.nc outfile.nc 

    To select a date/time range:
     $ cdo seldate,2014-12-12T12:00:00, 2015-01-31T18:00:00 infile.nc outfile.nc 

     

    操作符:3.修改

    设置时间轴到198701-16 12:00, 时间增量一个月增量 使用

     $ cdo settaxis,1987-01-16,12:00,1mon ifile ofile 

    将一个2维场纬度从N到S反转成S到N

     $ cdo invertlat ifile ofile 

     

    操作符:4.算术

    计算所有场元素的平方根:

     $ cdo sqrt ifile ofile 

    将所有输入场加入一个常数-273.15:

     $ cdo -addc,-273.15 ifile ofile 

     

    操作符:5.统计

    计算所有输入场的纬向平均:

     $ cdo zonmean ifile ofile 

    假设输入数据集具有数年的月度平均值。 为了从月度计算季节性均值,必须跳过前两个月:Assume an input dataset has monthly means over several years. In order to compute seasonal means from monthly means the first two months must be skipped:

     $ cdo timselmean,3,2 ifile ofile 

    多年逐日滑动百分值:

    • 为了计算一个百分值,必须知道最小和最大边界。

     $ cdo ydrunpctdl,p,nts infile minfile maxfile outfile 

    该运算符写滑动的百分值对于一年中的每一天,从infile写到outfile。最小和最大边界用minfile和maxfile提供。

    计算一个对年逐日的滑动百分率值,需要执行多步。

    $ cdo ydrunmin,5 ifile minfile
    $ cdo ydrunmax,5 ifile maxfile
    $ cdo ydrunpctl,90,5 ifile minfile maxfile ofile

    操作符:6 内插

    为了将所有场线性插值到一个T42高斯格点。

     $ cdo remapbil,t42grid ifile ofile 

    为了将混合模式层数据插值到气压层925,850,500和200 hPa

     $ cdo ml2pl,92500,85000,50000,20000 ifile ofile 

    操作符:9 气候指数

    得到一个逐日降水总量时间序列找那个连续干日的最大数目。

     $ cdo eca_cdd rrfile ofile 

    其中rrfile是逐日降水总量RR的时间序列,然后统计了连续天数的最大值,当RR小于1 mm时。

    为了得到热带夜晚一个时间序列逐日最小温度

     $ cdo eca_tr tnfile ofile 

    其中tnfile是逐日最低温度TN的时间序列,随后统计的是当TN>T时候的天数。T是一个可选的参数,其缺省值T=20℃。

     

    除此之外CDO还能做什么? CDO有许多通用的命令行开关,可以与(大多数)运算符一起使用。 这是一个选择:

    -a 生成绝对时间轴Generate an absolute time axis
    -f <format> 指定格式Specify format ("grb", "nc", "nc4" etc)
    -m <val> 设置默认缺测值Set the default missing value
    -Q 对netCDF变量名排序Sort netCDF variable names
    -r 生成相对时间轴Generate a relative time axis
    -s 静默模式Silent mode
    -V Version of CDO
    -v Verbose - print extra details.
    -z zip Deflate compression of netCDF4 vars.

     

    组合运算符

    所有的运算符都有一个固定的输入流和一个输出流,可以直接将结果管道给其它的操作符。这个操作符必须以“-”开始,为了和其它相结合。可以通过一下,来促进性能:

    • 减少不必要的磁盘I/O
    • 并行执行

    例如,我们可以把

    $ cdo timavg ifile1 tmp1
    $ cdo dayavg ifile2 tmp2
    $ cdo sub tmp2 tmp1 ofile
    $ rm tmp1 tmp2

    替换成

    $ cdo sub -dayavg ifile2 -timavg ifile1 ofile

    组合运算符:例子2

    以下三个命令是计算一个多年逐日滑动百分率,需要多步:

    $ cdo ydrunmin,5 ifile minfile
    $ cdo ydrunmax,5 ifile maxfile
    $ cdo ydrunpctl,90,5 ifile minfile maxfile ofile

    可以通过一个简单的命令替换

    $ cdo ydrunpctl,90,5 ifile -ydrunmin ifile -ydrunmax ifile ofile

    更多信息 

    CDO User Guide: https://code.mpimet.mpg.de/projects/cdo/embedded/cdo.pdf

    CDO Home page:  https://code.zmaw.de/projects/cdo

    CDO Tutorial:  https://code.zmaw.de/projects/cdo/wiki/Tutorial

    CDO Documentation:  https://code.zmaw.de/projects/cdo/wiki#Documentation

  • 相关阅读:
    哈工大《机器学习》最小二乘法曲线拟合——实验一
    最小二乘法曲线拟合以及matlab实现
    Dubbo简介
    Redis持久化策略
    Linux安装Redis
    RabbitMQ-Demo
    RabbitMQ安装相关
    SpringCloud-Alibaba-Nacos-Demo
    Nacos_启动失败原因
    IDEA中properties中文显示乱码
  • 原文地址:https://www.cnblogs.com/jiangleads/p/11145774.html
Copyright © 2020-2023  润新知