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

#timestep  = ARGV[0].to_i

x1 = 0
x2 = 256000
#x2 = 512000
#x2 = 500 * 1000 - 500 * 10
z1 = 0
#z2 = 30000
#z2 = 48000
t2 = 86400 * 50

t2 = ARGV[0].to_i

files1 = 'thermal-moist_PressAll.nc'
gphys1 = GPhys::IO.open(files1, 'PressAll')
#files2 = 'thermal-moist_PressAll-20121219-Default_z48km.nc'
#gphys2 = GPhys::IO.open(files2, 'PressAll')
#files2 = 'thermal-moist_PressAll_TET_CtlPress_atSfcFlux_x256km_z48km.nc'
#gphys2 = GPhys::IO.open(files2, 'PressAll')
#files2 = 'thermal-moist_PressAll2.nc'
#gphys2 = GPhys::IO.open(files2, 'PressAll')
#files2 = 'thermal-moist_PressAll_z24km.nc'
#gphys2 = GPhys::IO.open(files2, 'PressAll')
#files3 = 'thermal-moist_PressAll_z36km.nc'
#gphys3 = GPhys::IO.open(files3, 'PressAll')
#files4 = 'thermal-moist_PressAll_z48km.nc'
#gphys4 = GPhys::IO.open(files4, 'PressAll')


#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.25,0.8,0.10,0.275] )

#gphysdisp0 = gphys
gphysdisp0 = gphys1
gphysdisp0 = gphysdisp0.mean( 'x' )
gphysdisp0 = gphysdisp0.mean( 'y' )
gphysdisp0 = gphysdisp0.cut( 'z'=>150 )
gphysdisp0 = gphysdisp0.cut( 't'=>0..t2 )
#gphysdisp  = gphysdisp0
gphysdisp1 = gphysdisp0

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

#gphysdisp0 = gphys3
#gphysdisp0 = gphysdisp0.mean( 'x' )
#gphysdisp0 = gphysdisp0.mean( 'y' )
#gphysdisp0 = gphysdisp0.cut( 'z'=>150 )
#gphysdisp0 = gphysdisp0.cut( 't'=>0..t2 )
##gphysdisp  = gphysdisp0
#gphysdisp3 = gphysdisp0
#
#gphysdisp0 = gphys4
#gphysdisp0 = gphysdisp0.mean( 'x' )
#gphysdisp0 = gphysdisp0.mean( 'y' )
#gphysdisp0 = gphysdisp0.cut( 'z'=>150 )
#gphysdisp0 = gphysdisp0.cut( 't'=>0..t2 )
##gphysdisp  = gphysdisp0
#gphysdisp4 = gphysdisp0

#GGraph.contour( gphysdisp, true, 'transpose'=>true )
#GGraph.line( gphysdisp, true, 'min' => 0.956, 'max' => 0.996 )

# とりあえず一本だけ描画
#GGraph.line( gphysdisp1, true )

# 高度各々描画
#GGraph.line( gphysdisp2, true, 'min' => 0.90, 'max' => 0.996, 'type'=>4 )
#GGraph.line( gphysdisp1, false, 'min' => 0.90, 'max' => 0.996, 'type'=>3 )
#GGraph.line( gphysdisp3, false, 'min' => 0.90, 'max' => 0.996, 'type'=>2 )
#GGraph.line( gphysdisp4, false, 'min' => 0.90, 'max' => 0.996, 'type'=>1 )

# 二本並べる
#GGraph.line( gphysdisp1, true, 'min' => 0.960, 'max' => 0.996, 'type'=>1 )
#GGraph.line( gphysdisp2, false, 'min' => 0.960, 'max' => 0.996, 'type'=>2 )
#GGraph.line( gphysdisp1, true, 'min' => 86000, 'max' => 94000, 'type'=>1 )
#GGraph.line( gphysdisp2, false, 'min' => 86000, 'max' => 94000, 'type'=>2 )

# とりあえず一本だけ描画
GGraph.line( gphysdisp1, true, 'min' => 86000, 'max' => 94000, 'type'=>1 )


DCL.grcls
