CDO學習3 CDO 用戶指南User Guide


注:部分參考,全文請見https://code.mpimet.mpg.de/projects/cdo/embedded/cdo.pdf

1.2 用法

cdo [ Options ] Operator1 [ -Operator2 [ -OperatorN ] ]

1.2.1 選項

所有選項都需要放在第一個操作符之前。對於所有操作符,以下選項是可行的:

-a
      生成一個絕對時間軸Generate an absolute time axis.

 

-b <nbits>
      設置輸出經度的位數。合理的精度取決於文件格式:

格式 位數

grb1, grb2

nc1, nc2, nc4, nc4c

grb2, src, ext, ieg

P1 - P24

I8/I16/I32/F32/F64

F32/F64

      對於srv, ext 和 ieg 格式,可以用字母L或B將位序分別設置為小端或大端。

 

- -cmor
      CMOR符合NetCDF輸出

 

-C, - -color
      彩色輸出消息

 

- -eccodes
      使用ecCodes來解碼/編碼GRIB1 messages

 

-f <format>
      設置輸出文件格式。合理的文件格式有:

文件格式 格式
GRIB version 1
GRIB version 2
NetCDF
NetCDF version 2 (64-bit offset)
NetCDF-4 (HDF5)
NetCDF-4 classic
NetCDF version 5 (64-bit data)
SERVICE
EXTRA
IEG

grb1/grb
grb2
nc1
nc2/nc
nc4
nc4c
nc5
srv
ext
ieg

GRIB2僅適用於,如果cdo編譯時啟用了ecCodes支持,並且所有的NetCDF文件支持需要在編譯時開啟NetCDF支持才可用!

 

-g <grid>
      定義默認格點描述以名稱或者從文件中(參見11頁1.3章)。可用的格點名稱有: r<NX>x<NY>, lon=<LON>/lat=<LAT>, n<N>, gme<NI>

 

-h, - -help
      關於操作符的幫助信息

 

- -no_history
      不要附加到NetCDF歷史全局屬性

 

- -netcdf_hdr_pad, - -hdr_pad, - -header_pad <nbr>
      使用nbr字節填充NetCDF輸出頭

 

-k <chunktype>
      NetCDF4塊類型:auto,grid或lines

 

-L
      I/O 鎖(順序訪問)

 

-M
      切換以指示I / O流具有缺測值。-m <missval>  設置非NetCDF文件的缺測值(默認值:-9e + 33)

 

-O
      如果選中,則覆蓋現有輸出文件。 僅檢查現有輸出文件:ens <STAT>,merge,mergetime

 

- -operators
      所有操作符的列表

 

-P <nthreads>
      設置OpenMP線程數(僅在編譯OpenMP支持時可用)

 

- -percentile <method>
      Percentile方法:nrank nist numpy numpy_lower numpy_higher numpy_nearest

 

- -reduce_dim
      減少NetCDF維度

 

-R, - -regular
      將GRIB1數據從global縮減轉換為常規高斯網格(僅限cgribex lib)

 

-r
      生成相對時間軸

-S
      為模塊TIMSTAT創建額外的輸出流。此流包含每個輸出時段的非缺失值的數量

-s, -silent
      無聲模式

- -sortname
      NetCDF參數名稱的字母數字排序

-t <partab>
      設置GRIB1(cgribex)默認參數表名稱或文件(請參閱第16頁的第1.6章)。預定義的表格是:echam4 echam5 echam6 mpiom1 ecmwf remo

 

 

- -timestat_date <srcdate>
      目標時間戳(時間統計):源數據時間步中的first, middle, midhigh 或者 last

 

-V, - -version
      打印版本號

 

-v, - -verbose
      為某些操作符打印額外的詳細信息

 

-W
      打印額外的警告信息

 

-z szip     SZIP壓縮GRIB1記錄
    jpeg    JPEG壓縮GRIB2記錄
    zip [_1-9]      縮小NetCDF4變量的壓縮率

1.2.3 操作符

有超過700個操作符。對於所有的操作符的一個詳細的描述可以在參考手冊一節找到。

1.2.4 操作符鏈

所有操作符有一個固定的輸入流和一個輸出流可以將結果直接管道到一個其它的操作符。操作符必須用“-”開頭,用以和其它操作符組合。這個可以通過以下操作提升性能:

  • 減少不必要的磁盤I/O
  • 並行處理

使用

cdo sub -dayavg infile2 -timavg infile1 outfile

而不是

cdo timavg infile1 tmp1
cdo dayavg infile2 tmp2
cdo sub tmp2 tmp1 outfile
rm tmp1 tmp2

所有的 單輸入流的操作符 將只會在輸入流中處理一次!將這些運算符 與一個 具有任意數量輸入流的運算符混合時,需要注意。 以下示例說明了此問題。

1. cdo info -timavg infile?
2. cdo info -timavg infile1 infile2
3. cdo timavg infile1 tmpfile
cdo info tmpfile infile2

這三個例子都產生相同的結果。 僅在第一個輸入文件上計算時間平均值。
如果這些運算符與多個輸入流一起使用,則具有任意數量的輸入流(infiles)的所有運算符都不能與其他運算符組合。 以下是這些運算符的不完整列表:
copy,cat,merge,mergetime,select,ens <STAT>
如果輸入流名稱與單個通配符表達式匹配,請使用單引號。 在這種情況下,CDO將進行模式匹配,輸出可以與其他運算符組合。 以下是此功能的示例:
cdo timavg -select,name=temperature ’infile?’ outfile

CDO內部通配符擴展使用glob()函數。 因此,沒有glob()函數的操作系統上不能使用內部通配符擴展! 支持以下通配符:
*,?,[]
注意:運算符鏈接是通過POSIX線程(pthreads)實現的。 因此,如果沒有POSIX Threads支持,此CDO功能在操作系統上不可用!

1.2.5 並行化操作符

一些CDO操作符可以用OpenMP共享內存並行化。要使用此功能,需要支持OpenMP的C編譯器。 用戶可以使用'-P'開關請求特定數量的OpenMP線程nthreads。

以下是在8個OpenMP線程上分布雙線性插值的示例:

cdo -P 8 remapbil,targetgrid infile outfile

許多CDO操作符受I/O約束。 這意味着大部分時間都花在閱讀和寫入數據上。 僅計算密集型CDO操作符是並行化的。 OpenMP並行化運算符的不完整列表可以在附錄B中找到。

附:B. Parallelized operators

The following CDO operators are parallelized with OpenMP:

Module Operator Description

Detrend

 detrend Detrend
Ensstat  ensmin Ensemble minimum
Ensstat  ensmax Ensemble maximum
Ensstat  enssum Ensemble sum
Ensstat  ensmean Ensemble mean
Ensstat  ensavg Ensemble average
Ensstat  ensvar Ensemble variance
Ensstat  ensstd Ensemble standard deviation
Ensstat  enspctl Ensemble percentiles
Filter  bandpass Bandpass filtering
Filter  lowpass Lowpass filtering
Filter  highpass Highpass filtering
Fourier  fourier Fourier transformation
Genweights  genbil Generate bilinear interpolation weights
Genweights  genbic Generate bicubic interpolation weights
Genweights  gendis Generate distance-weighted average remap weights
Genweights  gennn Generate nearest neighbor remap weights
Genweights  gencon Generate 1st order conservative remap weights
Genweights  gencon2 Generate 2nd order conservative remap weights
Genweights  genlaf Generate largest area fraction remap weights
Gridboxstat  gridboxmin Gridbox minimum
Gridboxstat  gridboxmax Gridbox maximum
Gridboxstat  gridboxsum Gridbox sum
Gridboxstat  gridboxmean Gridbox mean
Gridboxstat  gridboxavg Gridbox average
Gridboxstat  gridboxvar Gridbox variance
Gridboxstat  gridboxstd Gridbox standard deviation
Remapeta  remapeta Remap vertical hybrid level
Remap  remapbil Bilinear interpolation
Remap  remapbic Bicubic interpolation
Remap  remapdis Distance-weighted average remapping
Remap  remapnn Nearest neighbor remapping
Remap  remapcon First order conservative remapping
Remap  remapcon2 Second order conservative remapping
Remap  remaplaf Largest area fraction remapping

 1.2.6 操作符參數

一些操作符需要一個或多個參數。參數列表用分隔符','表示

  • 字符串
    不帶引號的字符不能包含有空格和tab。下面的命令利用變量名pressure和tsurf選擇了變量:
        cdo selvar,pressure,tsurf infile outfile
  • 浮點數
    浮點數可以用任何形式表示。下列的命令將0到273.15之間范圍的所有長設置成缺失值:
        cdo setrtomiss,0,273.15 infile outfile
  • 布爾類型
    布爾參數,需要如下所示:TRUE / FALSE,T / F 或 0/1。 在計算一個場的平均值時,要禁用網格單元格區域的權重,請使用:
        cdo fldmean,weights = FALSE infile outfile
  • 整數
    可以通過first / last [/ inc]指定一系列整數參數。 選擇第5天,第6天,第7天,第8天和第9天,可以使用:
        cdo selday,5/9 infile outfile
    使用以下命令結果相同:
        cdo selday,5,6,7,8,9 infile outfile

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM