2018.10.05 [研究メモ] nc2bin :: NOAA OLR (scale_factor add_offsetに注意)

NOAA のOLRをnetcdfからplain binaryに変換.
ちょっとまだ良く分からないが,sdfopenと普通のopenは,時間やZの次元が共通化されていないので,時間平均などは一緒に書けない???

データ:
https://www.esrl.noaa.gov/psd/data/gridded/data.interp_OLR.html

落とし穴:: ”scale_factor” or “add_offset” を含むnetcdfは要注意!


正解(ctlopen)


*****************************************************
* create ctl file before using “q ctlfile”
*****************************************************
*dset olr.mon.mean.nc
*title Monthly means of OLR from interpolated OLR dataset
*undef -9.99e+33
*UNPACK scale_factor add_offset
*OPTIONS yrev
*dtype netcdf
*xdef 144 linear 0 2.5
*ydef 73 linear -90 2.5
*zdef 1 linear 0 1
*tdef 512 linear 00Z01JUN1974 1mo
*vars 1
*olr=>olr 0 t,y,x OLR monthly means
*endvars
*****************************************************
*notes:  following descriptions should be added manually
*”UNPACK scale_factor add_offset”
*”OPTIONS yrev”
*****************************************************
‘open ./ctlopen.ctl’
‘set clevs 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300’
‘d ave(olr,t=1,t=512)’


失敗(sdfopen)


‘sdfopen ./olr.mon.mean.nc’
‘set clevs 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300’
‘d ave(olr,t=1,t=512)’

上がctlopen(正解), 右がsdfopen(間違い)

 

sdfopenからでもctlopen相当量は作れるはずなのだが,どうやるかはまだ不明.
単純なscale_factorの掛け算などでは実現できなさそう.


*’sdfopen ./olr.mon.mean.nc’
‘open ctlopen.ctl’

’q ctlinfo’
‘q dims’
‘set x 1 144’
*** since x=145 ==> lon=360
‘set y 1 73’
‘set z 1 1’
‘set t 1 512’
‘set undef -999’
‘set gxout fwrite’
‘set fwrite -be olr.bin’
* be :: big_endiann
* le :: little_endian

‘d olr’

return


 

参考:
http://ccsr.aori.u-tokyo.ac.jp/~obase/grads-scripts.html

  • kotsuking
  • 関東の某国立大学、教授。他に、JST・さきがけ研究員、理研・客員研究員、気象予報士。京都大学大学院で博士(工学)を取得。
    スーパーコンピューターを駆使して天気予報の改善に取り組むデータ同化研究者。座右の書は「7つの習慣」。

コメントする

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です