#!/usr/bin/env ruby

require "numru/ggraph"      # ggraph library
include NumRu

# file

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

# definition of constant value

Sfctemp = 270.0 # ground tempareture [K]
Min = 240       # 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(4)
DCL.sgpset('lcntl', false)
DCL.uzfact(0.7)

for i in 0..2

  time = 1800.0 * (2 - 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
