Closed ThomasHaine closed 1 year ago
Yes, that would be useful. I think that they have to be copied over manually from the C source:
https://github.com/TEOS-10/GSW-C/blob/master/gsw_internal_const.h#L33
Are you interested to make a pull request?
Yes, I can try, although I'm a Julia newbie so will probably need some help.
That could be a one-liner, as defined and tested below, but the harder thing would be finding where in the source to put this, so that it would sit alongside similar functions.
julia> gsw_cp0() = 3991.86795711963
gsw_cp0 (generic function with 1 method)
julia> gsw_cp0()
3991.86795711963
I guess that we can also declare it as an irrational as we did for Ωe
(https://github.com/TEOS-10/GibbsSeaWater.jl/blob/master/src/utils.jl#L1 )
Base.@irrational gsw_cp0 3991.86795711963 big(3991.86795711963)
export gsw_cp0
It can go maybe the same file src/utils.jl
. The advantage of the irrational type is that when multiplied with a single precision float, the result will remain single precision (and not automatically promoted to double precision).
julia> Base.@irrational gsw_cp0 3991.86795711963 big(3991.86795711963)
julia> gsw_cp0
gsw_cp0 = 3991.8679571196...
julia> gsw_cp0 * 1.0
3991.86795711963
julia> gsw_cp0 * 1f0
3991.868f0
julia> typeof(gsw_cp0 * 1f0)
Float32
julia> typeof(gsw_cp0 * 1.0)
Float64
@Alexander-Barth, thanks for your support. @ThomasHaine, please wait I can update.
@ThomasHaine, I've updated.
You can try after update the package, like
pkg> add GibbsSeaWater#master
and check it.
julia> using GibbsSeaWater
julia> Float32(GibbsSeaWater.gsw_cp0)
3991.868f0
Now, to check it without a warning, we may need to cast them to a type like Float32()
or Float64()
under julia version <= 1.8.3.
Works! Thanks @kouketsu
How do I access the seawater specific heat capacity
gsw_cp0
constant (and other constants, for that matter)? The MATLAB gsw package has a function that returns it.Thanks for building this Julia gsw package!