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

#
# = 基本場をかくスクリプト
#
# * 対応 (予定) 物理量
#   * 温度
#   * 気圧
#   * 水蒸気混合比
#   * 湿度
#
# * 履歴
#   * 2013/02/05 更新
#   * 2013/01/24 新規作成
#
##########################################

var = ARGV[0]

x1 = 0
x2 = 256000
z1 = 0
z2 = ARGV[1].to_i

files = "thermal-moist_restart.nc"
gphysTempBZ  = GPhys::IO.open(files, 'TempBZ')
gphysPressBZ = GPhys::IO.open(files, 'PressBZ')
gphysHumBZ   = GPhys::IO.open(files, 'HumBZ')
gphysQMixBZ  = GPhys::IO.open(files, 'QMixBZ')

#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] )

gphysTempBZ = gphysTempBZ.cut( 'x'=>x1..x2 )
gphysTempBZ = gphysTempBZ.cut( 'z'=>z1..z2 )
gphysTempBZ = gphysTempBZ.mean( 'x' )
gphysTempBZ = gphysTempBZ.mean( 'y' )
gphysTempBZ = gphysTempBZ.cut( 'z'=>0..10000 )

gphysPressBZ = gphysPressBZ.cut( 'x'=>x1..x2 )
gphysPressBZ = gphysPressBZ.cut( 'z'=>z1..z2 )
gphysPressBZ = gphysPressBZ.mean( 'x' )
gphysPressBZ = gphysPressBZ.mean( 'y' )
gphysPressBZ = gphysPressBZ.cut( 'z'=>0..10000 )

gphysHumBZ = gphysHumBZ.cut( 'x'=>x1..x2 )
gphysHumBZ = gphysHumBZ.cut( 'z'=>z1..z2 )
gphysHumBZ = gphysHumBZ.mean( 'x' )
gphysHumBZ = gphysHumBZ.mean( 'y' )
gphysHumBZ = gphysHumBZ.cut( 'z'=>0..10000 )

gphysQMixBZ = gphysQMixBZ.cut( 's'=>1 )
gphysQMixBZ = gphysQMixBZ.cut( 'x'=>x1..x2 )
gphysQMixBZ = gphysQMixBZ.cut( 'z'=>z1..z2 )
gphysQMixBZ = gphysQMixBZ.mean( 'x' )
gphysQMixBZ = gphysQMixBZ.mean( 'y' )
gphysQMixBZ = gphysQMixBZ.cut( 'z'=>0..10000 )

#gphysdisp = gphysdisp1

if var == "Temp"
    gphysdisp = gphysTempBZ
  elsif var == "Press"
    gphysdisp = gphysPressBZ
  elsif var == "Hum"
    gphysdisp = gphysHumBZ
  elsif var == "H2Og" or var == "H2O-g"
    gphysdisp = gphysQMixBZ
  else
    p "No such variables."
end

GGraph.line( gphysdisp, true, 'exchange'=>true ) 

DCL.grcls
