#!/usr/bin/env ruby

require "numru/ggraph"      # ggraph library
require "numru/gphys"      # ggraph library
include NumRu

# file

file_d = "../nc/arare-odaka1998-dx100-20050811.nc"  # output netCDF file (disturb field value)
file_b = "../nc/arare-odaka1998-dx100-init.rc"  # output netCDF file (basic field value)

# definition of constant value

Sfctemp = 270.0 # ground tempareture [K]
Min = 230       # minimum value of axis
Max = 275       # maximum value of axis

# GPhys object initialization

gp_pottemp_d = GPhys::IO.open(file_d, "PotTemp")
gp_pottemp_b = GPhys::IO.open(file_b, "PotTempBasicZ")

# uniform array size and dimension

gp_pottemp_b = gp_pottemp_b.cut('x'=>0..25600, 'z'=>0..10000)
gp_pottemp_d = gp_pottemp_d.cut('x'=>0..25600, 'z'=>0..10000)

# draw

DCL.gropn(1)
DCL.sgpset('lcntl', false)
DCL.uzfact(0.7)

for i in 0..6

  time = 7200.0 * (6 - i)

  gp_pottemp = gp_pottemp_b + gp_pottemp_d.cut('t'=>time)
  gp_pottemp = gp_pottemp.mean('x')

  if i==0 then
    GGraph.line( gp_pottemp, true, 'exchange'=>true, 'min'=>Min, 'max'=>Max )
  else
    GGraph.line( gp_pottemp, false, 'exchange'=>true )
  end
  
end

DCL.grcls
