Index: trunk/Ohana/src/opihi/cmd.data/Makefile
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/Makefile	(revision 36455)
+++ trunk/Ohana/src/opihi/cmd.data/Makefile	(revision 36489)
@@ -25,4 +25,5 @@
 $(SRC)/book.$(ARCH).o		\
 $(SRC)/book_commands.$(ARCH).o	\
+$(SRC)/cast.$(ARCH).o		\
 $(SRC)/center.$(ARCH).o	\
 $(SRC)/clear.$(ARCH).o		\
Index: trunk/Ohana/src/opihi/cmd.data/cast.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/cast.c	(revision 36489)
+++ trunk/Ohana/src/opihi/cmd.data/cast.c	(revision 36489)
@@ -0,0 +1,71 @@
+# include "data.h"
+
+int cast (int argc, char **argv) {
+  
+  int  i, valid;
+  Vector *ivec, *ovec;
+
+  ivec = ovec = NULL;
+
+  if (argc < 6) goto usage;
+
+  valid = TRUE;
+  valid &= !strcmp(argv[2], "=");
+  valid &= !strcmp(argv[4], "as");
+  if (!valid) goto usage;
+
+  // out type 
+  char outType = OPIHI_NOTYPE;
+  if (!strcasecmp(argv[5], "int")) outType = OPIHI_INT;
+  if (!strcasecmp(argv[5], "float")) outType = OPIHI_FLT;
+  if (outType == OPIHI_NOTYPE) goto usage;
+
+  if ((ovec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto error;
+  if ((ivec = SelectVector (argv[3], OLDVECTOR, TRUE)) == NULL) goto error;
+
+  // ovec matches ivec in type
+  ResetVector (ovec, outType, ivec[0].Nelements);
+
+  // we have four cases: (ivec == flt or int) and (tvec == flt or int)
+  if ((ivec->type == OPIHI_FLT) && (ovec->type == OPIHI_FLT)) {
+    opihi_flt *vi = ivec[0].elements.Flt;
+    opihi_flt *vo = ovec[0].elements.Flt;
+    for (i = 0; i < ovec[0].Nelements; i++, vi++, vo++) {
+      *vo = *vi;
+    }
+    return (TRUE);
+  }
+  if ((ivec->type == OPIHI_FLT) && (ovec->type == OPIHI_INT)) {
+    opihi_flt *vi = ivec[0].elements.Flt;
+    opihi_int *vo = ovec[0].elements.Int;
+    for (i = 0; i < ovec[0].Nelements; i++, vi++, vo++) {
+      *vo = *vi;
+    }
+    return (TRUE);
+  }
+  if ((ivec->type == OPIHI_INT) && (ovec->type == OPIHI_FLT)) {
+    opihi_int *vi = ivec[0].elements.Int;
+    opihi_flt *vo = ovec[0].elements.Flt;
+    for (i = 0; i < ovec[0].Nelements; i++, vi++, vo++) {
+      *vo = *vi;
+    }
+    return (TRUE);
+  }
+  if ((ivec->type == OPIHI_INT) && (ovec->type == OPIHI_INT)) {
+    opihi_int *vi = ivec[0].elements.Int;
+    opihi_int *vo = ovec[0].elements.Int;
+    for (i = 0; i < ovec[0].Nelements; i++, vi++, vo++) {
+      *vo = *vi;
+    }
+    return (TRUE);
+  }
+
+error:
+  DeleteVector (ovec);
+  return (FALSE);
+
+usage:
+  gprint (GP_ERR, "SYNTAX: cast vec = vec as (int/float)\n");
+  return (FALSE);
+}
+
Index: trunk/Ohana/src/opihi/cmd.data/densify.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/densify.c	(revision 36455)
+++ trunk/Ohana/src/opihi/cmd.data/densify.c	(revision 36489)
@@ -2,8 +2,9 @@
 
 # define CHECKVAL(ARG) if (!isfinite(ARG)) { gprint (GP_ERR, "illegal value for %s: %f\n", #ARG, ARG); return (FALSE); }
+enum {IS_DOT, IS_SQUARE, IS_CIRCLE, IS_GAUSS};
 
 int densify (int argc, char **argv) {
 
-  int i, Nx, Ny, Xb, Yb, N, Xpix, Ypix, good, UseGraph;
+  int i, Nx, Ny, Xb, Yb, ix, iy, N, Xpix, Ypix, good, UseGraph;
   double Xmin, Xmax, dX, Ymin, Ymax, dY;
   float *val;
@@ -24,8 +25,26 @@
   }
 
+  float scale = 0.0;
+  if ((N = get_argument (argc, argv, "-scale"))) {
+    remove_argument (N, &argc, argv);
+    scale = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  int PSFTYPE = IS_DOT;
+  if ((N = get_argument (argc, argv, "-psf"))) {
+    remove_argument (N, &argc, argv);
+    if (!strcasecmp(argv[N], "dot"))    PSFTYPE = IS_DOT;
+    if (!strcasecmp(argv[N], "square")) PSFTYPE = IS_SQUARE;
+    if (!strcasecmp(argv[N], "circle")) PSFTYPE = IS_CIRCLE;
+    if (!strcasecmp(argv[N], "gauss"))  PSFTYPE = IS_GAUSS;
+    remove_argument (N, &argc, argv);
+  }
+
   good = UseGraph ? (argc == 4) : (argc == 10);
   if (!good) {
     gprint (GP_ERR, "USAGE: densify buffer x y Xmin Xmax dX Ymin Ymax dY\n");
     gprint (GP_ERR, "   OR: densify buffer x y -graph\n");
+    gprint (GP_ERR, " option: -psf [dot] (circle) (square) (gauss)\n");
     return (FALSE);
   }
@@ -69,4 +88,7 @@
   CHECKVAL(dY);
 
+  float scaleX = (scale > 0.0) ? scale / dX : 3.0;
+  float scaleY = (scale > 0.0) ? scale / dY : 3.0;
+
   Nx = (Xmax - Xmin) / dX + 1;
   Ny = (Ymax - Ymin) / dY + 1;
@@ -76,4 +98,10 @@
   CreateBuffer (bf, Nx, Ny, -32, 0.0, 1.0);
   strcpy (bf[0].file, "(empty)");
+  
+  float scale2 = (scaleX + 1.0) * (scaleY + 1.0);
+  float fSquare = 1.0 / scale2;
+  float fCircle = 1.0 / (3.141592 * scale2);
+  float fSigma  = 0.5 / scale2;
+  float fGauss  = 1.0 / (2.0 * 3.141592 * scale2);
 
   x = vx[0].elements.Flt;
@@ -83,9 +111,53 @@
     Xb = (*x - Xmin) / dX;
     Yb = (*y - Ymin) / dY;
-    if (Xb >= Nx) continue;
-    if (Yb >= Ny) continue;
-    if (Xb < 0) continue;
-    if (Yb < 0) continue;
-    val[Xb + Yb*Nx] ++;
+    switch (PSFTYPE) {
+      case IS_DOT:
+	if (Xb >= Nx) continue;
+	if (Yb >= Ny) continue;
+	if (Xb < 0) continue;
+	if (Yb < 0) continue;
+	val[Xb + Yb*Nx] ++;
+	break;
+      case IS_SQUARE:
+	for (ix = Xb - scaleX; ix <= Xb + scaleX; ix++) {
+	  for (iy = Yb - scaleY; iy <= Yb + scaleY; iy++) {
+	    if (ix >= Nx) continue;
+	    if (iy >= Ny) continue;
+	    if (ix < 0) continue;
+	    if (iy < 0) continue;
+	    val[ix + iy*Nx] += fSquare;
+	  }
+	}
+	break;
+      case IS_CIRCLE:
+	for (ix = Xb - scaleX; ix <= Xb + scaleX; ix++) {
+	  float dX = ix - Xb;
+	  for (iy = Yb - scaleY; iy <= Yb + scaleY; iy++) {
+	    float dY = iy - Yb;
+	    float r2 = dX*dX + dY*dY;
+	    if (r2 > 9) continue;
+	    if (ix >= Nx) continue;
+	    if (iy >= Ny) continue;
+	    if (ix < 0) continue;
+	    if (iy < 0) continue;
+	    val[ix + iy*Nx] += fCircle;
+	  }
+	}
+	break;
+      case IS_GAUSS:
+	for (ix = Xb - scaleX; ix <= Xb + scaleX; ix++) {
+	  float dX = ix - Xb;
+	  for (iy = Yb - scaleY; iy <= Yb + scaleY; iy++) {
+	    float dY = iy - Yb;
+	    float r2 = dX*dX + dY*dY;
+	    if (ix >= Nx) continue;
+	    if (iy >= Ny) continue;
+	    if (ix < 0) continue;
+	    if (iy < 0) continue;
+	    val[ix + iy*Nx] += fGauss*exp(-fSigma*r2);
+	  }
+	}
+	break;
+    }
   }
   return (TRUE);
Index: trunk/Ohana/src/opihi/cmd.data/init.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/init.c	(revision 36455)
+++ trunk/Ohana/src/opihi/cmd.data/init.c	(revision 36489)
@@ -10,4 +10,5 @@
 int center           PROTO((int, char **));
 int parity           PROTO((int, char **));
+int cast             PROTO((int, char **));
 int circstats        PROTO((int, char **));
 int clear            PROTO((int, char **));
@@ -164,4 +165,5 @@
   {1, "buffers",      list_buffers,     "list the currently allocated buffers (images)"},
   {1, "center",       center,           "center image on coords"},
+  {1, "cast",         cast,             "cast input vector to specified type"},
   {1, "circstats",    circstats,        "circular statistics"},
   {1, "clear",        clear,            "erase plot"},
Index: trunk/Ohana/src/opihi/cmd.data/vgauss.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/vgauss.c	(revision 36455)
+++ trunk/Ohana/src/opihi/cmd.data/vgauss.c	(revision 36489)
@@ -48,4 +48,7 @@
   if ((ovec = SelectVector (argv[4], ANYVECTOR, TRUE)) == NULL) return (FALSE);
 
+  CastVector (xvec, OPIHI_FLT);
+  CastVector (yvec, OPIHI_FLT);
+
   int Nsvec = strlen(argv[3]);
 
@@ -69,6 +72,4 @@
   }
 
-  CastVector (xvec, OPIHI_FLT);
-  CastVector (yvec, OPIHI_FLT);
   CastVector (svec, OPIHI_FLT);
   // XXX Cast is failing.
