IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42332


Ignore:
Timestamp:
Jan 30, 2023, 9:45:29 AM (3 years ago)
Author:
eugene
Message:

adding option to spline1d to specify boundary 1st derivatives (default is 2nd derive = 0.0)

Location:
trunk/Ohana/src/opihi
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.data/imspline_apply.c

    r40549 r42332  
    7777      Tx1[i] = spline_apply_flt (Tyc, Ty1, Ty2, Ny, y);
    7878    }
    79     spline_construct_flt (Txc, Tx1, Nx, Tx2);
     79    spline_construct_flt (Txc, Tx1, Nx, Tx2, NAN, NAN);
    8080
    8181    /* apply x-dir spline to new image */
  • trunk/Ohana/src/opihi/cmd.data/imspline_construct.c

    r40549 r42332  
    5555    }
    5656 
    57     spline_construct_flt (Tx, Ty, Ny, Ty2);
     57    spline_construct_flt (Tx, Ty, Ny, Ty2, NAN, NAN);
    5858 
    5959    /* copy derivatives to output buffer */
  • trunk/Ohana/src/opihi/cmd.data/spline_commands.c

    r41341 r42332  
    1515int spline_create (int argc, char **argv) {
    1616
    17   int i;
     17  int i, N;
    1818  Vector *xvec, *yvec;
     19
     20  double dyLower = NAN;
     21  double dyUpper = NAN;
     22  if ((N = get_argument (argc, argv, "-dyLower"))) {
     23    remove_argument (N, &argc, argv);
     24    dyLower = atof(argv[N]);
     25    remove_argument (N, &argc, argv);
     26  }
     27  if ((N = get_argument (argc, argv, "-dyUpper"))) {
     28    remove_argument (N, &argc, argv);
     29    dyUpper = atof(argv[N]);
     30    remove_argument (N, &argc, argv);
     31  }
    1932
    2033  if (argc != 4) {
     
    4356  }   
    4457
    45   spline_construct_dbl (myspline->xk, myspline->yk, myspline->Nknots, myspline->y2);
     58  spline_construct_dbl (myspline->xk, myspline->yk, myspline->Nknots, myspline->y2, dyLower, dyUpper);
    4659  return TRUE;
    4760}
  • trunk/Ohana/src/opihi/include/data.h

    r41891 r42332  
    133133
    134134/* in spline.c */
    135 void spline_construct_flt (float *x, float *y, int N, float *y2);
     135void spline_construct_flt (float *x, float *y, int N, float *y2, float dyLower, float dyUpper);
    136136float spline_apply_flt (float *x, float *y, float *y2, int N, float X);
    137 void spline_construct_dbl (opihi_flt *x, opihi_flt *y, int N, opihi_flt *y2);
     137void spline_construct_dbl (opihi_flt *x, opihi_flt *y, int N, opihi_flt *y2, opihi_flt dyLower, opihi_flt dyUpper);
    138138opihi_flt spline_apply_dbl (opihi_flt *x, opihi_flt *y, opihi_flt *y2, int N, opihi_flt X);
    139139
  • trunk/Ohana/src/opihi/lib.data/spline.c

    r41341 r42332  
    22
    33/* construct the natural spline for x, y in y2 */
    4 void spline_construct_flt (float *x, float *y, int N, float *y2) {
     4void spline_construct_flt (float *x, float *y, int N, float *y2, float dyLower, float dyUpper) {
    55
    66  int i;
     
    6767
    6868/* construct the natural spline for x, y in y2 */
    69 void spline_construct_dbl (opihi_flt *x, opihi_flt *y, int N, opihi_flt *y2) {
     69void spline_construct_dbl (opihi_flt *x, opihi_flt *y, int N, opihi_flt *y2, opihi_flt dyLower, opihi_flt dyUpper) {
    7070
    7171  int i;
     
    7777  ALLOCATE (tmp, opihi_flt, N);
    7878
    79   y2[0] = tmp[0] = 0.0;
     79  if (isnan(dyLower)) {
     80    y2[0] = tmp[0] = 0.0;
     81  } else {
     82    y2[0] = -0.5;
     83    tmp[0]   = (3.0/(x[1]-x[0])) * ((y[1]-y[0])/(x[1]-x[0]) - dyLower);
     84  }
    8085 
    8186  for (i = 1; i < N-1; i++) {
     
    8691    tmp[i] = (6.0 * tmp[i] / (x[i+1] - x[i-1]) - dx*tmp[i-1]) / dy;
    8792  }
     93
     94  if (isfinite(dyUpper)) {
     95    opihi_flt qn = 0.5;
     96    tmp[N-1] = (3.0/(x[N-1]-x[N-2])) * (dyUpper - (y[N-1]-y[N-2])/(x[N-1]-x[N-2]));
     97    y2[N-1] = (tmp[N-1] - (qn * tmp[N-2])) / ((qn * y2[N-2]) + 1.0);
     98  } else {
     99    y2[N-1] = 0;
     100  }
    88101 
    89   y2[N-1] = 0;
    90   for (i = N-2; i >= 1; i--)
     102  for (i = N-2; i >= 0; i--) {
    91103    y2[i] = y2[i]*y2[i+1] + tmp[i];
     104  }
    92105
    93106  free (tmp);
Note: See TracChangeset for help on using the changeset viewer.