require "numru/ggraph"
include NumRu

c1=5.0*(10**(-1))
c2=5.0*(10**(-2))
c3=5.0*(10**(-3))
c4=5.0*(10**(-4))
c5=2.5*(10**(-3))
c6=1.0*(10**(-2))
nu=3.5
time=510

gphys1_1 = GPhys::IO.open("./src/c_5d-1/u_mu.nc","u").cut("t"=>time).cut("height"=>0)
gphys1_2 = GPhys::IO.open("./src/c_5d-1/dudz.nc","dudz").cut("t"=>time).cut("height"=>0.05)
gphys2_1 = GPhys::IO.open("./src/c_5d-2/u_mu.nc","u").cut("t"=>time).cut("height"=>0)
gphys2_2 = GPhys::IO.open("./src/c_5d-2/dudz.nc","dudz").cut("t"=>time).cut("height"=>0.05)
gphys3_1 = GPhys::IO.open("./src/c_5d-3/u_mu.nc","u").cut("t"=>time).cut("height"=>0)
gphys3_2 = GPhys::IO.open("./src/c_5d-3/dudz.nc","dudz").cut("t"=>time).cut("height"=>0.05)
gphys4_1 = GPhys::IO.open("./src/c_5d-4/u_mu.nc","u").cut("t"=>time).cut("height"=>0)
gphys4_2 = GPhys::IO.open("./src/c_5d-4/dudz.nc","dudz").cut("t"=>time).cut("height"=>0.05)
gphys5_1 = GPhys::IO.open("./src/c_25d-3/u_mu.nc","u").cut("t"=>time).cut("height"=>0)
gphys5_2 = GPhys::IO.open("./src/c_25d-3/dudz.nc","dudz").cut("t"=>time).cut("height"=>0.05)
gphys6_1 = GPhys::IO.open("./src/c_1d-2/u_mu.nc","u").cut("t"=>time).cut("height"=>0)
gphys6_2 = GPhys::IO.open("./src/c_1d-2/dudz.nc","dudz").cut("t"=>time).cut("height"=>0.05)
gphys10 = GPhys::IO.open("./src/c_5d-1/ft.nc","u")

gphys1=c1*gphys1_1-nu*gphys1_2
gphys2=c2*gphys2_1-nu*gphys2_2
gphys3=c3*gphys3_1-nu*gphys3_2
gphys4=c4*gphys4_1-nu*gphys4_2
gphys5=c5*gphys5_1-nu*gphys5_2
gphys6=c6*gphys6_1-nu*gphys6_2

Lat = gphys10.axis('lat').pos.val
mu = NArray.float(192).fill(0.0)
line = NArray.float(192).fill(0.0)

for i in 0..191 do
mu[i] = sin(Lat[i]*(Math::PI/180.0))
end

Mu = VArray.new(mu,{"long_name"=>"sin Latitude","units"=>""},"sinLat")
axis_mu = Axis.new.set_pos(Mu)
line = VArray.new(line,{"long_name"=>"zonal wind","units"=>"m/s"},"u")
gphys10 = GPhys.new(Grid.new(axis_mu),line)

DCL.gropn(1)
DCL.uzfact(0.6)
GGraph.set_fig("itr"=>1,"viewport"=>[0.1,0.7,0.2,0.6])
GGraph.set_axes("ytitle"=>"","yunits"=>"","xtitle"=>"sin (Lat)","xunits"=>"")
rmiss = DCL.glpget('rmiss')

#GGraph.line(gphys1,true,"exchange"=>false,"annotate"=>false,"title"=>"","index"=>20)
#GGraph.line(gphys1,true,"exchange"=>false,"annotate"=>false,"title"=>"","index"=>20,"min"=>-30,"max"=>34)
GGraph.line(gphys1,true,"exchange"=>false,"annotate"=>false,"title"=>"","index"=>20,"min"=>-0.032,"max"=>0.024)
GGraph.line(gphys2,false,"exchange"=>false,"annotate"=>false,"index"=>40)
GGraph.line(gphys3,false,"exchange"=>false,"annotate"=>false,"index"=>10)
GGraph.line(gphys4,false,"exchange"=>false,"annotate"=>false,"index"=>60)
GGraph.line(gphys5,false,"exchange"=>false,"annotate"=>false,"index"=>50)
GGraph.line(gphys6,false,"exchange"=>false,"annotate"=>false,"index"=>30)
GGraph.line(gphys10,false,"exchange"=>false,"annotate"=>false,"index"=>10)

DCL.grcls

