IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 8, 2023, 12:17:35 PM (3 years ago)
Author:
eugene
Message:

merge from eam_branches/ipp-20220316. fixes for more pendantic gcc; add opihi memory stats; string vector improvements; use named macros for fixed string lengths

Location:
trunk/Ohana
Files:
15 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/Ohana

  • trunk/Ohana/src/opihi/cmd.data/Makefile

    r42128 r42389  
    140140$(SRC)/radial.$(ARCH).o \
    141141$(SRC)/rd.$(ARCH).o             \
     142$(SRC)/rdjpg.$(ARCH).o          \
    142143$(SRC)/rdseg.$(ARCH).o          \
    143144$(SRC)/read_vectors.$(ARCH).o   \
     
    154155$(SRC)/set.$(ARCH).o            \
    155156$(SRC)/shift.$(ARCH).o          \
     157$(SRC)/opihi_size.$(ARCH).o        \
    156158$(SRC)/sort.$(ARCH).o           \
    157159$(SRC)/spline.$(ARCH).o         \
  • trunk/Ohana/src/opihi/cmd.data/cursor.c

    r39457 r42389  
    4242    KiiCursorRead (kapa, &X, &Y, &Z, &R, &D, key);
    4343
    44     sprintf (string, "X%s", key);
    45     set_variable (string, X);
    46     sprintf (string, "Y%s", key);
    47     set_variable (string, Y);
    48     sprintf (string, "Z%s", key);
    49     set_variable (string, Z);
    50     sprintf (string, "R%s", key);
    51     set_variable (string, R);
    52     sprintf (string, "D%s", key);
    53     set_variable (string, D);
     44    snprintf_nowarn (string, 20, "X%s", key);    set_variable (string, X);
     45    snprintf_nowarn (string, 20, "Y%s", key);    set_variable (string, Y);
     46    snprintf_nowarn (string, 20, "Z%s", key);    set_variable (string, Z);
     47    snprintf_nowarn (string, 20, "R%s", key);    set_variable (string, R);
     48    snprintf_nowarn (string, 20, "D%s", key);    set_variable (string, D);
    5449
    5550    set_str_variable ("KEY", key);
  • trunk/Ohana/src/opihi/cmd.data/init.c

    r42128 r42389  
    126126int queue2book       PROTO((int, char **));
    127127int rd               PROTO((int, char **));
     128int rdjpg            PROTO((int, char **));
    128129int rdseg            PROTO((int, char **));
    129130int read_vectors     PROTO((int, char **));
     
    160161int tvgrid           PROTO((int, char **));
    161162int opihi_type       PROTO((int, char **));
     163int opihi_size       PROTO((int, char **));
    162164int uniq             PROTO((int, char **));
    163165int uniqpair         PROTO((int, char **));
     
    336338  {1, "ipptool2book", queue2book,       "convert queue with ipptool output to book"},
    337339  {1, "rd",           rd,               "load fits image"},
     340  {1, "rdjpg",        rdjpg,            "load jpeg image"},
    338341  {1, "rdseg",        rdseg,            "read a segment of an image from a file"},
    339342  {1, "read",         read_vectors,     "read vectors from datafile"},
     
    350353  {1, "set",          set,              "image and vector math"},
    351354  {1, "shift",        shift,            "shift data in an image"},
     355  {1, "size",         opihi_size,       "get vector/matrix dimension/size information"},
    352356  {1, "sort",         sort_vectors,     "sort list of vectors"},
    353357  {1, "spline",       spline_command,   "shift data in an image"},
  • trunk/Ohana/src/opihi/cmd.data/limits.c

    r40291 r42389  
    6161    APPLY = TRUE;
    6262  }
     63
    6364  char *name = NULL;
    6465  if ((N = get_argument (argc, argv, "-n"))) {
     
    6768    remove_argument (N, &argc, argv);
    6869  }
    69 
    7070  if (!GetGraph (&graphmode, &kapa, name)) return (FALSE);
    7171  FREE (name);
     72
     73  // this is not super intuitive
     74  if ((N = get_argument (argc, argv, "-boxsize"))) {
     75    remove_argument (N, &argc, argv);
     76    float dx, dy;
     77    // ask kapa for the size of the graph region in pixels
     78    KapaGetLimits (kapa, &dx, &dy);
     79    set_variable ("KAPA_XPIX", fabs(dx));
     80    set_variable ("KAPA_YPIX", fabs(dy));
     81  }
    7282
    7383  // XXX need an option to set the limits based on the current image bounds
     
    169179  return (TRUE);
    170180}
     181
     182/* -minX value : the minimum X axis value will be no higher than this value
     183   -maxX value : the maximum X axis value will be no lower than this value
     184   -delX value : the range of the X axis will be at least this value
     185
     186   These can be used to prevent the range from collapsing. 
     187   These are only used if the -a option is supplied, otherwise the supplied or auto-calculated
     188   ranges are used (this seems like an poor choice)
     189
     190*/
     191
     192
     193   
  • trunk/Ohana/src/opihi/cmd.data/read_vectors.c

    r42082 r42389  
    385385      if (!lineStatus && VERBOSE) {
    386386        char temp[32];
    387         strncpy (temp, c0, 32);
    388         temp[31] = 0;
     387        strncpy_nowarn (temp, c0, 31);
    389388        gprint (GP_ERR, "skip line %s\n\n", temp);
    390389      }
  • trunk/Ohana/src/opihi/cmd.data/reindex.c

    r42082 r42389  
    7272    }
    7373  }
     74  if (ivec->type == OPIHI_STR) {
     75    opihi_int *vx = xvec[0].elements.Int;
     76    for (Npts = i = 0; i < xvec[0].Nelements; i++, vx++) {
     77      if (Npts >= NPTS) {
     78        NPTS += 2000;
     79        REALLOCATE (ovec[0].elements.Str, char *, NPTS);
     80      }
     81      if (*vx < 0) {
     82        if (KEEP_UNMATCH) {
     83          ovec[0].elements.Str[Npts] = strcreate(""); // XXX use a different or a specified value?
     84          Npts++;
     85        }
     86        continue;
     87      }
     88      if (*vx > Nmax) ESCAPE("unexpected value in index: "OPIHI_INT_FMT" (%d)\n", *vx, i);
     89      ovec[0].elements.Str[Npts] = strcreate(ivec->elements.Str[*vx]);
     90      Npts++;
     91    }
     92  }
    7493
    7594  // free up unused memory
  • trunk/Ohana/src/opihi/cmd.data/subset.c

    r42311 r42389  
    4444  ResetVector (ovec, ivec->type, tvec[0].Nelements);
    4545
    46   // we have four cases: (ivec == flt or int) and (tvec == flt or int)
     46  // we have size cases: (ivec == flt, int, str) and (tvec == flt or int)
    4747  if ((ivec->type == OPIHI_FLT) && (tvec->type == OPIHI_FLT)) {
    4848    opihi_flt *vi = ivec[0].elements.Flt;
     
    8181    }
    8282  }
     83  // XXX if ivec is an existing vector, this step will
     84  // leak (existing elements need to be freed if they
     85  // have been allocated).
    8386  if ((ivec->type == OPIHI_STR) && (tvec->type == OPIHI_FLT)) {
    8487    opihi_flt *vt = tvec[0].elements.Flt;
    8588    for (Npts = i = 0; i < tvec[0].Nelements; i++, vt++) {
    8689      if (!*vt) continue;
    87       ovec[0].elements.Str[Npts] = strcreate (ivec[0].elements.Str[i]);
     90      ovec[0].elements.Str[Npts] = strcreate(ivec[0].elements.Str[i]);
    8891      Npts++;
    8992    }
     
    9396    for (Npts = i = 0; i < tvec[0].Nelements; i++, vt++) {
    9497      if (!*vt) continue;
    95       ovec[0].elements.Str[Npts] = strcreate (ivec[0].elements.Str[i]);
     98      ovec[0].elements.Str[Npts] = strcreate(ivec[0].elements.Str[i]);
    9699      Npts++;
    97100    }
  • trunk/Ohana/src/opihi/cmd.data/svd.c

    r29540 r42389  
    5858
    5959  // try C.R. Bond's version -- requires matrices in the form A[row][col] not A[row*Ncol + col]
    60   if (1) {
     60  if (0) {
    6161      int j;
    6262      double **a, **u, **v, *q;
  • trunk/Ohana/src/opihi/cmd.data/test/histogram.sh

    r20936 r42389  
    3535 local i
    3636
    37  list word -x "ps -p $PID -o rss"
    38  $startmem = $word:1
     37 create xhis 0 10 0.1
     38 $i = 1
     39
     40 memory stats
     41 $startmem = $memory:Ntotal
    3942
    4043 for i 0 1000
     
    4245 end
    4346 
    44  list word -x "ps -p $PID -o rss"
    45  $endmem = $word:1
     47 memory stats
     48 $endmem = $memory:Ntotal
    4649
    4750 $PASS = 1
  • trunk/Ohana/src/opihi/cmd.data/test/join.sh

    r36084 r42389  
    2121
    2222 join ID1 ID2
    23 
    24 mana: for i 0 index1[]
    25 >> echo index1[$i] index2[$i]
    26 >> end
    27 0 2
    28 2 1
    29 4 0
    30 5 3
    31 mana: join ID1 ID2 -outer
    32 mana: vectors
    33     N       name      size
    34     0        ID1          6 (INT)
    35     1       val1          6 (FLT)
    36     2        ID2          4 (INT)
    37     3        val          4 (FLT)
    38     4     index1          6 (INT)
    39     5     index2          4 (INT)
    40 mana: for i 0 index1[]
    41 >> echo index1[$i]
    42 >> end
    43 2
    44 -1
    45 1
    46 -1
    47 0
    48 3
    49 mana: echo ID1[2]
    50 3
    51 mana: echo ID1[0] ID2[2]
    52 1 1
    53 mana: for i 0 index1[]
    54 >> if (index1[$i] == -1) continue
    55 >> $N = index1[$i]
    56 >> echo $i index1[$i] ID1[$i] ID2[$N]
    57 >> end
    58 0 2 1 1
    59 2 1 3 3
    60 4 0 5 5
    61 5 3 6 6
    62 mana: for i 0 index2[]
    63 >> if (index2[$i] == -1) continue
    64 >> $N = index2[$i]
    65 >> echo $i index2[$i] ID2[$i] ID1[$N]
    66 >> end
    67 0 4 5 5
    68 1 2 3 3
    69 2 0 1 1
    70 3 5 6 6
    71 mana:
    72 
    73  # if ((xvec[1024] != 17) || (yvec[1024] != 100))
    74  #  $PASS = 0
    75  #  echo "Value mismatch: xvec[1024] yvec[1024] (should be 17,100)"
    76  # end
    77  #
    78  # imhist -q buff xvec yvec -region 40 0 25 10 -range 0 10
    79  #
    80  # if ((xvec[1024] != 10) || (yvec[1024] != 100))
    81  #  $PASS = 0
    82  #  echo "Value mismatch: xvec[1024] yvec[1024] (should be 10,100)"
    83  # end
    8423
    8524end
  • trunk/Ohana/src/opihi/cmd.data/threshold.c

    r42277 r42389  
    33int QUIET = FALSE;
    44
    5 void _threshold_set_values (double value, int Nbin, double level) {
     5void _threshold_set_values (double value, int Nbin, double level, int thresherr) {
    66
    77  set_variable ("threshval", value);
    88  set_int_variable ("threshbin", Nbin);
    99  set_variable ("threshold", level);
     10  set_int_variable ("thresherr", thresherr);
    1011
    1112  if (!QUIET) gprint (GP_LOG, "theshold %f (bin %d is %f)\n", level, Nbin, value);
     
    117118    if (vecy[0].elements.Flt[BinMin] > value) {
    118119      if (SATURATE) {
    119         _threshold_set_values (vecy[0].elements.Flt[BinMin], BinMin, vecx[0].elements.Flt[BinMin]);
     120        _threshold_set_values (vecy[0].elements.Flt[BinMin], BinMin, vecx[0].elements.Flt[BinMin], 1);
    120121        return TRUE;
    121122      } else {
    122123        gprint (GP_ERR, "ERROR: all values above threshold\n");
    123         _threshold_set_values (NAN, -1, NAN);
     124        _threshold_set_values (NAN, -1, NAN, 1);
    124125        return FALSE;
    125126      }
     
    127128    if (vecy[0].elements.Flt[BinMax] < value) {
    128129      if (SATURATE) {
    129         _threshold_set_values (vecy[0].elements.Flt[BinMax], BinMax, vecx[0].elements.Flt[BinMax]);
     130        _threshold_set_values (vecy[0].elements.Flt[BinMax], BinMax, vecx[0].elements.Flt[BinMax], 1);
    130131        return TRUE;
    131132      } else {
    132133        gprint (GP_ERR, "ERROR: all values below threshold\n");
    133         _threshold_set_values (NAN, -1, NAN);
     134        _threshold_set_values (NAN, -1, NAN, 1);
    134135        return FALSE;
    135136      }
     
    156157    if (vecy[0].elements.Flt[BinMin] < value) {
    157158      if (SATURATE) {
    158         _threshold_set_values (vecy[0].elements.Flt[BinMin], BinMin, vecx[0].elements.Flt[BinMin]);
     159        _threshold_set_values (vecy[0].elements.Flt[BinMin], BinMin, vecx[0].elements.Flt[BinMin], 1);
    159160        return TRUE;
    160161      } else {
    161162        gprint (GP_ERR, "ERROR: all values below threshold\n");
    162         _threshold_set_values (NAN, -1, NAN);
     163        _threshold_set_values (NAN, -1, NAN, 1);
    163164        return FALSE;
    164165      }
     
    166167    if (vecy[0].elements.Flt[BinMax] > value) {
    167168      if (SATURATE) {
    168         _threshold_set_values (vecy[0].elements.Flt[BinMax], BinMax, vecx[0].elements.Flt[BinMax]);
     169        _threshold_set_values (vecy[0].elements.Flt[BinMax], BinMax, vecx[0].elements.Flt[BinMax], 1);
    169170        return TRUE;
    170171      } else {
    171172        gprint (GP_ERR, "ERROR: all values above threshold\n");
    172         _threshold_set_values (NAN, -1, NAN);
     173        _threshold_set_values (NAN, -1, NAN, 1);
    173174        return FALSE;
    174175      }
     
    219220  }
    220221
    221   _threshold_set_values (y1, Nhi, Xvalue);
     222  _threshold_set_values (y1, Nhi, Xvalue, 0);
    222223  return (TRUE);
    223224}
  • trunk/Ohana/src/opihi/cmd.data/tvcolors.c

    r41341 r42389  
    4141    gprint (GP_ERR, "   f: 0 - 1 defines the scale value for the transition\n");
    4242    gprint (GP_ERR, "   R,G,B: 0 - 1 define the value of the color at the transition point\n");
     43
     44    gprint (GP_ERR, "   There are 5 colormap file format options:\n");
     45    gprint (GP_ERR, "   * file:filename : index Red Green Blue\n");
     46    gprint (GP_ERR, "   * lgcy:filename : index Red Blue Green\n");
     47    gprint (GP_ERR, "   * csvf:filename : index,Red,Green,Blue\n");
     48    gprint (GP_ERR, "   * cetf:filename : fRed,fGreen,fBlue \n");
     49    gprint (GP_ERR, "   * cetr:filename : fRed,fGreen,fBlue \n\n");
     50    gprint (GP_ERR, "   The index value goes from 0.0 to 1.0 and sets transitions (must be monotonic).\n");
     51    gprint (GP_ERR, "   In the CET cases, the index is implicit, with 256 entries expected.\n");
     52    gprint (GP_ERR, "   For cetr: the index is reversed.\n");
     53
    4354    return (FALSE);
    4455  }
  • trunk/Ohana/src/opihi/cmd.data/wd.c

    r41674 r42389  
    115115      Ns = strlen (simple);
    116116      No = 80 - Ns;
    117       strncpy (temp_header.buffer, simple, Ns);
     117      strncpy_nowarn (temp_header.buffer, simple, Ns);
    118118      memset (&temp_header.buffer[Ns], ' ', No);
    119119    }
     
    275275  return (f);
    276276}
    277 
    278 
    279 ///    /* fix up header */
    280 ///    {
    281 ///      static char simple[] = "XTENSION= 'IMAGE  '            / Image extension";
    282 ///      int Ns, No;
    283 ///      Ns = strlen (simple);
    284 ///      No = 80 - Ns;
    285 ///      strncpy (temp_header.buffer, simple, Ns);
    286 ///      memset (&temp_header.buffer[Ns], ' ', No);
    287 ///    }
    288 ///
    289 ///    /* position to end of file to write new extend */
    290 ///    fseeko (f, 0LL, SEEK_END);
    291 ///    nbytes = fwrite (temp_header.buffer, 1, temp_header.datasize, f);
    292 ///    fclose (f);
    293 ///    if (nbytes != temp_header.datasize) {
    294 ///      gprint (GP_ERR, "failed to write file\n");
    295 ///      status = FALSE;
    296 ///      goto done1;
    297 ///    }
    298 ///
    299 ///  }
  • trunk/Ohana/src/opihi/cmd.data/write_vectors.c

    r42127 r42389  
    214214    /* identify type (%NNNNd %NNNNf) */
    215215    for (p2 = p1 + 1; (*p2 == '.') || (*p2 == '-') || (*p2 == '+') || (*p2 == ' ') || isdigit(*p2); p2++);
    216     strncpy (fmtlist[j], p0, p2 - p0 + 1);
     216    strncpy_nowarn (fmtlist[j], p0, p2 - p0 + 1);
    217217    switch (*p2) {
    218218      case 'e':
Note: See TracChangeset for help on using the changeset viewer.