Closed jpolton closed 10 months ago
@jpolton interesting, I'll take a look
@jpolton @anwiseNOCL , after a review of the calculation, I verified that there are some differences between the absolute salinity calculation between versions 3.4 and 3.6. Please see below the differences:
import gsw
gsw.SA_from_SP(SP=24.835115, p=0.5038634337828468 ,lon=-19.888672,lat=40.066406)
The output is 24.952401390208948
in the version 3.4 and 24.952399876617687
in the version 3.6.
I checked the gws packages to see the updates between the releases but I did not find yet anything that justify this difference ("0.00000151359 g/kg"). I will spend a little bit more time on that.
@jpolton , in the latest gsw version, the c package for the gsw wrapper was updated, responsible for calculations used by Matlab, Python, and R packages. While checking release updates for gsw_python, gsw for c, and the TEOS-10 manual for version 3.06, no information was found regarding updates to absolute salinity calculations.
I suspect differences in results may be due to the use of double for representing floats in C. Despite not finding confirmation for this, experimenting with float 16, float 32, and float 34 numbers yields different outputs.
It's importante to mention that there is a xarray wrapper exists for GSW, known as gsw-array, which requires version 3.4.0 or newer (similar to the coast package).
While acknowledging the observed differences in results, I propose considering an update to the latest GSW version (3.6.17). The variances are minimal, and it is unlikely that they would significantly impact scientific outcomes. To provide perspective, consider the Autosal sensor, renowned for its precision in salinity measurement, has a resolution of 0.0002 PSU (~0.0002g/kg), which surpasses the small difference (0.00000151359 g/kg) between the versions.
@jpolton , in the latest gsw version, the c package for the gsw wrapper was updated, responsible for calculations used by Matlab, Python, and R packages. While checking release updates for gsw_python, gsw for c, and the TEOS-10 manual for version 3.06, no information was found regarding updates to absolute salinity calculations.
I suspect differences in results may be due to the use of double for representing floats in C. Despite not finding confirmation for this, experimenting with float 16, float 32, and float 34 numbers yields different outputs.
I propose we accept the new version, update our assert tests accordingly, and post an Issue on the gsm package highlighting the difference we found (cut and paste from the above). @soutobias are you happy to do that? Then we can consider this issue closed.
Hi @jpolton , I updated my comment. Please take a look at that. I will post an issue in the gsw package as well.
@soutobias That is really good to know that there is an xarray wrapper for gsw, it always bothered me that there wasn't (or I thought there wasn't). Also I agree with your suggestion.
@jpolton @anwiseNOCL , I posted an issue. Lets see what they will reply: https://github.com/TEOS-10/GSW-Python/issues/150
(See branch feature/585_gsw_version, see linked draft pull request.)
Updating the GSW (Gibbs Sea Water) package seems to modify the calculation of pressure related terms at the 6th significant figure. This may or may not be a problem.
The update for GSW is new. https://github.com/TEOS-10/GSW-Python/releases We were using 3.4.0 but in Sep'22 they updated to 3.4.2 and now 3.6.16
Looking through unit_testing issues occur in
in calculations of domain summed stratification metrics. Note that the changes are relatively small:
But what is the cause? Well I think this must be
Gridded.construct_density()
but thetest_diagnostic_methods.py/test_construct_density()
passes. Hmmm.Tests also fail in
The latter is interesting because it passed a test calculating density but fails with pressure:
Having "fixed" the errors in stratification by moving the
np.isclose()
goal posts remaining failures are all inWhich is why I think it is the pressure calculation and probably:
But since bottom pressure needs to be double precision this is worth a look.
Code snippet to demonstrate issue, with updated gsw=3.6.16post1 (from 3.4)
Update packages. I did this with
which found and implemented the gsw update. Then
Returns:
So again a change at the 6 significant figure.