#!/usr/bin/env ruby
=begin

=draw_thetaprof.rb

  * $B?eJ?J?6Q$7$?290L$N1tD>%W%m%U%!%$%k$r0lDj;~4V4V3V$GIA$/(B
  * $B4pK\>l%U%!%$%k(B($B=i4|CM%U%!%$%k(B or $B%j%9%?!<%H%U%!%$%k(B)$B$*$h$S(B
    $BM=JsJQ?t=PNO%U%!%$%k$,I,MW(B

=end


require "numru/ggraph"      # ggraph library
include NumRu

# file

file_d = "arare-odaka1998-dx200-20050918.nc"  # output netCDF file (disturb field value)
file_b = "arare-odaka1998-dx200-20050918-init.nc"  # 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
Interval = 3600.0   # time interval
Xmin = 0       # minimum value of x-region
Xmax = 25600   # maximum value of x-region
Zmin = 0       # minimum value of z-region
Zmax = 10000   # maximum value of z-region

# 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'=>Xmin..Xmax, 'z'=>Zmin..Zmax)
gp_pottemp_d = gp_pottemp_d.cut('x'=>Xmin..Xmax, 'z'=>Zmin..Zmax)

# draw

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

for i in 0..6

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