Skip to content

Commit

Permalink
minor cleanup from earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
ggebbie committed Nov 18, 2022
1 parent 11e2ea9 commit 03c20ef
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/IsopycnalSurfaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ function sigmacolumn(θz::Vector{T},Sz::Vector{T},pz::Vector{T2},p₀,eos="TEOS1
# "GibbsSeaWater.jl is a Julia wrapper for GSW-C#master, which is the C implementation of the Thermodynamic Equation of Seawater 2010 (TEOS-10)."
SA = gsw_sa_from_sp.(Sz,pz,0,30) # here we use the fixed location, lon=0deg,lat=30deg, to convert practical S to absolute S
CT = gsw_ct_from_pt.(SA ,θz) # Conservative T from (Absolute S, sigma0)
σ = gsw_rho.(SA,CT,p₀) .- 1000.
σ = gsw_rho.(SA,CT,p₀) .- 1000.0
else
error("The entered EOS is not supported for the classic version of this function, please try the supported one, like EOS80 or JMD95")
error("The entered EOS is not supported for the classic version of this function, please try the supported one, like EOS80, JMD95, or TEOS10")
end

return σ
Expand Down
25 changes: 21 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,38 @@ using IsopycnalSurfaces, Test

@testset "point" begin

# some examples of different interfaces.

# classic definition for sigma1
θ = Vector{Float64}(undef,1); θ[1] = 15.0
S = Vector{Float64}(undef,1); S[1] = 35.0
p = Vector{Float64}(undef,1); p[1] = 2000.0

# classic EOS takes 3 classic variables.
σ₁A = sigma1column(θ,S,p,"EOS80")
σ₁B = sigma1column(θ,S,p,"JMD95")

# Try more general version of sigma1
vars = Dict( => θ, :S => S, :p => p)
σ₁C= sigmacolumn(vars,p₀=1000,eos="TEOS10")
# Thermodynamic EOS will also take classic variables.
σ₁C = sigma1column(θ,S,p,"TEOS10")

# Argument list can be packed into a Dict with symbols.
vars = Dict( => θ, :S => S, :p => p)
#σ₁A2= sigmacolumn(vars,p₀=1000,eos="EOS80") # fails
#σ₁B2= sigmacolumn(vars,p₀=1000,eos="JMD95") # fails
σ₁C2= sigmacolumn(vars,p₀=1000,eos="TEOS10")

# A more general version with strings instead of symbols
vars = Dict("θ" => θ, "S" => S, "p" => p)
σ₁D= sigmacolumn(vars,p₀=1000,eos="TEOS10")

# smaller than 5% error?
@test abs(σ₁C[1] - σ₁B[1])/(abs(σ₁C[1]) + abs(σ₁B[1])) < 0.05
@test abs(σ₁A[1] - σ₁B[1])/(abs(σ₁A[1]) + abs(σ₁B[1])) < 0.05
@test abs(σ₁D[1] - σ₁B[1])/(abs(σ₁D[1]) + abs(σ₁B[1])) < 0.05

# can you supply a depth index instead of pressure?
# can one supply a depth index instead of pressure?
vars = Dict("θ" => θ, "S" => S, "z" => p)
σ₁E= sigmacolumn(vars,p₀=1000,eos="TEOS10")

end

Expand Down

0 comments on commit 03c20ef

Please sign in to comment.