Fix constant integration offset in geo_strf_dyn_height#224
Fix constant integration offset in geo_strf_dyn_height#224romeroqe wants to merge 1 commit intoTEOS-10:mainfrom
Conversation
|
Can you provide an example where this doesn't return 0 where |
|
I think this does need to be solved in the C, not in the Python. The C is using exact equality tests for floating point numbers. This could cause a problem like this if one side of a test is promoted from single precision, for example. We need a simple easy-to-use test case. @romeroqe, please make a complete self-contained example we can use to investigate this, and later in an actual test. Maybe save all the inputs to gsw.geo_strf_dyn_height from the first profile in a single netcdf file, preserving the types of all variables, so that a single read of that file followed by a single call to gsw.geo_strf_dyn_height will reproduce the error. |

This pull request ensures that
geo_strf_dyn_heightreturns a dynamic height anomaly that is exactly zero at the reference pressure (p_ref).In the MATLAB GSW toolbox, the dynamic height is explicitly anchored by subtracting its value at
p_ref, ensuring:In the current Python implementation, a constant integration offset may remain due to the implicit integration constant of the numerical integral. As a result, the dynamic height at
p_refcan differ from zero even whenp_refis included in the integration grid.This modification removes that constant by subtracting the dynamic height evaluated at
p_refwithin each processed profile.This prevents discrepancies between MATLAB and Python implementations when comparing dynamic height or derived quantities.