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

#timestep  = ARGV[0].to_i

x1 = 0
x2 = 256000
#x2 = 500 * 1000 - 500 * 10
z1 = 0
z2 = 48000
t1 = 0
t2 = ARGV[0].to_i
#t1 = 86400 * 49  # 29 日
#t2 = 86400 * 50  # 30 日

time = ARGV[1].to_i

files1 = "thermal-moist_TempAll.nc"
gphys1  = GPhys::IO.open(files1, 'TempAll')
files2 = "thermal-moist_restart.nc"
gphys2 = GPhys::IO.open(files2, 'TempBZ')

gphys2 = gphys2.cut( 'x'=>x1..x2 )
gphys2 = gphys2.cut( 'z'=>z1..z2 )

#DCL.gropn(1)
DCL.gropn(2)
#DCL.sldiv('y',1,2)
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] )  

#gphysdisp0 = gphys1
gphysdisp0 = gphys1 - gphys2
gphysdisp0 = gphysdisp0.mean( 'x' )
gphysdisp0 = gphysdisp0.mean( 'y' )
#gphysdisp0 = gphysdisp0.cut( 'z'=>0..10000 )
gphysdisp0 = gphysdisp0.cut( 't'=>t1..t2 )
#gphysdisp0 = gphysdisp0.mean( 't' )
gphysdisp0 = gphysdisp0.cut( 't'=>time )
gphysdisp1  = gphysdisp0

#gphysdisp0 = gphys2
#gphysdisp0 = gphysdisp0.mean( 'x' )
#gphysdisp0 = gphysdisp0.mean( 'y' )
##gphysdisp0 = gphysdisp0.cut( 'z'=>0..10000 )
#gphysdisp0 = gphysdisp0.cut( 't'=>t1..t2 )
#gphysdisp0 = gphysdisp0.mean( 't' )
#gphysdisp2  = gphysdisp0

GGraph.line( gphysdisp1, true, 'min' => -10.0, 'max' => 10.0, 'type'=>1, 'exchange'=>true )

#GGraph.line( gphysdisp1, true, 'min' => 180.0, 'max' => 300.0, 'type'=>1, 'exchange'=>true )
#GGraph.line( gphysdisp2, false, 'min' => 170.0, 'max' => 300.0, 'type'=>2, 'exchange'=>true )
#GGraph.line( gphysdisp1, true, 'min' => 230.0, 'max' => 300.0, 'type'=>1, 'exchange'=>true )
#GGraph.line( gphysdisp2, false, 'min' => 230.0, 'max' => 300.0, 'type'=>2, 'exchange'=>true )
#GGraph.line( gphysdisp, true )

DCL.grcls


###---------------------------------
###
### ゼロしろ
##
#            '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 色
###
###---------------------------------
