# -*- coding: euc-jp -*-

# 初期と最終時刻での水平平均地表面圧力を計算するスクリプト
# (x 平均)

require "numru/ggraph"
include NumRu

#timestep  = ARGV[0].to_i

x1 = 0
x2 = 256000
#x2 = 512000
#x2 = 500 * 1000 - 500 * 10
z1 = 0
#z2 = 30000
#z2 = 48000
#t2 = 86400 * 50
t2 = 86400 * 20

files1 = 'thermal-moist_PressAll.nc'
gphys1 = GPhys::IO.open(files1, 'PressAll')
files2 = 'thermal-moist_PressAll-20121219-Default_z48km.nc'
gphys2 = GPhys::IO.open(files2, 'PressAll')

#files2 = 'thermal-moist_PressAll_TET_CtlPress_atSfcFlux_x256km_z48km.nc'
#gphys2 = GPhys::IO.open(files2, 'ExnerAll')
#files2 = 'thermal-moist_ExnerAll_z24km.nc'
#gphys2 = GPhys::IO.open(files2, 'ExnerAll')
#files3 = 'thermal-moist_ExnerAll_z36km.nc'
#gphys3 = GPhys::IO.open(files3, 'ExnerAll')
#files4 = 'thermal-moist_ExnerAll_z48km.nc'
#gphys4 = GPhys::IO.open(files4, 'ExnerAll')

#gphysdisp0 = gphys
gphysdisp0 = gphys1
gphysdisp0 = gphysdisp0.mean( 'x' )
gphysdisp0 = gphysdisp0.mean( 'y' )
gphysdisp0 = gphysdisp0.cut( 'z'=>150 )
gphysdisp1 = gphysdisp0.cut( 't'=>0 )
gphysdisp2 = gphysdisp0.cut( 't'=>t2 )

#print "\n z30km t=0 :\n"
print "\n Default z48km t=0 :\n"
p gphysdisp1.val

#print "\n z30km t=50day :\n"
print "\n Default z48km t=20day :\n"
p gphysdisp2.val

p " "
p ( gphysdisp1.val - gphysdisp2.val ) / gphysdisp1.val * 100

p "--------------------------"

#exit

gphysdisp0 = gphys2
gphysdisp0 = gphysdisp0.mean( 'x' )
gphysdisp0 = gphysdisp0.mean( 'y' )
gphysdisp0 = gphysdisp0.cut( 'z'=>150 )
gphysdisp1 = gphysdisp0.cut( 't'=>0 )
gphysdisp2 = gphysdisp0.cut( 't'=>t2 )

#print "\n z24km t=0 :\n"
print "\n 20121219 Default z48km t=0 :\n"
p gphysdisp1.val

#print "\n z24km t=50day :\n"
print "\n 20121219 Default z48km t=20day :\n"
p gphysdisp2.val

p " "
p ( gphysdisp1.val - gphysdisp2.val ) / gphysdisp1.val * 100

p "--------------------------"

exit

gphysdisp0 = gphys3
gphysdisp0 = gphysdisp0.mean( 'x' )
gphysdisp0 = gphysdisp0.mean( 'y' )
gphysdisp0 = gphysdisp0.cut( 'z'=>150 )
gphysdisp1 = gphysdisp0.cut( 't'=>0 )
gphysdisp2 = gphysdisp0.cut( 't'=>t2 )

print "\n z36km t=0 :\n"
p gphysdisp1.val

print "\n z36km t=50day :\n"
p gphysdisp2.val

p "--------------------------"

gphysdisp0 = gphys4
gphysdisp0 = gphysdisp0.mean( 'x' )
gphysdisp0 = gphysdisp0.mean( 'y' )
gphysdisp0 = gphysdisp0.cut( 'z'=>150 )
gphysdisp1 = gphysdisp0.cut( 't'=>0 )
gphysdisp2 = gphysdisp0.cut( 't'=>t2 )

print "\n z48km t=0 :\n"
p gphysdisp1.val

print "\n z48km t=50day :\n"
p gphysdisp2.val

p "--------------------------"


