IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 6, 2012, 6:32:19 PM (14 years ago)
Author:
watersc1
Message:

merge from trunk. Preliminary versions of stacktool/warptool updates and regenerate_background.pl script. The warp code is finished and tested, and I still need to get the stack version resolved.

Location:
branches/czw_branch/20120906/Ohana
Files:
2 deleted
15 edited
4 copied

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20120906/Ohana

  • branches/czw_branch/20120906/Ohana/src/opihi

    • Property svn:mergeinfo deleted
  • branches/czw_branch/20120906/Ohana/src/opihi/cmd.data

  • branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/Makefile

    r33662 r34772  
    114114$(SRC)/shift.$(ARCH).o          \
    115115$(SRC)/sort.$(ARCH).o           \
    116 $(SRC)/spline_apply.$(ARCH).o   \
    117 $(SRC)/spline_construct.$(ARCH).o \
     116$(SRC)/spline.$(ARCH).o         \
     117$(SRC)/spline_commands.$(ARCH).o \
     118$(SRC)/imspline_apply.$(ARCH).o \
     119$(SRC)/imspline_construct.$(ARCH).o \
    118120$(SRC)/imstats.$(ARCH).o           \
    119121$(SRC)/style.$(ARCH).o             \
  • branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/box.c

    r27790 r34772  
    149149 usage:
    150150  gprint (GP_ERR, "USAGE: box [-ticks NNNN] [-axis NNNN] [-labels NNNN]\n");
     151
     152  gprint (GP_ERR, "  additional options:\n");
     153  gprint (GP_ERR, "  -fn (font) (size) : set font used for box\n");
     154  gprint (GP_ERR, "  -lw (weight) : set box line weight\n");
     155  gprint (GP_ERR, "  -c (color) : set box color\n");
     156  gprint (GP_ERR, "  \n");
     157  gprint (GP_ERR, "  for the descriptions below:\n");
     158  gprint (GP_ERR, "    -x refers to the bottom x-axis, \n");
     159  gprint (GP_ERR, "    -y refers to the left y-axis, \n");
     160  gprint (GP_ERR, "    +x refers to the top x-axis, \n");
     161  gprint (GP_ERR, "    +y refers to the right y-axis, \n");
     162  gprint (GP_ERR, "  \n");
     163  gprint (GP_ERR, "  -ticks [NNNN]  : turn on (1), off (0), or use default for ticks\n");
     164  gprint (GP_ERR, "  -labels [NNNN] : turn on (1), off (0), or use default for label\n");
     165  gprint (GP_ERR, "  -axis [NNNN]   : turn on (1), off (0), or use default for axis\n");
     166  gprint (GP_ERR, "    the order for the NNNN values in the above options is: -x, -y, +x, +y\n");
     167  gprint (GP_ERR, "  \n");
     168  gprint (GP_ERR, "  -tickpad : set the spacing between the ticks and the tick text \n");
     169  gprint (GP_ERR, "  \n");
     170  gprint (GP_ERR, "  the following set the spacing between the label and the given axis:\n");
     171  gprint (GP_ERR, "    -labelpadx, -labelpady, +labelpadx, +labelpady\n");
     172  gprint (GP_ERR, "  \n");
     173  gprint (GP_ERR, "  -pad : set the spacing between the plot section boundary and the axes\n");
     174  gprint (GP_ERR, "         alternatively, set each axis independently with:\n");
     175  gprint (GP_ERR, "        -xpad, -ypad, +xpad, +ypad\n");
     176
    151177  return (FALSE);
    152178}
  • branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/dbconnect.c

    r27435 r34772  
    3333  password[i] = 0;
    3434# endif
     35
     36  // XXX do I need to call mysql_library_init()?
    3537
    3638  mysql_init (&mysql);
  • branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/dbselect.c

    r20936 r34772  
    6161  ALLOCATE (vec, Vector *, Ncols);
    6262  for (i = 0; i < Ncols; i++) {
    63     if ((vec[i] = SelectVector (fields[i].name, ANYVECTOR, TRUE)) == NULL) {
    64       gprint (GP_ERR, "trouble creating vector named %s\n", fields[i].name);
     63    char *name = fields[i].name ? fields[i].name : fields[i].org_name;
     64    if ((vec[i] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) {
     65      gprint (GP_ERR, "trouble creating vector named %s\n", name);
    6566      free (query);
    6667      free (vec);
  • branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/grid.c

    r26258 r34772  
    178178  graphmode.ptype = 100; /* connect a pair */
    179179  graphmode.etype = 0;
    180   PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);
     180  PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
    181181
    182182  free (Xvec.elements.Flt);
  • branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/init.c

    r33662 r34772  
    102102int shift            PROTO((int, char **));
    103103int sort_vectors     PROTO((int, char **));
    104 int spline_apply_cmd PROTO((int, char **));
    105 int spline_construct_cmd PROTO((int, char **));
     104int spline_command   PROTO((int, char **));
     105int imspline_apply   PROTO((int, char **));
     106int imspline_construct PROTO((int, char **));
    106107int stats            PROTO((int, char **));
    107108int imstats          PROTO((int, char **));
     
    254255  {1, "shift",        shift,            "shift data in an image"},
    255256  {1, "sort",         sort_vectors,     "sort list of vectors"},
    256   {1, "spline.apply", spline_apply_cmd, "apply spline fit to generate an image"},
    257   {1, "spline.const", spline_construct_cmd, "create spline 2nd deriv. terms"},
     257  {1, "spline",       spline_command,   "shift data in an image"},
     258  {1, "imspline.apply", imspline_apply, "apply spline fit to generate an image"},
     259  {1, "imspline.const", imspline_construct, "create spline 2nd deriv. terms"},
    258260  {1, "stats",        imstats,          "statistics on a portion of an image"},
    259261  {1, "style",        style,            "set the style for graph plots"},
  • branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/plot.c

    r32346 r34772  
    33int plot (int argc, char **argv) {
    44 
    5   int kapa, N, Npts;
     5  char *out;
     6  int kapa, N, Npts, valid, size, i;
    67  Graphdata graphmode;
    78  Vector *xvec, *yvec, *dxmvec, *dxpvec, *dymvec, *dypvec;
     
    3233  }
    3334
    34   if (argc != 3) {
     35  valid  = (argc == 3);
     36  valid |= (argc > 4) && !strcmp (argv[3], "where");
     37  if (!valid) {
    3538    gprint (GP_ERR, "USAGE: plot <x> <y> [style]\n");
     39    gprint (GP_ERR, "   OR: plot <x> <y> [style] where (condition)\n");
    3640    return (FALSE);
     41  }
     42
     43  // tvec is used for logical test (truth vector)
     44  Vector *tvec = NULL;
     45  char *mask = NULL;
     46  if (argc > 4) {
     47    out = dvomath (argc - 4, &argv[4], &size, 1);
     48    if (out == NULL) {
     49      print_error ();
     50      return FALSE;
     51    }
     52    if ((tvec = SelectVector (out, OLDVECTOR, TRUE)) == NULL) {
     53      gprint (GP_ERR, " invalid logic result\n");
     54      DeleteNamedVector (out);
     55      free (out);
     56      return (FALSE);
     57    }
    3758  }
    3859
     
    5374    return (FALSE);
    5475  }
     76  if (tvec && tvec[0].Nelements != yvec[0].Nelements) {
     77    gprint (GP_ERR, "logic test vector not the same length as data vectors\n");
     78    return (FALSE);
     79  }
    5580  if (dypvec && (dypvec->Nelements != xvec->Nelements)) goto mismatch;
    5681  if (dymvec && (dymvec->Nelements != xvec->Nelements)) goto mismatch;
     
    5984
    6085  Npts = xvec[0].Nelements;
    61   if (Npts == 0) return (TRUE);
     86  if (Npts == 0) {
     87    if (tvec) DeleteVector (tvec);
     88    return (TRUE);
     89  }
     90
     91  if (tvec) {
     92    Npts = 0;
     93    ALLOCATE (mask, char, tvec->Nelements);
     94    for (i = 0; i < tvec->Nelements; i++) {
     95      mask[i] = (tvec->type == OPIHI_FLT) ? (tvec->elements.Flt[i] == 0.0) : (tvec->elements.Int[i] == 0.0);
     96      if (!mask[i]) Npts ++;
     97    }
     98    if (Npts == 0) {
     99      DeleteVector (tvec);
     100      free (mask);
     101      return TRUE;
     102    }
     103  }
    62104
    63105  if (!KapaPrepPlot (kapa, Npts, &graphmode)) return (FALSE);
    64106 
    65   PlotVectorSingle (kapa, xvec, "x");
    66   PlotVectorSingle (kapa, yvec, "y");
     107  PlotVectorSingle (kapa, xvec, mask, "x");
     108  PlotVectorSingle (kapa, yvec, mask, "y");
    67109  if (graphmode.etype & 0x01) {
    68     PlotVectorSingle (kapa, dymvec, "dym");
    69     PlotVectorSingle (kapa, dypvec, "dyp");
     110    PlotVectorSingle (kapa, dymvec, mask, "dym");
     111    PlotVectorSingle (kapa, dypvec, mask, "dyp");
    70112  }
    71113  if (graphmode.etype & 0x02) {
    72     PlotVectorSingle (kapa, dxmvec, "dxm");
    73     PlotVectorSingle (kapa, dxpvec, "dxp");
     114    PlotVectorSingle (kapa, dxmvec, mask, "dxm");
     115    PlotVectorSingle (kapa, dxpvec, mask, "dxp");
     116  }
     117
     118  if (tvec) {
     119    free (mask);
     120    DeleteVector (tvec);
    74121  }
    75122  return (TRUE);
  • branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/read_vectors.c

    r33662 r34772  
    2222
    2323// vector types
    24 enum {COLTYPE_NONE, COLTYPE_FLT, COLTYPE_INT, COLTYPE_TIME};
     24enum {COLTYPE_NONE, COLTYPE_FLT, COLTYPE_INT, COLTYPE_TIME, COLTYPE_CHAR};
    2525
    2626int read_vectors (int argc, char **argv) {
     
    3030  int i, j, Nskip, Narg, Nvec, *col, IsCSV, VERBOSE;
    3131  int Nbytes, Nstart, NELEM, Nelem, nread, *coltype;
    32   char *colstr, *c0, *c1, *buffer, *extname;
     32  char *colstr, *c0, *c1, *extname;
    3333  Vector **vec;
     34
     35  char *buffer = NULL;
    3436
    3537  /* auto-sense table type */
     
    101103      if (!strcasecmp(ptr, "float")) { coltype[i] = COLTYPE_FLT; }
    102104      if (!strcasecmp(ptr, "int"))   { coltype[i] = COLTYPE_INT; }
     105      if (!strcasecmp(ptr, "char"))  { coltype[i] = COLTYPE_CHAR; }
    103106      if (!strcasecmp(ptr, "time"))  { coltype[i] = COLTYPE_TIME; }
    104107      if (!coltype[i]) goto bad_colname;
     
    143146  NELEM = 1000;
    144147  for (i = 0; i < Nvec; i++) {
    145     if (coltype[i] == COLTYPE_INT) {
     148    if ((coltype[i] == COLTYPE_INT) || (coltype[i] == COLTYPE_CHAR)) {
    146149      ResetVector (vec[i], OPIHI_INT, NELEM);
    147150    } else {
     
    154157  bzero (buffer, 0x10001);
    155158  for (i = 0; i < Nskip; i++) {
    156     scan_line (f, buffer);
     159    if (scan_line_maxlen (f, buffer, 0x10000) == EOF) {
     160      gprint (GP_ERR, "problem reading file %s\n", filename);
     161      free (vec);
     162      free (col);
     163      return FALSE;
     164    }
    157165  }
    158166
     
    178186    while (bufferStatus) {
    179187      c1 = strchr (c0, '\n'); // find the end of this current line
     188      if (!c1) {
     189        c1 = strchr (c0, '\r'); // try \r for non-UNIX files (what do we do about a Mac? \n\r?)
     190      }
    180191      if (c1 == (char *) NULL) {
    181192        Nstart = strlen (c0);
     
    195206      for (i = 0; i < Nvec; i++) {
    196207        int ivalue;
     208        char cvalue;
    197209        double dvalue;
    198210        time_t tvalue;
     
    203215            readStatus = IsCSV ? iparse_csv (&ivalue, col[i], c0) : iparse (&ivalue, col[i], c0);
    204216            vec[i][0].elements.Int[Nelem] = readStatus ? ivalue : 0;
     217            break;
     218          case COLTYPE_CHAR:
     219            readStatus = IsCSV ? charparse_csv (&cvalue, col[i], c0) : charparse (&cvalue, col[i], c0);
     220            vec[i][0].elements.Int[Nelem] = readStatus ? cvalue : 0;
    205221            break;
    206222          case COLTYPE_FLT:
     
    254270  free (vec);
    255271  free (col);
    256   free (buffer);
     272  if (buffer) free (buffer);
    257273  return (TRUE);
    258274
  • branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/reindex.c

    r33662 r34772  
    55int reindex (int argc, char **argv) {
    66 
    7   int  i, Npts, Nmax;
     7  int  i, Nmax, N;
    88  Vector *ivec, *ovec, *xvec;
    99
    1010  ivec = ovec = xvec = NULL;
    11   Npts = 0;
     11  int Npts = 0;
     12
     13  int KEEP_UNMATCH = FALSE;
     14  if ((N = get_argument (argc, argv, "-keep-unmatched"))) {
     15    remove_argument (N, &argc, argv);
     16    KEEP_UNMATCH = TRUE;
     17  }
    1218
    1319  if (argc != 6) goto usage;
     
    2228
    2329  // ovec matches ivec in type and xvec in size (xvec need not have all ivec elements, and may have duplicates
     30  int NPTS = xvec[0].Nelements;
    2431  ResetVector (ovec, ivec->type, xvec[0].Nelements);
    2532
     
    3138    opihi_int *vx = xvec[0].elements.Int;
    3239    for (Npts = i = 0; i < xvec[0].Nelements; i++, vx++) {
    33       if (*vx == -1) continue;
    34       if (*vx < 0) ESCAPE("unexpected value in index: %d (%d)\n", *vx, i);
     40      if (Npts >= NPTS) {
     41        NPTS += 2000;
     42        REALLOCATE (ovec[0].elements.Flt, opihi_flt, NPTS);
     43      }
     44      if (*vx < 0) {
     45        if (KEEP_UNMATCH) {
     46          ovec[0].elements.Flt[Npts] = NAN;
     47          Npts++;
     48        }
     49        continue;
     50      }
    3551      if (*vx > Nmax) ESCAPE("unexpected value in index: %d (%d)\n", *vx, i);
    3652      ovec[0].elements.Flt[Npts] = vi[*vx];
     
    4258    opihi_int *vx = xvec[0].elements.Int;
    4359    for (Npts = i = 0; i < xvec[0].Nelements; i++, vx++) {
    44       if (*vx == -1) continue;
    45       if (*vx < 0) ESCAPE("unexpected value in index: %d (%d)\n", *vx, i);
     60      if (Npts >= NPTS) {
     61        NPTS += 2000;
     62        REALLOCATE (ovec[0].elements.Int, opihi_int, NPTS);
     63      }
     64      if (*vx < 0) {
     65        if (KEEP_UNMATCH) {
     66          ovec[0].elements.Flt[Npts] = -1;
     67          Npts++;
     68        }
     69        continue;
     70      }
    4671      if (*vx > Nmax) ESCAPE("unexpected value in index: %d (%d)\n", *vx, i);
    4772      ovec[0].elements.Int[Npts] = vi[*vx];
     
    6085usage:
    6186    gprint (GP_ERR, "USAGE: reindex (out) = (in) using (index)\n");
    62     gprint (GP_ERR, "  creates a new vectors (out) from (in) based on sequence in (index)\n");
     87    gprint (GP_ERR, "  Creates a new vector (out) from (in) based on sequence in (index)\n");
     88    gprint (GP_ERR, "  output[i] = input[index[i]]\n");
     89    gprint (GP_ERR, "  If -keep-unmatched is provided, elements of index with negative values will be set to NaN / -1,\n");
     90    gprint (GP_ERR, "    otherwise they will be skipped in the output.\n");
     91    gprint (GP_ERR, "  The output vector has the type of the input vector and the length of the index (if -keep-unmatched).\n");
     92    gprint (GP_ERR, "  The index vector may have duplicates\n");
    6393    return (FALSE);
    6494}
  • branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/subset.c

    r30610 r34772  
    1313  Npts = 0;
    1414
     15  if (argc < 6) {
     16    gprint (GP_ERR, "SYNTAX: subset vec = vec [if/where] (logic expression)\n");
     17    return (FALSE);
     18  }
     19
    1520  valid = TRUE;
    16   valid &= (argc >= 6);
    1721  valid &= !strcmp(argv[2], "=");
    1822  valid &= !strcmp(argv[4], "if") || !strcmp (argv[4], "where");
  • branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/write_vectors.c

    r33963 r34772  
    9999  }
    100100
    101   /* open file for outuput */
     101  /* open file for output */
    102102  if (append) {
    103103    f = fopen (argv[1], "a");
  • branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/zplot.c

    r31667 r34772  
    33int zplot (int argc, char **argv) {
    44 
    5   int i, kapa;
     5  char *outname = NULL;
     6  int i, kapa, valid, size;
    67  opihi_flt *out;
    78  double min, range;
     
    1112  if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE);
    1213
    13   if (argc != 6) {
     14  valid  = (argc == 6);
     15  valid |= (argc > 7) && !strcmp (argv[6], "where");
     16  if (!valid) {
    1417    gprint (GP_ERR, "USAGE: zplot <x> <y> <z> min max\n");
     18    gprint (GP_ERR, "   OR: zplot <x> <y> <z> min max where (condition)\n");
    1519    return (FALSE);
    1620  }
     
    1822  min = atof(argv[4]);
    1923  range = atof(argv[5]) - min;
     24
     25  // tvec is used for logical test (truth vector)
     26  Vector *tvec = NULL;
     27  char *mask = NULL;
     28  if (argc > 7) {
     29    outname = dvomath (argc - 7, &argv[7], &size, 1);
     30    if (outname == NULL) {
     31      print_error ();
     32      return FALSE;
     33    }
     34    if ((tvec = SelectVector (outname, OLDVECTOR, TRUE)) == NULL) {
     35      gprint (GP_ERR, " invalid logic result\n");
     36      DeleteNamedVector (outname);
     37      free (outname);
     38      return (FALSE);
     39    }
     40  }
    2041
    2142  /* find vectors */
     
    2950  if (xvec[0].Nelements != zvec[0].Nelements) {
    3051    gprint (GP_ERR, "vectors %s and %s not the same length\n", argv[1], argv[3]);
     52    return (FALSE);
     53  }
     54  if (tvec && tvec[0].Nelements != yvec[0].Nelements) {
     55    gprint (GP_ERR, "logic test vector not the same length as data vectors\n");
    3156    return (FALSE);
    3257  }
     
    4671  }
    4772
     73  if (tvec) {
     74    ALLOCATE (mask, char, tvec->Nelements);
     75    for (i = 0; i < tvec->Nelements; i++) {
     76      mask[i] = (tvec->type == OPIHI_FLT) ? (tvec->elements.Flt[i] == 0.0) : (tvec->elements.Int[i] == 0.0);
     77    }
     78  }
     79
    4880  /* point size determined by Zvec */
    4981  graphmode.style = 2; /* plot points */
    5082  graphmode.size = -1; /* point size determined by Zvec */
    5183  graphmode.etype = 0; /* no errorbars */
    52   PlotVectorTriplet (kapa, xvec, yvec, &Zvec, &graphmode);
     84  PlotVectorTriplet (kapa, xvec, yvec, &Zvec, mask, &graphmode);
    5385
    5486  free (Zvec.elements.Ptr);
     87  if (mask) free (mask);
     88  DeleteNamedVector (outname);
    5589
    5690  return (TRUE);
     
    6094int zcplot (int argc, char **argv) {
    6195 
    62   int i, kapa;
     96  char *outname = NULL;
     97  int i, kapa, valid, size;
    6398  opihi_flt *out;
    6499  double min, range;
     
    68103  if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE);
    69104
    70   if (argc != 6) {
    71     gprint (GP_ERR, "USAGE: zplot <x> <y> <z> min max\n");
     105  valid  = (argc == 6);
     106  valid |= (argc > 7) && !strcmp (argv[6], "where");
     107  if (!valid) {
     108    gprint (GP_ERR, "USAGE: zcplot <x> <y> <z> min max\n");
     109    gprint (GP_ERR, "   OR: zcplot <x> <y> <z> min max where (condition)\n");
    72110    return (FALSE);
    73111  }
     
    75113  min = atof(argv[4]);
    76114  range = atof(argv[5]) - min;
     115
     116  // tvec is used for logical test (truth vector)
     117  Vector *tvec = NULL;
     118  char *mask = NULL;
     119  if (argc > 7) {
     120    outname = dvomath (argc - 7, &argv[7], &size, 1);
     121    if (outname == NULL) {
     122      print_error ();
     123      return FALSE;
     124    }
     125    if ((tvec = SelectVector (outname, OLDVECTOR, TRUE)) == NULL) {
     126      gprint (GP_ERR, " invalid logic result\n");
     127      DeleteNamedVector (outname);
     128      free (outname);
     129      return (FALSE);
     130    }
     131  }
    77132
    78133  /* find vectors */
     
    86141  if (xvec[0].Nelements != zvec[0].Nelements) {
    87142    gprint (GP_ERR, "vectors %s and %s not the same length\n", argv[1], argv[3]);
     143    return (FALSE);
     144  }
     145  if (tvec && tvec[0].Nelements != yvec[0].Nelements) {
     146    gprint (GP_ERR, "logic test vector not the same length as data vectors\n");
    88147    return (FALSE);
    89148  }
     
    103162  }
    104163
     164  if (tvec) {
     165    ALLOCATE (mask, char, tvec->Nelements);
     166    for (i = 0; i < tvec->Nelements; i++) {
     167      mask[i] = (tvec->type == OPIHI_FLT) ? (tvec->elements.Flt[i] == 0.0) : (tvec->elements.Int[i] == 0.0);
     168    }
     169  }
     170
    105171  /* point size determined by Zvec */
    106172  graphmode.style = 2; /* plot points */
    107173  graphmode.color = -1; /* point color determined by Zvec */
    108174  graphmode.etype = 0; /* no errorbars */
    109   PlotVectorTriplet (kapa, xvec, yvec, &Zvec, &graphmode);
     175  PlotVectorTriplet (kapa, xvec, yvec, &Zvec, mask, &graphmode);
    110176
    111177  free (Zvec.elements.Ptr);
     178  if (mask) free (mask);
     179  DeleteNamedVector (outname);
    112180
    113181  return (TRUE);
Note: See TracChangeset for help on using the changeset viewer.