#!/usr/bin/env ruby
=begin

=draw_energy.rb

  * $B%(%M%k%.!<$N;~4VJQ2=$N@^$l@~?^$rIA$/(B
  * $B=i4|$N%(%M%k%.!<$KBP$9$kHf$rIA$$$F$$$k(B

=end

require "numru/ggraph"
require "numru/dcl"

include NumRu

file = ARGV[0]
#file = "./arare_diag-odaka1998-dx200-20050917.nc" 

# open file and initialize GPhys object

gp_rad = GPhys::IO.open(file, "EnergyTendRadTotal")
gp_dis = GPhys::IO.open(file, "EnergyTendDisTotal")
gp_sfh = GPhys::IO.open(file, "EnergyTendSfcHeatFluxTotal")
gp_sfm = GPhys::IO.open(file, "EnergyTendSfcMomentumFluxTotal")
gp_ncs = GPhys::IO.open(file, "EnergyTendNonconsvTotal")
gp_tbh = GPhys::IO.open(file, "EnergyTendPotTempTurbTotal")
gp_tbm = GPhys::IO.open(file, "EnergyTendVelTurbTotal")
gp_bsf = GPhys::IO.open(file, "EnergyTendPotTempBasicTotal")

gp_total = gp_rad + gp_dis + gp_sfh + gp_sfm + gp_tbh + gp_tbm \
           + gp_ncs + gp_bsf

DCL.gropn(4)
DCL.sgpset("lcntl", false)
DCL.uzfact(0.7)
GGraph.line(gp_total, true, "index"=>13, "max"=>10.0e+4, "min"=>-5.0e+4)
GGraph.line(gp_rad, false, "index"=>33 )
GGraph.line(gp_dis, false, "index"=>63 )
GGraph.line(gp_sfh, false, "index"=>43 )
GGraph.line(gp_sfm, false, "index"=>43, "type"=>2 )
GGraph.line(gp_tbh, false, "index"=>73 )
GGraph.line(gp_tbm, false, "index"=>73, "type"=>2 )
GGraph.line(gp_ncs, false, "index"=>83 )
GGraph.line(gp_bsf, false, "index"=>133 )
DCL.grcls