IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42946


Ignore:
Timestamp:
Nov 23, 2025, 4:33:16 PM (8 months ago)
Author:
eugene
Message:

add spline option to extrapolate (vs saturate); add vweave function (like drizzle for a vector)

Location:
branches/eam_branches/ipp-ppmerge-20241229/Ohana/src/opihi
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-ppmerge-20241229/Ohana/src/opihi/cmd.data/Makefile

    r42456 r42946  
    183183$(SRC)/vbin.$(ARCH).o              \
    184184$(SRC)/vgroup.$(ARCH).o            \
     185$(SRC)/vweave.$(ARCH).o            \
    185186$(SRC)/vclip.$(ARCH).o             \
    186187$(SRC)/vgauss.$(ARCH).o            \
  • branches/eam_branches/ipp-ppmerge-20241229/Ohana/src/opihi/cmd.data/init.c

    r42456 r42946  
    168168int vbin             PROTO((int, char **));
    169169int vgroup           PROTO((int, char **));
     170int vweave           PROTO((int, char **));
    170171int vclip            PROTO((int, char **));
    171172int vect_select      PROTO((int, char **));
     
    382383  {1, "vbin",         vbin,             "rebin vector data by a factor of N"},
    383384  {1, "vgroup",       vgroup,           "group y vector into bins defined by x vector values"},
     385  {1, "vweave",       vweave,           "drizzle input vectors to output vector with correct fractional bin weighting"},
    384386  {1, "vclip",        vclip,            "clip values in a vector to be within a range"},
    385387  {1, "vectors",      list_vectors,     "list vectors"},
  • branches/eam_branches/ipp-ppmerge-20241229/Ohana/src/opihi/cmd.data/spline_commands.c

    r42332 r42946  
    6262int spline_apply (int argc, char **argv) {
    6363
    64   int i;
     64  int i, N;
    6565  Vector *xvec, *yvec;
     66
     67  spline_contruct_mode (SPLINE_SATURATE);
     68  if ((N = get_argument (argc, argv, "-extrapolate"))) {
     69    spline_contruct_mode (SPLINE_EXTRAPOLATE);
     70    remove_argument (N, &argc, argv);
     71  }
    6672
    6773  if (argc != 4) {
  • branches/eam_branches/ipp-ppmerge-20241229/Ohana/src/opihi/cmd.data/test/spline.sh

    r41341 r42946  
    11
    22macro test1
    3 
    43  for i 0 100
    54    create x 0 50
     
    109  end
    1110end
     11
     12macro mytest.saturate
     13  vlist x 400 500  600  700  800  900
     14  vlist y  15 425  610  700  745  775
     15
     16  spline create t1 x y
     17
     18  create X 300 1000 5
     19  spline apply t1 X Y
     20
     21  lim X Y; clear; box; plot x y; plot -c red -x line X Y
     22end
     23 
     24macro mytest.extrapolate
     25  vlist x 400 500  600  700  800  900
     26  vlist y  15 425  610  700  745  775
     27
     28  spline create t1 x y
     29
     30  create X 300 1000 5
     31  spline apply t1 X Y -extrapolate
     32
     33  lim X Y; clear; box; plot x y; plot -c red -x line X Y
     34end
     35 
  • branches/eam_branches/ipp-ppmerge-20241229/Ohana/src/opihi/include/data.h

    r42456 r42946  
    3333  char **pageIDs;
    3434} Book;
     35
     36typedef enum {SPLINE_SATURATE, SPLINE_EXTRAPOLATE} SplineMode;
    3537
    3638// the interpolating spline has valu
     
    138140void spline_construct_dbl (opihi_flt *x, opihi_flt *y, int N, opihi_flt *y2, opihi_flt dyLower, opihi_flt dyUpper);
    139141opihi_flt spline_apply_dbl (opihi_flt *x, opihi_flt *y, opihi_flt *y2, int N, opihi_flt X);
     142int spline_contruct_mode (SplineMode mode);
    140143
    141144/* in svdcmp.c */
  • branches/eam_branches/ipp-ppmerge-20241229/Ohana/src/opihi/lib.data/spline.c

    r42332 r42946  
    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) */
     
    114131 
    115132  // saturate correction at high and low ends
    116   if (X < x[0]) return y[0];
    117   if (X > x[N-1]) return y[N-1];
     133  if (MODE == SPLINE_SATURATE) {
     134    if (X < x[0]) return y[0];
     135    if (X > x[N-1]) return y[N-1];
     136  }
    118137
    119138  /* find correct element in array (x must be sorted) */
Note: See TracChangeset for help on using the changeset viewer.