# coding: cp932
require "numru/ggraph"
include NumRu

plev = 500
z = GPhys::IO.open('hgt.2012-01.nc', 'hgt').cut('level'=>plev)
zc = GPhys::IO.open('ncep2.Jan.clim.1981-2010.nc', 'hgt').cut('level'=>plev)

iws= 1
DCL.sgscmn(4)                             # カラーマップ番号
DCL.gropn(iws)                            # iws : DCL出力デバイス．1,4:画面, 2:PS
DCL.sgpset('isub', 96)                    # 下付き添字制御文字を '_' から '`' に
DCL.glpset('lmiss',true)                  # DCLの欠損値処理を on に
GGraph.set_fig "itr"=>32,"viewport"=>[0.15,0.85,0.15,0.85]  # 32:正距方位図法
GGraph.set_map "coast_world"=>true
(16..26).step(5) do |d0|                  # 2012年1月の日付でループ
  t0 = DateTime.new(2012,1,d0)            # 2012-01-d0 00UTC (時刻指定省略のため)
  t1 = t0 + 4.9                    # 5日間の終わり(データは毎正時なので +4 でも可)
  zp = z.cut("time"=>t0..t1).mean("time") # 半旬(5日)平均
  zpd = zp - zc                           # 気候値からのずれ
  GGraph.tone zpd,true,"max"=>500,"min"=>-500,
     "annot"=>false,  # 右脇のアノテーション非表示
     "title"=>"Z#{plev}  #{t0.strftime('%Y/%m/%d')}-#{t1.strftime('%d')}"
  GGraph.contour zp,false,"int"=>100
  GGraph.color_bar
end
DCL.grcls
