#!/usr/bin/env ruby
#
# 表題  子午面非発散ベクトル場
#
# 履歴  2026/06/03 竹広 真一
#
require "numru/dcl"
include NumRu
include NMath

Nlat = 30 ; Nsig = 30

lat = NArray.float(Nlat)
for j in 0..Nlat-1
  lat[j] = - PI/2 + PI/(Nlat-1)*j
end
latdeg = lat/PI*180.0

sig = NArray.float(Nsig)
for k in 0..Nsig-1
  sig[k] = 1.0-1.0/(Nsig-1)*k
end

psi1 = NArray.float(Nlat,Nsig)
for k in 0..Nsig-1
  for j in 0..Nlat-1
    psi1[j,k] = sin(PI*sig[k])*cos(lat[j])**2
  end
end

psi2 = NArray.float(Nlat,Nsig)
for k in 0..Nsig-1
  for j in 0..Nlat-1
    psi2[j,k] = sin(PI*sig[k])*3*sin(lat[j])*cos(lat[j])**2
  end
end

DCL.udlset('LMSG',false)
DCL.gropn(1)
DCL.grfrm
DCL.grsvpt( 0.2, 0.8, 0.65, 0.9 )
DCL.grswnd( -90.0, 90.0, 1.0, 0.0 )
DCL.grstrn(1)
DCL.grstrf

DCL.ussttl( 'latitude', 'deg.', 'sigma','')
DCL.usdaxs
DCL.udcntr( psi1 )

DCL.grfig
DCL.grsvpt( 0.2, 0.8, 0.2, 0.45 )
DCL.grswnd( -90.0, 90.0, 1.0, 0.0 )
DCL.grstrn(1)
DCL.grstrf

DCL.ussttl( 'latitude', 'deg.', 'sigma','')
DCL.usdaxs
DCL.udcntr( psi2 )

DCL.grcls
