# -*- coding: euc-jp -*-
# Title: Ruby script drawing contour map for deepconv/arare5 output data 
#
# History: 2011/09/27 (Masatsugu Odaka)
#
require "numru/ggraph"
include NumRu

#file0 = 'BS1998_restart_rank000000.nc'
file0 = 'restart_long-PTempBZ.nc'
filehead = "BS1998_"
filedir = "../time_000100000-000150000"
cuttime = 100000..150000 #..2080000
ptemp_file0   = "#{filedir}/#{filehead}PTemp_rank000000.nc"
#ptemp_file1   = "#{filedir}/#{filehead}PTemp_rank000001.nc"
#ptemp_file2   = "#{filedir}/#{filehead}PTemp_rank000002.nc"
#ptemp_file3   = "#{filedir}/#{filehead}PTemp_rank000003.nc"
#ptemp_file4   = "#{filedir}/#{filehead}PTemp_rank000004.nc"
#ptemp_file5   = "#{filedir}/#{filehead}PTemp_rank000005.nc"
ptemp = GPhys::IO.open(ptemp_file0, "PTemp" )
varname0 = 'PTempBZ'

ptemp = ptemp.cut('t'=>cuttime)

comax = 250.0
comin = 228.0
var0  = GPhys::IO.open(file0, varname0)


# <Open DCL>
DCL.swlset( 'ldump', true )
DCL.gropn(4)
#var0 = var0[5..104,0..-1,5..104]

VarAll = ptemp + var0

#VarAll = var1.cut(true,true,true,0.0) + var0[5..14,0..-1,5..124]
VarMean = VarAll.average('x').average('y')
GGraph.line( VarMean.cut('z'=>0), 
             true, 'exchange'=>false ,
             'index'=>2, 'type'=>1, 'label'=>'0km',
             'title'=>'Mean Potemtial Temp.',
             'max'=>comax, 'min'=>comin)    

GGraph.line( VarMean.cut('z'=>3000), 
             false, 'exchange'=>false ,
             'index'=>2, 'type'=>1, 'label'=>'3km',
             'title'=>'Mean Potemtial Temp.',
             'max'=>comax, 'min'=>comin)    
GGraph.line( VarMean.cut('z'=>6000), 
             false, 'exchange'=>false ,
             'index'=>2, 'type'=>1, 'label'=>'6km',
             'title'=>'Mean Potemtial Temp.',
             'max'=>comax, 'min'=>comin)    
GGraph.line( VarMean.cut('z'=>9000), 
             false, 'exchange'=>false ,
             'index'=>2, 'type'=>1, 'label'=>'9km',
             'title'=>'Mean Potemtial Temp.',
             'max'=>comax, 'min'=>comin)    
GGraph.line( VarMean.cut('z'=>12000), 
             false, 'exchange'=>false ,
             'index'=>2, 'type'=>1, 'label'=>'12km',
             'title'=>'Mean Potemtial Temp.',
             'max'=>comax, 'min'=>comin)    
GGraph.line( VarMean.cut('z'=>15000), 
             false, 'exchange'=>false ,
             'index'=>2, 'type'=>1, 'label'=>'15km',
             'title'=>'Mean Potemtial Temp.',
             'max'=>comax, 'min'=>comin)    
GGraph.line( VarMean.cut('z'=>18000), 
             false, 'exchange'=>false ,
             'index'=>2, 'type'=>1, 'label'=>'18km',
             'title'=>'Mean Potemtial Temp.',
             'max'=>comax, 'min'=>comin)    
GGraph.line( VarMean.cut('z'=>19000), 
             false, 'exchange'=>false ,
             'index'=>2, 'type'=>1, 'label'=>'19km',
             'title'=>'Mean Potemtial Temp.',
             'max'=>comax, 'min'=>comin)    
GGraph.line( VarMean.cut('z'=>20000), 
             false, 'exchange'=>false ,
             'index'=>2, 'type'=>1, 'label'=>'20km',
             'title'=>'Mean Potemtial Temp.',
             'max'=>comax, 'min'=>comin)    

# <Close DCL>
DCL.grcls
