IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 21, 2014, 5:42:34 AM (12 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ps2-tc3-20130727
Files:
12 edited
10 copied

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ps2-tc3-20130727

  • branches/eam_branches/ps2-tc3-20130727/Ohana

    • Property svn:mergeinfo deleted
  • branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi

    • Property svn:mergeinfo deleted
  • branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.data

    • Property svn:mergeinfo deleted
  • branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.data/Makefile

    r35416 r36680  
    2525$(SRC)/book.$(ARCH).o           \
    2626$(SRC)/book_commands.$(ARCH).o  \
     27$(SRC)/cast.$(ARCH).o           \
    2728$(SRC)/center.$(ARCH).o \
    2829$(SRC)/clear.$(ARCH).o          \
     
    6364$(SRC)/imcut.$(ARCH).o          \
    6465$(SRC)/imhist.$(ARCH).o \
     66$(SRC)/impeaks.$(ARCH).o        \
    6567$(SRC)/imsmooth.$(ARCH).o       \
     68$(SRC)/imsmooth.generic.$(ARCH).o       \
     69$(SRC)/imsmooth.2d.$(ARCH).o    \
    6670$(SRC)/integrate.$(ARCH).o      \
    6771$(SRC)/interpolate.$(ARCH).o    \
     72$(SRC)/join.$(ARCH).o           \
    6873$(SRC)/jpeg.$(ARCH).o           \
    6974$(SRC)/kern.$(ARCH).o           \
     
    8489$(SRC)/mget.$(ARCH).o           \
    8590$(SRC)/minterpolate.$(ARCH).o   \
     91$(SRC)/medimage.$(ARCH).o       \
     92$(SRC)/medimage_commands.$(ARCH).o \
    8693$(SRC)/mset.$(ARCH).o           \
    8794$(SRC)/peak.$(ARCH).o           \
     
    143150$(SRC)/vmaxwell.$(ARCH).o          \
    144151$(SRC)/vgrid.$(ARCH).o             \
     152$(SRC)/vlist.$(ARCH).o             \
    145153$(SRC)/vload.$(ARCH).o             \
    146154$(SRC)/vzload.$(ARCH).o            \
  • branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.data/densify.c

    r34088 r36680  
    22
    33# define CHECKVAL(ARG) if (!isfinite(ARG)) { gprint (GP_ERR, "illegal value for %s: %f\n", #ARG, ARG); return (FALSE); }
     4enum {IS_DOT, IS_SQUARE, IS_CIRCLE, IS_GAUSS};
    45
    56int densify (int argc, char **argv) {
    67
    7   int i, Nx, Ny, Xb, Yb, N, Xpix, Ypix, good, UseGraph;
     8  int i, Nx, Ny, Xb, Yb, ix, iy, N, Xpix, Ypix, good, UseGraph;
    89  double Xmin, Xmax, dX, Ymin, Ymax, dY;
    910  float *val;
     
    2425  }
    2526
     27  float scale = 0.0;
     28  if ((N = get_argument (argc, argv, "-scale"))) {
     29    remove_argument (N, &argc, argv);
     30    scale = atof(argv[N]);
     31    remove_argument (N, &argc, argv);
     32  }
     33
     34  int PSFTYPE = IS_DOT;
     35  if ((N = get_argument (argc, argv, "-psf"))) {
     36    remove_argument (N, &argc, argv);
     37    if (!strcasecmp(argv[N], "dot"))    PSFTYPE = IS_DOT;
     38    if (!strcasecmp(argv[N], "square")) PSFTYPE = IS_SQUARE;
     39    if (!strcasecmp(argv[N], "circle")) PSFTYPE = IS_CIRCLE;
     40    if (!strcasecmp(argv[N], "gauss"))  PSFTYPE = IS_GAUSS;
     41    remove_argument (N, &argc, argv);
     42  }
     43
    2644  good = UseGraph ? (argc == 4) : (argc == 10);
    2745  if (!good) {
    2846    gprint (GP_ERR, "USAGE: densify buffer x y Xmin Xmax dX Ymin Ymax dY\n");
    2947    gprint (GP_ERR, "   OR: densify buffer x y -graph\n");
     48    gprint (GP_ERR, " option: -psf [dot] (circle) (square) (gauss)\n");
    3049    return (FALSE);
    3150  }
     
    6988  CHECKVAL(dY);
    7089
     90  float scaleX = (scale > 0.0) ? scale / dX : 3.0;
     91  float scaleY = (scale > 0.0) ? scale / dY : 3.0;
     92
    7193  Nx = (Xmax - Xmin) / dX + 1;
    7294  Ny = (Ymax - Ymin) / dY + 1;
     
    7698  CreateBuffer (bf, Nx, Ny, -32, 0.0, 1.0);
    7799  strcpy (bf[0].file, "(empty)");
     100 
     101  float scale2 = (scaleX + 1.0) * (scaleY + 1.0);
     102  float fSquare = 1.0 / scale2;
     103  float fCircle = 1.0 / (3.141592 * scale2);
     104  float fSigma  = 0.5 / scale2;
     105  float fGauss  = 1.0 / (2.0 * 3.141592 * scale2);
    78106
    79107  x = vx[0].elements.Flt;
     
    83111    Xb = (*x - Xmin) / dX;
    84112    Yb = (*y - Ymin) / dY;
    85     if (Xb >= Nx) continue;
    86     if (Yb >= Ny) continue;
    87     if (Xb < 0) continue;
    88     if (Yb < 0) continue;
    89     val[Xb + Yb*Nx] ++;
     113    switch (PSFTYPE) {
     114      case IS_DOT:
     115        if (Xb >= Nx) continue;
     116        if (Yb >= Ny) continue;
     117        if (Xb < 0) continue;
     118        if (Yb < 0) continue;
     119        val[Xb + Yb*Nx] ++;
     120        break;
     121      case IS_SQUARE:
     122        for (ix = Xb - scaleX; ix <= Xb + scaleX; ix++) {
     123          for (iy = Yb - scaleY; iy <= Yb + scaleY; iy++) {
     124            if (ix >= Nx) continue;
     125            if (iy >= Ny) continue;
     126            if (ix < 0) continue;
     127            if (iy < 0) continue;
     128            val[ix + iy*Nx] += fSquare;
     129          }
     130        }
     131        break;
     132      case IS_CIRCLE:
     133        for (ix = Xb - scaleX; ix <= Xb + scaleX; ix++) {
     134          float dX = ix - Xb;
     135          for (iy = Yb - scaleY; iy <= Yb + scaleY; iy++) {
     136            float dY = iy - Yb;
     137            float r2 = dX*dX + dY*dY;
     138            if (r2 > 9) continue;
     139            if (ix >= Nx) continue;
     140            if (iy >= Ny) continue;
     141            if (ix < 0) continue;
     142            if (iy < 0) continue;
     143            val[ix + iy*Nx] += fCircle;
     144          }
     145        }
     146        break;
     147      case IS_GAUSS:
     148        for (ix = Xb - scaleX; ix <= Xb + scaleX; ix++) {
     149          float dX = ix - Xb;
     150          for (iy = Yb - scaleY; iy <= Yb + scaleY; iy++) {
     151            float dY = iy - Yb;
     152            float r2 = dX*dX + dY*dY;
     153            if (ix >= Nx) continue;
     154            if (iy >= Ny) continue;
     155            if (ix < 0) continue;
     156            if (iy < 0) continue;
     157            val[ix + iy*Nx] += fGauss*exp(-fSigma*r2);
     158          }
     159        }
     160        break;
     161    }
    90162  }
    91163  return (TRUE);
  • branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.data/init.c

    r35416 r36680  
    1010int center           PROTO((int, char **));
    1111int parity           PROTO((int, char **));
     12int cast             PROTO((int, char **));
    1213int circstats        PROTO((int, char **));
    1314int clear            PROTO((int, char **));
     
    5253int imcut            PROTO((int, char **));
    5354int imhist           PROTO((int, char **));
     55int impeaks          PROTO((int, char **));
    5456int imsmooth         PROTO((int, char **));
     57int imsmooth_generic PROTO((int, char **));
     58int imsmooth_2d      PROTO((int, char **));
    5559int integrate        PROTO((int, char **));
    5660int interpolate      PROTO((int, char **));
     61int join             PROTO((int, char **));
    5762int jpeg             PROTO((int, char **));
    5863int kern             PROTO((int, char **));
     
    7479int mget             PROTO((int, char **));
    7580int minterp          PROTO((int, char **));
     81int medimage_command PROTO((int, char **));
    7682int mset             PROTO((int, char **));
    7783int peak             PROTO((int, char **));
     
    133139int vmaxwell         PROTO((int, char **));
    134140int vload            PROTO((int, char **));
     141int vlist            PROTO((int, char **));
    135142int vzload           PROTO((int, char **));
    136143int vstats           PROTO((int, char **));
     
    160167  {1, "buffers",      list_buffers,     "list the currently allocated buffers (images)"},
    161168  {1, "center",       center,           "center image on coords"},
     169  {1, "cast",         cast,             "cast input vector to specified type"},
    162170  {1, "circstats",    circstats,        "circular statistics"},
    163171  {1, "clear",        clear,            "erase plot"},
     
    205213  {1, "imcut",        imcut,            "linear image cut between arbitrary coords"},
    206214  {1, "imhistogram",  imhist,           "histogram of an image region"},
     215  {1, "impeaks",      impeaks,          "find peaks in an image (return vectors)"},
    207216  {1, "imsmooth",     imsmooth,         "circular gaussian smoothing"},
     217  {1, "imsmooth.generic", imsmooth_generic, "circular non-gaussian smoothing"},
     218  {1, "imsmooth.2d",  imsmooth_2d,      "circular non-gaussian smoothing"},
    208219  {1, "imstats",      imstats,          "statistics on a portion of an image"},
    209220  {1, "integrate",    integrate,        "integrate a vector"},
    210221  {1, "interpolate",  interpolate,      "interpolate between vector pairs"},
     222  {1, "join",         join,             "find the join of two ID vectors"},
    211223  {1, "jpeg",         jpeg,             "convert display image to JPEG"},
    212224  {1, "kern",         kern,             "convolve with 3x3 kernel"},
     
    224236  {1, "minterp",      minterp,          "interpolate image pixels"},
    225237  {1, "iminterp",     minterp,          "interpolate image pixels"},
     238  {1, "medimage",     medimage_command, "median image manipulation"},
    226239  {1, "matrix",       matrix,           "matrix math operations"},
    227240  {1, "match2d",      match2d,          "match 2 pairs of X,Y vectors and return matched indexes"},
     
    290303  {1, "vgrid",        vgrid,            "generate an image from a triplet of vectors"},
    291304  {1, "vhistogram",   histogram,        "generate histogram from vector"},
     305  {1, "vlist",        vlist,            "append values to a vector from command line"},
    292306  {1, "vload",        vload,            "load vectors as overlay on image display"},
    293307  {1, "vmaxwell",     vmaxwell,         "fit a Maxwellian to a vector"},
  • branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.data/match2d.c

    r33963 r36680  
    1414  Vector *index1, *index2;
    1515
     16  if ((N = get_argument (argc, argv, "-h"))) goto usage;
     17  if ((N = get_argument (argc, argv, "--help"))) goto usage;
     18
    1619  CLOSEST = FALSE;
    1720  if ((N = get_argument (argc, argv, "-closest"))) {
     
    3841  if (argc != 6) {
    3942    gprint (GP_ERR, "USAGE: match2d X1 Y1 X2 Y2 Radius [-index1 (index1)] [-index2 (index2)] [-closest]\n");
    40     gprint (GP_ERR, "  if -closest is provided, index1 & index2 will have the same length as X1 and X2 (respectively)\n");
    41     gprint (GP_ERR, "    with either the index of the match or a value of -1 for non-matches\n");
     43    gprint (GP_ERR, "  use -h or --help for more detail\n");
    4244    return (FALSE);
    4345  }
     
    9092
    9193  return (TRUE);
     94
     95usage:
     96  gprint (GP_ERR, "we have two modes of operation:\n\n");
     97
     98  gprint (GP_ERR, "without -closest, we are finding all matched pairs within the match radius.  in this\n");
     99  gprint (GP_ERR, "case, the two index vectors have the same length, one entry per matched pair.\n");
     100  gprint (GP_ERR, "x1[index1],y1[index1] matches to x2[index2],y2[index2].\n\n");
     101
     102  gprint (GP_ERR, "with -closest selected, we are finding the closest element of set 1 to each of set 2\n");
     103  gprint (GP_ERR, "and vice versa.  in this case, index1 is always the same length as x1,y1, while index2\n");
     104  gprint (GP_ERR, "is the same lengths as x2,y2.  x2[index1],y2[index1] matches x1,y1 while\n");
     105  gprint (GP_ERR, "x1[index2],y1[index2] matches x2,y2\n\n");
     106
     107  gprint (GP_ERR, "if -index1 or -index2 is not supplied, the vectors are created with names index1 or index2\n");
     108  gprint (GP_ERR, "use 'reindex' to generate new vectors based on these index vectors\n");
     109
     110  return FALSE;
    92111}
    93112
  • branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.data/read_vectors.c

    r34753 r36680  
    2323// vector types
    2424enum {COLTYPE_NONE, COLTYPE_FLT, COLTYPE_INT, COLTYPE_TIME, COLTYPE_CHAR};
     25static int FITS_TRANSPOSE;
    2526
    2627int read_vectors (int argc, char **argv) {
     
    3435
    3536  char *buffer = NULL;
     37
     38  FITS_TRANSPOSE = FALSE;
     39  if ((Narg = get_argument (argc, argv, "-transpose"))) {
     40    remove_argument (Narg, &argc, argv);
     41    FITS_TRANSPOSE = TRUE;
     42  }
    3643
    3744  /* auto-sense table type */
     
    410417    }
    411418       
    412     // define the multifield vector names
    413     ALLOCATE (vec, Vector *, Nval);
    414     for (j = 0; j < Nval; j++) {
    415       if (Nval == 1)
    416         sprintf (name, "%s", argv[i]);
    417       else
    418         sprintf (name, "%s:%d", argv[i], j);
    419       if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name");
    420       ResetVector (vec[j], vecType, Ny);
    421     }
    422 
    423     if (!strcmp (type, "char")) {
    424       char *Ptr = data;
     419    if (!FITS_TRANSPOSE) {
     420      // define the multifield vector names (Nval vectors x Ny elements)
     421      ALLOCATE (vec, Vector *, Nval);
     422      for (j = 0; j < Nval; j++) {
     423        if (Nval == 1)
     424          sprintf (name, "%s", argv[i]);
     425        else
     426          sprintf (name, "%s:%d", argv[i], j);
     427        if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name");
     428        ResetVector (vec[j], vecType, Ny);
     429      }
     430
     431      if (!strcmp (type, "char")) {
     432        char *Ptr = data;
     433        for (j = 0; j < Ny; j++) {
     434          for (k = 0; k < Nval; k++, Ptr++) {
     435            vec[k][0].elements.Int[j] = *Ptr;
     436          }
     437        }
     438      }
     439      if (!strcmp (type, "short")) {
     440        short *Ptr = data;
     441        for (j = 0; j < Ny; j++) {
     442          for (k = 0; k < Nval; k++, Ptr++) {
     443            vec[k][0].elements.Int[j] = *Ptr;
     444          }
     445        }
     446      }
     447      if (!strcmp (type, "int")) {
     448        int *Ptr = data;
     449        for (j = 0; j < Ny; j++) {
     450          for (k = 0; k < Nval; k++, Ptr++) {
     451            vec[k][0].elements.Int[j] = *Ptr;
     452          }
     453        }
     454      }
     455      if (!strcmp (type, "int64_t")) {
     456        int64_t *Ptr = data;
     457        for (j = 0; j < Ny; j++) {
     458          for (k = 0; k < Nval; k++, Ptr++) {
     459            vec[k][0].elements.Int[j] = *Ptr;
     460          }
     461        }
     462      }
     463      if (!strcmp (type, "float")) {
     464        float *Ptr = data;
     465        for (j = 0; j < Ny; j++) {
     466          for (k = 0; k < Nval; k++, Ptr++) {
     467            vec[k][0].elements.Flt[j] = *Ptr;
     468          }
     469        }
     470      }
     471      if (!strcmp (type, "double")) {
     472        double *Ptr = data;
     473        for (j = 0; j < Ny; j++) {
     474          for (k = 0; k < Nval; k++, Ptr++) {
     475            vec[k][0].elements.Flt[j] = *Ptr;
     476          }
     477        }
     478      }
     479    } else {
     480      // define the multifield vector names (Ny vectors x Nval elements)
     481      ALLOCATE (vec, Vector *, Ny);
    425482      for (j = 0; j < Ny; j++) {
    426         for (k = 0; k < Nval; k++, Ptr++) {
    427           vec[k][0].elements.Int[j] = *Ptr;
    428         }
    429       }
    430     }
    431     if (!strcmp (type, "short")) {
    432       short *Ptr = data;
    433       for (j = 0; j < Ny; j++) {
    434         for (k = 0; k < Nval; k++, Ptr++) {
    435           vec[k][0].elements.Int[j] = *Ptr;
    436         }
    437       }
    438     }
    439     if (!strcmp (type, "int")) {
    440       int *Ptr = data;
    441       for (j = 0; j < Ny; j++) {
    442         for (k = 0; k < Nval; k++, Ptr++) {
    443           vec[k][0].elements.Int[j] = *Ptr;
    444         }
    445       }
    446     }
    447     if (!strcmp (type, "int64_t")) {
    448       int64_t *Ptr = data;
    449       for (j = 0; j < Ny; j++) {
    450         for (k = 0; k < Nval; k++, Ptr++) {
    451           vec[k][0].elements.Int[j] = *Ptr;
    452         }
    453       }
    454     }
    455     if (!strcmp (type, "float")) {
    456       float *Ptr = data;
    457       for (j = 0; j < Ny; j++) {
    458         for (k = 0; k < Nval; k++, Ptr++) {
    459           vec[k][0].elements.Flt[j] = *Ptr;
    460         }
    461       }
    462     }
    463     if (!strcmp (type, "double")) {
    464       double *Ptr = data;
    465       for (j = 0; j < Ny; j++) {
    466         for (k = 0; k < Nval; k++, Ptr++) {
    467           vec[k][0].elements.Flt[j] = *Ptr;
     483        if (Ny == 1)
     484          sprintf (name, "%s", argv[i]);
     485        else
     486          sprintf (name, "%s:%d", argv[i], j);
     487        if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name");
     488        ResetVector (vec[j], vecType, Nval);
     489      }
     490
     491      if (!strcmp (type, "char")) {
     492        char *Ptr = data;
     493        for (j = 0; j < Ny; j++) {
     494          for (k = 0; k < Nval; k++, Ptr++) {
     495            vec[j][0].elements.Int[k] = *Ptr;
     496          }
     497        }
     498      }
     499      if (!strcmp (type, "short")) {
     500        short *Ptr = data;
     501        for (j = 0; j < Ny; j++) {
     502          for (k = 0; k < Nval; k++, Ptr++) {
     503            vec[j][0].elements.Int[k] = *Ptr;
     504          }
     505        }
     506      }
     507      if (!strcmp (type, "int")) {
     508        int *Ptr = data;
     509        for (j = 0; j < Ny; j++) {
     510          for (k = 0; k < Nval; k++, Ptr++) {
     511            vec[j][0].elements.Int[k] = *Ptr;
     512          }
     513        }
     514      }
     515      if (!strcmp (type, "int64_t")) {
     516        int64_t *Ptr = data;
     517        for (j = 0; j < Ny; j++) {
     518          for (k = 0; k < Nval; k++, Ptr++) {
     519            vec[j][0].elements.Int[k] = *Ptr;
     520          }
     521        }
     522      }
     523      if (!strcmp (type, "float")) {
     524        float *Ptr = data;
     525        for (j = 0; j < Ny; j++) {
     526          for (k = 0; k < Nval; k++, Ptr++) {
     527            vec[j][0].elements.Flt[k] = *Ptr;
     528          }
     529        }
     530      }
     531      if (!strcmp (type, "double")) {
     532        double *Ptr = data;
     533        for (j = 0; j < Ny; j++) {
     534          for (k = 0; k < Nval; k++, Ptr++) {
     535            vec[j][0].elements.Flt[k] = *Ptr;
     536          }
    468537        }
    469538      }
  • branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.data/rebin.c

    r28241 r36680  
    133133              *Vout += *Vin;
    134134              if (Normalize) {(*Vn) ++;}
     135              // if ((i == 1) && (j == 1)) fprintf (stderr, "%d,%d : %d,%d : %f : %f : %d\n", i, j, x, y, *Vin, *Vout, *Vn);
    135136            }
    136137            if (Normalize) {Vn ++;}
  • branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.data/vellipse.c

    r25757 r36680  
    228228 */
    229229
     230// XXX NOTE that PHI is defined with the wrong sign, should fix this...
    230231opihi_flt fellipseOD (opihi_flt alpha, opihi_flt *par, int Npar, opihi_flt *dpar) {
    231232 
  • branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.data/vgauss.c

    r35109 r36680  
    4848  if ((ovec = SelectVector (argv[4], ANYVECTOR, TRUE)) == NULL) return (FALSE);
    4949
     50  CastVector (xvec, OPIHI_FLT);
     51  CastVector (yvec, OPIHI_FLT);
     52
    5053  int Nsvec = strlen(argv[3]);
    5154
     
    6972  }
    7073
    71   CastVector (xvec, OPIHI_FLT);
    72   CastVector (yvec, OPIHI_FLT);
    7374  CastVector (svec, OPIHI_FLT);
    7475  // XXX Cast is failing.
Note: See TracChangeset for help on using the changeset viewer.