IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42361


Ignore:
Timestamp:
Feb 4, 2023, 7:36:15 AM (3 years ago)
Author:
eugene
Message:

merge from trunk: spline improvements & string vector equate

Location:
branches/eam_branches/ipp-20220316/Ohana
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20220316/Ohana

  • branches/eam_branches/ipp-20220316/Ohana/src/opihi/cmd.data/imspline_apply.c

    r40549 r42361  
    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 */
  • branches/eam_branches/ipp-20220316/Ohana/src/opihi/cmd.data/imspline_construct.c

    r40549 r42361  
    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 */
  • branches/eam_branches/ipp-20220316/Ohana/src/opihi/cmd.data/spline_commands.c

    r41341 r42361  
    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}
  • branches/eam_branches/ipp-20220316/Ohana/src/opihi/cmd.data/threshold.c

    r42156 r42361  
    11# include "data.h"
     2
     3int QUIET = FALSE;
     4
     5void _threshold_set_values (double value, int Nbin, double level, int thresherr) {
     6
     7  set_variable ("threshval", value);
     8  set_int_variable ("threshbin", Nbin);
     9  set_variable ("threshold", level);
     10  set_int_variable ("thresherr", thresherr);
     11
     12  if (!QUIET) gprint (GP_LOG, "theshold %f (bin %d is %f)\n", level, Nbin, value);
     13  return;
     14}
    215
    316int threshold (int argc, char **argv) {
     
    619  Vector *vecx, *vecy;
    720
    8   int QUIET = FALSE;
    921  if ((N = get_argument (argc, argv, "-q"))) {
    1022    QUIET = TRUE;
     23    remove_argument (N, &argc, argv);
     24  }
     25
     26  int SATURATE = FALSE;
     27  if ((N = get_argument (argc, argv, "-saturate"))) {
     28    SATURATE = TRUE;
     29    remove_argument (N, &argc, argv);
     30  }
     31  if ((N = get_argument (argc, argv, "-sat"))) {
     32    SATURATE = TRUE;
    1133    remove_argument (N, &argc, argv);
    1234  }
     
    95117    // this algorithm assumes vecy[BinMax] > threshold, vecy[BinMin] < threshold
    96118    if (vecy[0].elements.Flt[BinMin] > value) {
    97       if (!QUIET) gprint (GP_ERR, "ERROR: all values above threshold\n");
    98       set_int_variable ("threshbin", BinMin);
    99       set_variable ("threshval", vecy[0].elements.Flt[BinMin]);
    100       set_variable ("threshold", vecx[0].elements.Flt[BinMin]);
    101       set_int_variable ("thresherr", 1);
    102       if (!QUIET) gprint (GP_LOG, "theshold %f (bin %d is %f)\n",
    103                           vecx[0].elements.Flt[BinMin], BinMin,
    104                           vecy[0].elements.Flt[BinMin]);
    105       return TRUE;
     119      if (SATURATE) {
     120        _threshold_set_values (vecy[0].elements.Flt[BinMin], BinMin, vecx[0].elements.Flt[BinMin], 1);
     121        return TRUE;
     122      } else {
     123        gprint (GP_ERR, "ERROR: all values above threshold\n");
     124        _threshold_set_values (NAN, -1, NAN, 1);
     125        return FALSE;
     126      }
    106127    }
    107128    if (vecy[0].elements.Flt[BinMax] < value) {
    108       if (!QUIET) gprint (GP_ERR, "ERROR: all values below threshold\n");
    109       set_int_variable ("threshbin", BinMax);
    110       set_variable ("threshval", vecy[0].elements.Flt[BinMax]);
    111       set_variable ("threshold", vecx[0].elements.Flt[BinMax]);
    112       set_int_variable ("thresherr", 1);
    113       if (!QUIET) gprint (GP_LOG, "theshold %f (bin %d is %f)\n",
    114                           vecx[0].elements.Flt[BinMax], BinMax,
    115                           vecy[0].elements.Flt[BinMax]);
    116       return TRUE;
     129      if (SATURATE) {
     130        _threshold_set_values (vecy[0].elements.Flt[BinMax], BinMax, vecx[0].elements.Flt[BinMax], 1);
     131        return TRUE;
     132      } else {
     133        gprint (GP_ERR, "ERROR: all values below threshold\n");
     134        _threshold_set_values (NAN, -1, NAN, 1);
     135        return FALSE;
     136      }
    117137    }
    118138    while (Nhi - Nlo > 10) {
     
    136156    // this algorithm assumes vecy[BinMin] > threshold, vecy[BinMax] < threshold
    137157    if (vecy[0].elements.Flt[BinMin] < value) {
    138       if (!QUIET) gprint (GP_ERR, "ERROR: all values below threshold\n");
    139       set_int_variable ("threshbin", BinMin);
    140       set_variable ("threshval", vecy[0].elements.Flt[BinMin]);
    141       set_variable ("threshold", vecx[0].elements.Flt[BinMin]);
    142       set_int_variable ("thresherr", 1);
    143       if (!QUIET) gprint (GP_LOG, "theshold %f (bin %d is %f)\n",
    144                           vecx[0].elements.Flt[BinMin], BinMin,
    145                           vecy[0].elements.Flt[BinMin]);
    146       return TRUE;
     158      if (SATURATE) {
     159        _threshold_set_values (vecy[0].elements.Flt[BinMin], BinMin, vecx[0].elements.Flt[BinMin], 1);
     160        return TRUE;
     161      } else {
     162        gprint (GP_ERR, "ERROR: all values below threshold\n");
     163        _threshold_set_values (NAN, -1, NAN, 1);
     164        return FALSE;
     165      }
    147166    }
    148167    if (vecy[0].elements.Flt[BinMax] > value) {
    149       if (!QUIET) gprint (GP_ERR, "ERROR: all values above threshold\n");
    150       set_int_variable ("threshbin", BinMax);
    151       set_variable ("threshval", vecy[0].elements.Flt[BinMax]);
    152       set_variable ("threshold", vecx[0].elements.Flt[BinMax]);
    153       set_int_variable ("thresherr", 1);
    154       if (!QUIET) gprint (GP_LOG, "theshold %f (bin %d is %f)\n",
    155                           vecx[0].elements.Flt[BinMax], BinMax,
    156                           vecy[0].elements.Flt[BinMax]);
    157       return TRUE;
     168      if (SATURATE) {
     169        _threshold_set_values (vecy[0].elements.Flt[BinMax], BinMax, vecx[0].elements.Flt[BinMax], 1);
     170        return TRUE;
     171      } else {
     172        gprint (GP_ERR, "ERROR: all values above threshold\n");
     173        _threshold_set_values (NAN, -1, NAN, 1);
     174        return FALSE;
     175      }
    158176    }
    159177    while (Nhi - Nlo > 10) {
     
    202220  }
    203221
    204   set_variable ("threshval", y1);
    205   set_variable ("threshold", Xvalue);
    206   set_int_variable ("threshbin", Nhi);
    207   set_int_variable ("thresherr", 0);
    208 
    209   if (!QUIET) gprint (GP_LOG, "theshold %f (bin %d is %f)\n", Xvalue, Nhi, y1);
    210 
     222  _threshold_set_values (y1, Nhi, Xvalue, 0);
    211223  return (TRUE);
    212224}
  • branches/eam_branches/ipp-20220316/Ohana/src/opihi/include/data.h

    r41891 r42361  
    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
  • branches/eam_branches/ipp-20220316/Ohana/src/opihi/lib.data/spline.c

    r41341 r42361  
    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);
  • branches/eam_branches/ipp-20220316/Ohana/src/opihi/lib.shell/parse.c

    r42268 r42361  
    124124      free (B);
    125125
     126      // XXX make this error output conditional
    126127      if (filestatus) gprint (GP_ERR, "warning: exit status of command %d\n", filestatus);
    127128      set_int_variable ("EXECSTATUS", filestatus);
  • branches/eam_branches/ipp-20220316/Ohana/src/opihi/lib.shell/stack_math.c

    r42165 r42361  
    16191619  OUT[0].vector = InitVector ();
    16201620  OUT[0].type = ST_VECTOR_TMP; /*** <<--- says this is a temporary matrix ***/
     1621
     1622  if (V1->vector->type == OPIHI_STR) {
     1623    ResetVector (OUT->vector, V1->vector->type, V1->vector->Nelements);
     1624    for (i = 0; i < V1->vector->Nelements; i++) {
     1625      OUT->vector->elements.Str[i] = strcreate (V1->vector->elements.Str[i]);
     1626    }
     1627    goto escape;
     1628  }
    16211629
    16221630# define V_FUNC(OP,FTYPE) {                                             \
  • branches/eam_branches/ipp-20220316/Ohana/src/relastro/src

  • branches/eam_branches/ipp-20220316/Ohana/src/relphot

Note: See TracChangeset for help on using the changeset viewer.