Closed mukund-gupta closed 3 years ago
Now we did not have wrapper functions easily to use some subroutines including outputs in the arguments (ex. gsw_nsquared). The functions are confusing. Sorry @mukund-gupta.
In the released version, please try below.
using GibbsSeaWater
# Constants
g = 9.81
Nz = 64
Δz = 2.5
Lz = Δz*Nz
z = collect(-((Δz/2):Δz:(Lz-Δz/2))) # to Array{Float64} for Pres
Stop = 34.1
Sbot = 34.7
Ttop = -0.5
Tbot = 0
ztop = -40
zbot = -Lz
dSdz = (Sbot - Stop)/(zbot - ztop)
dTdz = (Tbot - Ttop)/(zbot - ztop)
rho_O = 1000.0 # !!! I miss this value in the original script
Lat0 = 0.0 # latitude where the profile is measured
# Profiles
S = Stop .+ dSdz*(z .< ztop).*(z .- ztop)
T = Ttop .+ dTdz*(z .< ztop).*(z .- ztop)
Pres = -rho_O*g*z*1e-4
N2 = zeros(Nz-1) # Array for output of Brunt-Vaisalla values @ Pmid)
Pmid = zeros(Nz-1) # Array for outputs of pressure for N2
Lats = fill(Lat0, Nz)
a = gsw_nsquared(S, T, Pres, Lats, Nz, N2, Pmid)
Or
In the master repository (pkg> add GibbsSeaWater#master
), you can use
N2, Pmid = gsw_nsquared(S, T, Pres, Lats)
Thank you very much! Both methods work for me. I'll just point out that when using
N2, Pmid = gsw_nsquared(S, T, Pres, Lats)
,
N2
and Pmid
have the same dimensions as T
and S
, and that the last element of those vectors are zeros. I don't know whether this is intentional or not.
Sorry, the lengths of outputs are wrong. I fixed them. Thank you for pointing out @mukund-gupta :).
Great! Thanks for fixing that.
I would personally have Lats
as an optional argument, since that would make it consistent with the Matlab and python versions of gsw_nsquared
.
Thanks for the help!
Hello, I am trying to use gsw_nsquared as follows:
But get the following error:
Could you advise how I should use gsw_nsquared instead? Many thanks.