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

# added
timestep  = ARGV[0].to_i

# 引数で渡そうと思ったがうまくいかない... 
IntegPeriod  = 4320000.0e0
tn = 20
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_H2O-l-Rain_FallFluxAtLB_rank(\d\d\d\d\d\d).nc/
#gphys  = GPhys::IO.open(files, 'H2O-l-Rain_FallFluxAtLB')
#files = /thermal-moist_H2O-g_SfcMassFlux_rank(\d\d\d\d\d\d).nc/
#gphys  = GPhys::IO.open(files, 'H2O-g_SfcMassFlux')
#files = /thermal-moist_SfcHeatFlux_rank(\d\d\d\d\d\d).nc/
#gphys  = GPhys::IO.open(files, 'SfcHeatFlux')
#files = /thermal-moist_VelX_rank(\d\d\d\d\d\d).nc/
#gphys  = GPhys::IO.open(files, 'VelX')
#files1 = /thermal-moist_ExnerAll_rank(\d\d\d\d\d\d).nc/
#gphys1  = GPhys::IO.open(files1, 'ExnerAll')
#files2 = /thermal-moist_PTempAll_rank(\d\d\d\d\d\d).nc/
#gphys2  = GPhys::IO.open(files2, 'PTempAll')
files = /thermal-moist_H2O-gAll_rank(\d\d\d\d\d\d).nc/
gphys  = GPhys::IO.open(files, 'H2O-gAll')


#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 = gphys1.coord(0)
#tax = gphys1.coord(3)

#gphysdisp0 = -gphys
gphysdisp0 = gphys
#gphysdisp0 = gphys1 * gphys2
gphysdisp0 = gphysdisp0.mean( 'y' )
gphysdisp0 = gphysdisp0.cut( 'z'=>1950 )
#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 = 'H2O-gAll at z = 1050 m'

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

gphysdisp = gphysdisp0
#GGraph.fig( xax, zax, 'new_frame'=>false, 
#GGraph.fig( xax, tax, 'new_frame'=>true ) 
#            'viewport'=>[0.25,0.9,vpy1,vpy2], 'window'=>[x1,x2,z1,z2] )
#            'viewport'=>[0.1,0.9,0.1,0.8], 'window'=>[x1,x2,z1,z2] )


#GGraph.contour( gphysdisp, true )
GGraph.tone( gphysdisp, true )
#GGraph.tone( gphysdisp, false )
#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]
#           高度 500 m あたりでの水蒸気混合比
#            'lev'=>[ 0,  3e-3, 6e-3, 9e-3, 12e-3,15e-3,18e-3,21e-3,24e-3,27e-3,30e-3],
#            'lev'=>[ 0,  4e-3, 6e-3, 8e-3,10e-3,12e-3,14e-3,16e-3,18e-3,20e-3,22e-3],
#            'lev'=>[  17e-3,17.6e-3,18.2e-3,18.8e-3,19.4e-3,20e-3,20.6e-3,21.2e-3,21.8e-3,22.4e-3],
#            'pat'=>[10999,15999,20999,  30999,  40999,   65999,70999,  75999,80999,90999]
#            'lev'=>[  4e-3, 6e-3, 8e-3, 10e-3, 12e-3,14e-3,16e-3,18e-3,20e-3,22e-3],
#            'pat'=>[10999,20999,30999,40999,55999,65999,70999,75999,80999,90999]       # 10 色
#           水蒸気混合比 at 全時刻全高度統一 ver.
#            'lev'=>[ 0,  4e-3, 6e-3, 8e-3, 10e-3, 12e-3,14e-3,16e-3,18e-3,20e-3,22e-3], 
#            'pat'=>[1,10999,15999,20999,30999,40999,55999,65999,70999,75999,80999,90999]       # 12 色
###---------------------------------
###
### ゼロしろ
##
#            'pat'=>[1,10999,15999,20999,      30999,35999,40999,            55999,65999,70999,75999,80999,90999,95999] # 14 色
# (水蒸気混合比(統一))
#            'pat'=>[1,10999,15999,20999,      30999,      40999,            55999,65999,70999,75999,80999,90999]       # 12 色
#            '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( 'vlength'=>0.07, 'inffact'=>0.5 )
GGraph.color_bar
DCL.grcls

