Skip to content

Commit

Permalink
Merge pull request #74 from mauzey1/interp_method_mrst
Browse files Browse the repository at this point in the history
Add MRST-PCHIP as interpolation option for gsw_geo_strf_dyn_height_1
  • Loading branch information
efiring authored Oct 7, 2024
2 parents e6afedf + e0418ce commit 4ead876
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions gsw_oceanographic_toolbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -4010,8 +4010,9 @@ gsw_geo_strf_dyn_height_1(double *sa, double *ct, double *p, double p_ref,
!
! This function evaluates the pressure integral of specific volume using
! SA and CT interpolated with respect to pressure. The interpolation method
! may be chosen as linear or "PCHIP", piecewise cubic Hermite using a shape-
! preserving algorithm for setting the derivatives.
! may be chosen as linear, "PCHIP" (piecewise cubic Hermite using a shape-
! preserving algorithm for setting the derivatives), or "MRST-PCHIP"
! (Multiply-Rotated Salinity–Temperature PCHIP).
!
! SA = Absolute Salinity [ g/kg ]
! CT = Conservative Temperature (ITS-90) [ deg C ]
Expand All @@ -4023,7 +4024,7 @@ gsw_geo_strf_dyn_height_1(double *sa, double *ct, double *p, double p_ref,
! geo_strf_dyn_height = dynamic height anomaly [ m^2/s^2 ]
! max_dp_i = maximum pressure difference between points for triggering
! interpolation.
! interp_method = 1 for linear, 2 for PCHIP
! interp_method = 1 for linear, 2 for PCHIP, 3 for MRST-PCHIP
!
! Note. If p_ref falls outside the range of a
! vertical profile, the dynamic height anomaly for each bottle
Expand Down Expand Up @@ -4269,8 +4270,13 @@ gsw_geo_strf_dyn_height_1(double *sa, double *ct, double *p, double p_ref,
err = err || gsw_util_pchip_interp(p, ct, nz, p_i, ct_i, n_i);
if (err) err = 6;
}
else if (interp_method == INTERP_METHOD_MRST) {
err = gsw_sa_ct_interp(sa, ct, p, nz,
p_i, n_i, sa_i, ct_i);
if (err) err = 7;
}
else {
err = 7;
err = 8;
}
if (err) {
free(p_i);
Expand Down
1 change: 1 addition & 0 deletions gswteos-10.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extern "C" {

#define INTERP_METHOD_LINEAR 1
#define INTERP_METHOD_PCHIP 2
#define INTERP_METHOD_MRST 3

/*
** Prototypes:
Expand Down

0 comments on commit 4ead876

Please sign in to comment.