# -*- coding: euc-jp -*-
require "numru/ggraph"
include NumRu

# added (07/19)
timestep  = ARGV[0].to_i

# 引数で渡そうと思ったがうまくいかない... 
IntegPeriod  = 4320000.0e0
#tn = 20
tn = 50
dt = IntegPeriod / tn
#IntegPeriod  = 432000.0e0
#tn = 2
#dt = IntegPeriod / tn

x1 = 0
x2 = 512000
#x2 = 500 * 1000 - 500 * 10
z1 = 0
z2 = 30000


#files = /thermal-moist_H2O-l-Rain_rank(\d\d\d\d\d\d).nc/
#gphys  = GPhys::IO.open(files, 'H2O-l-Rain')
#files = /thermal-moist_H2O-l-Rain_Fall_rank(\d\d\d\d\d\d).nc/
#gphys  = GPhys::IO.open(files, 'H2O-l-Rain_Fall')

files = /thermal-moist_VelZ_rank(\d\d\d\d\d\d).nc/
gphys  = GPhys::IO.open(files, 'VelZ')

#DCL.gropn(1)
DCL.gropn(2)
#DCL.sldiv('y',1,3)
DCL.sgpset('lfull',true)
DCL.sgpset('lcntl', false)
DCL.uzfact(0.7)
#DCL.uzfact(0.3)
GGraph.set_fig( 'viewport'=>[0.25,0.7,0.15,0.6] )
# アスペクト比をそれっぽくする
#GGraph.set_fig( 'viewport'=>[0.1,0.85,0.15,0.6] ) 
#GGraph.set_fig( 'viewport'=>[0.1,0.85,0.2,0.45] )

xax = gphys.coord(0)
#tax = gphys.coord(3)

#gphysdisp0 = -gphys
gphysdisp0 = gphys
gphysdisp0 = gphysdisp0.mean( 'y' )
gphysdisp0 = gphysdisp0.cut( 'z'=>4950 )
#gphysdisp0 = gphysdisp0.cut( 't'=>2e6..2.2e6 )
gphysdisp0 = gphysdisp0.cut( 't'=>dt*(timestep-1)..dt*timestep )
#gphysdisp0 = gphysdisp0.cut( 't'=>2.16e5*(timestep-1)..2.16e5*timestep )
gphysdisp  = gphysdisp0
gphysdisp.long_name = 'Vertical Velocity at z = 4950 m'

tax = gphysdisp.coord(1)  # <- gphysdisp は mean や cut して 2 次元になった

gphysdisp  = gphysdisp0
GGraph.fig( xax, tax, 'new_frame'=>true ) 

#GGraph.contour( gphysdisp, true )
#GGraph.tone( gphysdisp, true )
#GGraph.tone( gphysdisp, true,
GGraph.tone( gphysdisp, false,
#            'lev'=>[0,0.5e-3,1.0e-3,1.5e-3,2.0e-3,2.5e-3,3.0e-3,3.5e-3,4.0e-3,4.5e-3,5.0e3,5.5e-3,6.0e-3,6.5e-3,7.0e-3,7.5e-3],
#             # レベル＆パターンを陽に指定
#             'pat'=>[1,10999,15999,20999,25999,30999,35999,40999,45999,50999,60999,65999,70999,80999,90999]
#           降水量(デフォルト)
#            'lev'=>[1.0e-4,0.5e-3,1.0e-3,1.5e-3,2.0e-3,2.5e-3,3.0e-3,3.5e-3,4.0e-3,4.5e-3],
#           高度 500 m あたりでの水平風
#            'lev'=>[   -20.0,-15.0,-10.0,-5.0,  0,    5.0, 10.0, 15.0, 20.0 ],
            'lev'=>[   -20.0,-16.0,-12.0, -8.0,-4.0,  0,    4.0, 8.0,  12.0, 16.0, 20.0 ],
            'pat'=>[10999,15999,20999,25999,30999,40999,55999,70999,75999,80999,90999,95999]
###---------------------------------
###
### ゼロしろ
##
#            'pat'=>[1,10999,15999,20999,      30999,35999,40999,            55999,65999,70999,75999,80999,90999,95999] # 14 色
#            'pat'=>[1,10999,15999,20999,      30999,      40999,      50999,      60999,70999,75999,80999,90999]       # 12 色
# (降水量, 蒸発量)
#            'pat'=>[1,10999,      20999,      30999,      40999,            55999,65999,70999,75999,80999,90999]       # 11 色
###
### non ゼロしろ
##
# (エクスナー関数)
#            'pat'=>[  10999,15999,20999,25999,30999,35999,40999,45999,50999,      67999,70999,80999,85999,90999]
# (水平風, 鉛直風まま)
#            'pat'=>[  10999,15999,20999,25999,30999,      40999,            55999,      70999,75999,80999,90999,95999] # 12 色
# (地表面熱フラックス)
#            'pat'=>[  10999,15999,20999,25999,30999,      40999,            55999,65999,70999,      80999,90999]       # 11 色
#            'pat'=>[  10999,15999,20999,      30999,      40999,            55999,65999,70999,75999,80999,90999]       # 11 色
#            'pat'=>[  10999,      20999,      30999,      40999,            55999,65999,70999,75999,80999,90999]       # 10 色
###
### 試作中
##
# (水蒸気混合比まま)
#            'pat'=>[  10999,15999,20999,      30999,      40999,            55999,65999,70999,75999,80999,90999]       # 11 色
###
###
# (水蒸気混合比たまに)
#            'pat'=>[  10999,15999,20999,      30999,      40999,                  65999,70999,75999,80999,90999]       # 10 色
#            'pat'=>[  10999,15999,20999,      30999,      40999,                  65999,70999,75999,80999,90999]       # 9 色
###
###
### でふぉ
##
# (温度)
#            'pat'=>[  10999,12999,15999,20999,25999,30999,35999,40999,55999,65999,70999,75999,80999,90999,95999] # 15 色
)
GGraph.axes( xax, tax )
GGraph.title( gphysdisp.long_name )
GGraph.color_bar

DCL.grcls
