IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 9, 2026, 11:26:15 AM (4 months ago)
Author:
eugene
Message:

add spline options to extrapolate or saturate at end points; add vweave function to interpolate a vector with varying bin sizes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/lib.data/spline.c

    r42821 r42967  
    11# include "data.h"
     2
     3static SplineMode MODE = SPLINE_SATURATE; // SATURATE or EXTRAPOLATE?
     4
     5int spline_contruct_mode (SplineMode mode) {
     6 
     7  switch (mode) {
     8  case SPLINE_SATURATE:
     9  case SPLINE_EXTRAPOLATE:
     10    MODE = mode;
     11    break;
     12  default:
     13    return FALSE;
     14  }
     15  return TRUE;
     16}
    217
    318/* construct the natural spline for x, y in y2 */
     
    3651 
    3752  // saturate correction at high and low ends
    38   if (X < x[0]) return y[0];
    39   if (X > x[N-1]) return y[N-1];
     53  if (MODE == SPLINE_SATURATE) {
     54    if (X < x[0]) return y[0];
     55    if (X > x[N-1]) return y[N-1];
     56  }
    4057
    4158  /* find correct element in array (x must be sorted) */
     
    113130  opihi_flt dx, a, b, value;
    114131 
    115   // linear extrapolation past endpoints
    116   if (X < x[0]) {
    117     hi = 1;
    118     lo = 0;
    119     goto evaluate;
    120     // alternative: saturate correction at high and low ends
    121     // return y[0];
    122   }
    123   if (X > x[N-1]) {
    124     hi = N - 1;
    125     lo = N - 2;
    126     goto evaluate;
    127     // alternative: saturate correction at high and low ends
    128     // return y[N-1];
     132  // saturate correction at high and low ends
     133  if (MODE == SPLINE_SATURATE) {
     134    if (X < x[0]) return y[0];
     135    if (X > x[N-1]) return y[N-1];
    129136  }
    130137
     
    140147    }
    141148  }
    142 
    143 evaluate:
    144149
    145150  /* error condition: duplicate abssisca */
Note: See TracChangeset for help on using the changeset viewer.