require "numru/ggraph"
include NumRu

#DCL.gropn(2)
DCL.gropn(4)
#DCL.gropn(1)

gphys1 = GPhys::IO.open('../../netCDF/thermal-moist_H2O-s-Cloud.nc', 'H2O-s-Cloud')
#gphys2 = GPhys::IO.open('arare-earth_BasicZ.nc', 'H2O-s-CloudBasicZ')

# 引き数を置き変える
tn = ARGV[0].to_i
dt = ARGV[1].to_i

# 定数の設定確認
#print tn
#printf ("\n")
#print dt     #, tmin, tmax
#printf ("\n")

######################################################################
# Draw (Total PotTemp) - (Total PotTemp's x heikin) with contor      #
######################################################################
#  GGraph.contour( ( ( gphys1 ).cut(true, true, tn*86400  ) + gphys2 )  -  ( ( gphys1 ).cut(true, true, tn*86400 ).mean( 'x' ) + ( gphys2 ).mean( 'x' ) ) )

######################################################################
# トーンの level を固定する
# ひとまず外しておく
######################################################################
# 今関さんスクリプト (雲水混合比の絵をかく用) からぱくってきたもの
#GGraph.set_tone_levels( 'levels'=>[0,0.0001,0.0002,0.0003,0.0004,0.0005,0.0006,0.0008,0.001,0.0015,0.002,0.0025,0.0036],'patterns'=>[13999,15999,20999,27999,39999,50999,69999,73999,76999,79999,86999,92999,96999] )
# 下限を -3.0e-4, 上限を 8.0e-4 とした
#GGraph.set_tone_levels( 'levels'=>[-0.0003,-0.0002,-0.0001,0,0.00005,0.0001,0.0002,0.0003,0.0004,0.0005,0.0006,0.0007,0.0008],'patterns'=>[13999,15999,20999,27999,39999,50999,69999,73999,76999,79999,86999,92999,96999] )

# 下限を 0, 上限を 8.0e-4 とした
GGraph.set_tone_levels( 
  'levels'=>[0,0.00006,0.00012,0.00018,0.00024,0.0003,0.00036,0.00042,0.00048,0.00054,0.0006,0.0007,0.0008],
  'patterns'=>[13999,15999,20999,27999,39999,50999,69999,73999,76999,79999,86999,92999,96999] )

######################################################################
# total の雲水混合比を描画する (カラー)
######################################################################
  DCL.sgpset('lcntl', false)
#  GGraph.tone( ( ( gphys1 ).cut(true, true, tn*dt) + gphys2 )  -  ( ( gphys1 ).cut(true, true, tn*dt).mean( 'x' ) + ( gphys2 ).mean( 'x' ) ) )
  GGraph.tone( ( gphys1 ).cut(true, y=100, true, tn*dt) ) 

###################################
# Draw side tone var              #
###################################
GGraph.color_bar("landscape"=>false,'labelintv'=>3)

DCL.grcls

