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

InputFile0='2dMars_dx100dz100_01_Zprof.nc'
InputFile1='2dMars_dx100dz100_01_PotTempMean.nc'

Day = 86400.0

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


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

DCL::swpset('LDUMP', true)
DCL.gropn(4)
#DCL.sldiv('y', 2, 1)

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

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

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

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


GGraph.line( Diff.cut('t'=>43200), false, 
             'index'=>63, 'label'=>'diff',
             'exchange'=>true, 'annot'=>false)



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

GGraph.line( PotTempMean1.cut('t'=>7200), 
             true, 'max'=>280, 'min'=>225,
             'index'=>2, 'label'=>'2',
             'title'=>'Mean Potential Temp.',
             'exchange'=>true, 'annot'=>false )

GGraph.line( PotTempMean1.cut('t'=>14400), 
             false, 
             'index'=>2, 'label'=>'4',
             'exchange'=>true, 'annot'=>false )

GGraph.line( PotTempMean1.cut('t'=>21600), 
             false, 
             'index'=>2, 'label'=>'6',
             'exchange'=>true, 'annot'=>false )

GGraph.line( PotTempMean1.cut('t'=>28800), 
             false, 
             'index'=>2, 'label'=>'8',
             'exchange'=>true, 'annot'=>false )

GGraph.line( PotTempMean1.cut('t'=>36000), 
             false, 
             'index'=>2, 'label'=>'10',
             'exchange'=>true, 'annot'=>false )

GGraph.line( PotTempMean1.cut('t'=>43200), 
             false, 
             'index'=>2, 'label'=>'12',
             'exchange'=>true, 'annot'=>false )
DCL.grcls

#system( "mv dcl_001.png 3dMars_dx200dz100_heatprof.png" )
#system( "mv dcl_002.png 3dMars_dx200dz100_pottempprof.png" )
