# 表題  make_zprof.rb
#
# 履歴  2007/10/14 小高正嗣
#
# 内容  温位の水平平均偏差データを作成する
#
require "numru/gphys"
require "numru/ggraph"
include NumRu

InputFile1='2dMars_dx200dz100_Zprof.nc'
InputFile2='2dMars_dx200dz100_PotTempMean.nc'

Day = 86400.0

# データの読み込み
#
Adv  = GPhys::NetCDF_IO.open(InputFile1, 'PotTempAdv' )
Turb = GPhys::NetCDF_IO.open(InputFile1, 'PotTempTurb')
Disp = GPhys::NetCDF_IO.open(InputFile1, 'PotTempDisp')
Rad  = GPhys::NetCDF_IO.open(InputFile1, 'PotTempRad' )
Diff = GPhys::NetCDF_IO.open(InputFile1, 'PotTempDiff')
Flux = GPhys::NetCDF_IO.open(InputFile1, 'PotTempFlux')
Damp = GPhys::NetCDF_IO.open(InputFile1, 'PotTempDamp')
PotTempMean = GPhys::NetCDF_IO.open(InputFile2, 'PotTemp')

# K/sec から K/day に単位を変換
#
Adv  = Adv*Day
Turb = (Turb+Flux)*Day
Rad  = Rad*Day
#Disp = Disp*Day
#Diff = Diff*Day
Damp = Damp*Day


DCL::swpset('LDUMP', true)
DCL.gropn(4)

# 加熱率
#
GGraph.set_axes( 'xtitle'=>'', 'xunit'=>'K/day' )

GGraph.line( Adv.cut('t'=>86400.0), 
             true, 'max'=>100, 'min'=>-100, 
             'index'=>23, 'label'=>'adv',
             'title'=>'Heating rate',
             'exchange'=>true )

GGraph.line( Rad.cut('t'=>864200.0), false, 
             'index'=>43, 'label'=>'rad',
             'exchange'=>true, 'annot'=>false)

GGraph.line( Turb.cut('t'=>86400.0), false, 
             'index'=>33, 'label'=>'turb',
             'exchange'=>true, 'annot'=>false)

GGraph.line( Damp.cut('t'=>86400.0), false, 
             'index'=>63, 'label'=>'damp',
             'exchange'=>true, 'annot'=>false)



# 平均温位
#
GGraph.set_axes( 'xtitle'=>'', 'xunit'=>'K' )

GGraph.line( PotTempMean.cut('t'=>7200.0), 
             true, 'max'=>280, 'min'=>230,
             'index'=>12, 'label'=>'2',
             'title'=>'Mean Potential Temp.',
             'exchange'=>true, 'annot'=>false )

GGraph.line( PotTempMean.cut('t'=>14400.0), 
             false, 
             'index'=>22, 'label'=>'4',
             'exchange'=>true, 'annot'=>false )

GGraph.line( PotTempMean.cut('t'=>21600.0), 
             false, 
             'index'=>32, 'label'=>'6',
             'exchange'=>true, 'annot'=>false )

GGraph.line( PotTempMean.cut('t'=>28800.0), 
             false, 
             'index'=>42, 'label'=>'8',
             'exchange'=>true, 'annot'=>false )

GGraph.line( PotTempMean.cut('t'=>36000.0), 
             false, 
             'index'=>52, 'label'=>'10',
             'exchange'=>true, 'annot'=>false )

GGraph.line( PotTempMean.cut('t'=>43200.0), 
             false, 
             'index'=>62, 'label'=>'12',
             'exchange'=>true, 'annot'=>false )

GGraph.line( PotTempMean.cut('t'=>50400.0), 
             false, 
             'index'=>72, 'label'=>'14',
             'exchange'=>true, 'annot'=>false )

GGraph.line( PotTempMean.cut('t'=>57600.0), 
             false, 
             'index'=>82, 'label'=>'16',
             'exchange'=>true, 'annot'=>false )

GGraph.line( PotTempMean.cut('t'=>64800.0), 
             false, 
             'index'=>92, 'label'=>'18',
             'exchange'=>true, 'annot'=>false )

GGraph.line( PotTempMean.cut('t'=>72000.0), 
             false, 
             'index'=>102, 'label'=>'20',
             'exchange'=>true, 'annot'=>false )

GGraph.line( PotTempMean.cut('t'=>79200.0), 
             false, 
             'index'=>112, 'label'=>'22',
             'exchange'=>true, 'annot'=>false )

GGraph.line( PotTempMean.cut('t'=>86400.0), 
             false, 
             'index'=>122, 'label'=>'24',
             'exchange'=>true, 'annot'=>false )


DCL.grcls

system( "mv dcl_001.png 2dMars_dx200dz100_nc0.5_25kday_heatprof.png" )
system( "mv dcl_002.png 2dMars_dx200dz100_nc0.5_25kday_pottempprof.png" )
