#!/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

==USAGE

  draw_thetaprof.rb basfile disfile

  * ARGUMENTS
    * basfile: $B4pK\>l%U%!%$%k(B
    * disfile: $B>qMp>l%U%!%$%k(B

=end


require "numru/ggraph"      # ggraph library
include NumRu

# file

#file_b = ARGV[0]  # output netCDF file (disturb field value)
#file_d = ARGV[1]  # output netCDF file (basic field value)
file_d = ["nc/arare-odaka1998-dx100-20051130.nc",  
          "nc/arare-odaka1998-dx100-20051130-2.nc"]  
file_b = "nc/arare-odaka1998-dx100-20051130-init.nc" 

# definition of constant value

Sfctemp = 270.0 # ground tempareture [K]
Min = 225       # minimum value of axis
Max = 275       # maximum value of axis
Inittime = 0         # initial time
Interval = 7200.0   # time interval
Linenum = 12
Xmin = 0       # minimum value of x-region
Xmax = 51200   # 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..Linenum

  time = Inittime + Interval * i

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

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

DCL.grcls
