Index: trunk/Ohana/src/opihi/cmd.astro/Makefile
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/Makefile	(revision 39217)
+++ trunk/Ohana/src/opihi/cmd.astro/Makefile	(revision 39225)
@@ -23,4 +23,5 @@
 $(SRC)/cdot.$(ARCH).o		   \
 $(SRC)/cline.$(ARCH).o             \
+$(SRC)/cneedles.$(ARCH).o		   \
 $(SRC)/cplot.$(ARCH).o		   \
 $(SRC)/csystem.$(ARCH).o	   \
@@ -76,4 +77,5 @@
 $(SRC)/vshimage.$(ARCH).o         \
 $(SRC)/shimage.$(ARCH).o         \
+$(SRC)/wcs.$(ARCH).o         \
 $(SRC)/imsub.$(ARCH).o		   \
 $(SRC)/imfit.$(ARCH).o		   \
Index: trunk/Ohana/src/opihi/cmd.astro/cneedles.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/cneedles.c	(revision 39225)
+++ trunk/Ohana/src/opihi/cmd.astro/cneedles.c	(revision 39225)
@@ -0,0 +1,136 @@
+# include "data.h"
+
+// generate needle plots for (x,y) (dx,dy)
+int cneedles (int argc, char **argv) {
+  
+  int i, N, kapa, Npts, valid, size;
+  opihi_flt *x, *y, *r, *d, *dR, *dD, Rmin, Rmax;
+  Vector Xvec, Yvec, *xvec, *yvec, *dxvec, *dyvec;
+  Graphdata graphmode;
+
+  if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE;
+
+  float scale = 1.0;
+  if ((N = get_argument (argc, argv, "-scale"))) {
+    remove_argument (N, &argc, argv);
+    scale = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }    
+
+  valid  = (argc == 5);
+  valid |= (argc > 6) && !strcmp (argv[5], "where");
+  if (!valid) {
+    gprint (GP_ERR, "USAGE: needles <ra> <dec> <dR> <dD> [-scale scale] [style]\n");
+    gprint (GP_ERR, "   OR: needles <ra> <dec> <dR> <dD> [-scale scale] [style] where (condition)\n");
+    return (FALSE);
+  }
+
+  // tvec is used for logical test (truth vector)
+  Vector *tvec = NULL;
+  if (argc > 6) {
+    char *out = dvomath (argc - 6, &argv[6], &size, 1);
+    if (out == NULL) {
+      print_error ();
+      return FALSE;
+    }
+    if ((tvec = SelectVector (out, OLDVECTOR, TRUE)) == NULL) {
+      gprint (GP_ERR, " invalid logic result\n");
+      DeleteNamedVector (out);
+      free (out);
+      return (FALSE);
+    }
+  }
+
+  graphmode.etype = 0;
+  graphmode.ptype = 100;
+
+  Rmin = graphmode.coords.crval1 - 182.0;
+  Rmax = graphmode.coords.crval1 + 182.0;
+
+  /* find vectors */
+  if ((xvec = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE);
+  if ((yvec = SelectVector (argv[2], OLDVECTOR, TRUE)) == NULL) return (FALSE);
+  if ((dxvec = SelectVector (argv[3], OLDVECTOR, TRUE)) == NULL) return (FALSE);
+  if ((dyvec = SelectVector (argv[4], OLDVECTOR, TRUE)) == NULL) return (FALSE);
+
+  REQUIRE_VECTOR_FLT (xvec, FALSE); 
+  REQUIRE_VECTOR_FLT (yvec, FALSE); 
+  REQUIRE_VECTOR_FLT (dxvec, FALSE); 
+  REQUIRE_VECTOR_FLT (dyvec, FALSE); 
+
+  if (xvec->Nelements != yvec->Nelements) { gprint (GP_ERR, "vectors are not the same length\n"); return (FALSE); }
+  if (dxvec->Nelements != xvec->Nelements) { gprint (GP_ERR, "vectors are not the same length\n"); return (FALSE); }
+  if (dyvec->Nelements != xvec->Nelements) { gprint (GP_ERR, "vectors are not the same length\n"); return (FALSE); }
+
+  if (tvec && tvec[0].Nelements != yvec[0].Nelements) {
+    gprint (GP_ERR, "logic test vector not the same length as data vectors\n");
+    DeleteVector (tvec);
+    return (FALSE);
+  }
+
+  SetVector (&Xvec, OPIHI_FLT, 2*xvec[0].Nelements);
+  SetVector (&Yvec, OPIHI_FLT, 2*xvec[0].Nelements);
+  
+  // input vectors in r,d space
+  r  =  xvec[0].elements.Flt;
+  d  =  yvec[0].elements.Flt;
+  dR = dxvec[0].elements.Flt;
+  dD = dyvec[0].elements.Flt;
+
+  // output vectors after projection & offsets
+  x = Xvec.elements.Flt;
+  y = Yvec.elements.Flt;
+  
+  Npts = 0;
+  for (i = 0; i < xvec->Nelements; i++, r++, d++, dR++, dD++) {
+    if (tvec) {
+      int skip = (tvec->type == OPIHI_FLT) ? (tvec->elements.Flt[i] == 0.0) : (tvec->elements.Int[i] == 0.0);
+      if (skip) continue;
+    }
+
+    double dec = *d;
+    double ra = ohana_normalize_angle (*r);
+    while (ra < Rmin) ra += 360.0;
+    while (ra > Rmax) ra -= 360.0;
+
+    double X1, Y1;
+    int status1 = RD_to_XY (&X1, &Y1, ra, dec, &graphmode.coords);
+
+    float rescale = cos(dec*RAD_DEG);
+    if (fabs(rescale) < 0.01) {
+      rescale = 0.01;
+    }
+    dec = dec + *dD * scale;
+    ra  = ra  + *dR * scale / rescale;
+
+    double X2, Y2;
+    int status2 = RD_to_XY (&X2, &Y2, ra, dec, &graphmode.coords);
+
+    if (!status1 || !status2) continue;
+
+    *x = X1;
+    *y = Y1;
+    x++;
+    y++;
+    Npts++;
+
+    *x = X2;
+    *y = Y2;
+    x++;
+    y++;
+    Npts++;
+  }
+  Xvec.Nelements = Npts;
+  Yvec.Nelements = Npts;
+
+  graphmode.etype = 0;
+  graphmode.ptype = 100;
+  PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
+  
+  free (Xvec.elements.Ptr);
+  free (Yvec.elements.Ptr);
+    
+  if (tvec) DeleteVector (tvec);
+
+  return (TRUE);
+}
Index: trunk/Ohana/src/opihi/cmd.astro/drizzle.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/drizzle.c	(revision 39217)
+++ trunk/Ohana/src/opihi/cmd.astro/drizzle.c	(revision 39225)
@@ -141,4 +141,6 @@
 
 	  if (Vmk && Vmk[Ni]) continue;
+	  if (!isfinite(Vin[Ni])) continue;
+
 	  Vout[No] += Vin[Ni];
 	  Vwt[No] ++;
@@ -195,4 +197,5 @@
 
 	  if (Vmk && Vmk[Ni]) continue;
+	  if (!isfinite(Vin[Ni])) continue;
 	  Vout[No] += Vin[Ni];
 	  Vwt[No] ++;
Index: trunk/Ohana/src/opihi/cmd.astro/init.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/init.c	(revision 39217)
+++ trunk/Ohana/src/opihi/cmd.astro/init.c	(revision 39225)
@@ -7,4 +7,5 @@
 int cdot                    PROTO((int, char **));
 int cline                   PROTO((int, char **));
+int cneedles                PROTO((int, char **));
 int cplot                   PROTO((int, char **));
 int csystem                 PROTO((int, char **));
@@ -66,4 +67,5 @@
 int vshimage                PROTO((int, char **));
 int shimage                 PROTO((int, char **));
+int wcs                     PROTO((int, char **));
 
 static Command cmds[] = {  
@@ -74,4 +76,5 @@
   {1, "cdot",        cdot,         "plot point in sky coordinates"},
   {1, "cline",       cline,        "plot line connecting two sky coordinates"},
+  {1, "cneedles",    cneedles,     "plot vectors in sky coordinates"},
   {1, "cplot",       cplot,        "plot vectors in sky coordinates"},
   {1, "csystem",     csystem,      "convert between coordinate systems"},
@@ -131,4 +134,5 @@
   {1, "vshimage",    vshimage,     "generate images for vector spherical harmonic terms"},
   {1, "shimage",     shimage,      "generate images for spherical harmonic terms"},
+  {1, "wcs",         wcs,          "set the wcs for the given image"},
 }; 
 
Index: trunk/Ohana/src/opihi/cmd.astro/region.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/region.c	(revision 39217)
+++ trunk/Ohana/src/opihi/cmd.astro/region.c	(revision 39225)
@@ -74,7 +74,14 @@
   }
 
+  float Angle = 0.0;
+  if ((N = get_argument (argc, argv, "-angle"))) {
+    remove_argument (N, &argc, argv);
+    Angle = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
   if ((argc != 4) && (argc != 5)) {
     gprint (GP_ERR, "USAGE: region Ra Dec Radius [projection] [orientation]\n");
-    gprint (GP_ERR, "  [-image] [-ew] [+ew] [-ns] [+ns] [-no-clear]\n");
+    gprint (GP_ERR, "  [-image] [-ew] [+ew] [-ns] [+ns] [-no-clear] [-angle theta]\n");
     gprint (GP_ERR, " current: %f %f (%f x %f) (%s)\n", 
 	     graphmode.coords.crval1, graphmode.coords.crval2, 
@@ -111,6 +118,11 @@
   graphmode.coords.crval2 = Dec;
 
-  graphmode.coords.pc1_1 = (graphmode.flipeast) ? -1 : 1;
-  graphmode.coords.pc2_2 = (graphmode.flipnorth) ? -1 : 1;
+  float pc1_1 = (graphmode.flipeast)  ? -1 : 1;
+  float pc2_2 = (graphmode.flipnorth) ? -1 : 1;
+
+  graphmode.coords.pc1_1 =  cos(Angle*RAD_DEG)*pc1_1;
+  graphmode.coords.pc1_2 =  sin(Angle*RAD_DEG)*pc2_2;
+  graphmode.coords.pc2_1 = -sin(Angle*RAD_DEG)*pc1_1;
+  graphmode.coords.pc2_2 =  cos(Angle*RAD_DEG)*pc2_2;
 
   /* ask kapa for coordinate limits, to get the right aspect ratio */
Index: trunk/Ohana/src/opihi/cmd.astro/wcs.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/wcs.c	(revision 39225)
+++ trunk/Ohana/src/opihi/cmd.astro/wcs.c	(revision 39225)
@@ -0,0 +1,93 @@
+# include "astro.h"
+
+int wcs (int argc, char **argv) {
+  
+  int N;
+
+  int flipeast = TRUE;
+  if ((N = get_argument (argc, argv, "-ew"))) {
+    remove_argument (N, &argc, argv);
+    flipeast = TRUE;
+  }
+  if ((N = get_argument (argc, argv, "+ew"))) {
+    remove_argument (N, &argc, argv);
+    flipeast = FALSE;
+  }
+
+  int flipnorth = FALSE;
+  if ((N = get_argument (argc, argv, "-ns"))) {
+    remove_argument (N, &argc, argv);
+    flipnorth = TRUE;
+  }
+  if ((N = get_argument (argc, argv, "+ns"))) {
+    remove_argument (N, &argc, argv);
+    flipnorth = FALSE;
+  }
+
+  float Angle = 0.0;
+  if ((N = get_argument (argc, argv, "-angle"))) {
+    remove_argument (N, &argc, argv);
+    Angle = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  if ((argc != 5) && (argc != 6)) {
+    gprint (GP_ERR, "USAGE: wcs (buffer) Ra Dec platescale [projection] [orientation]\n");
+    gprint (GP_ERR, "  [-ew] [+ew] [-ns] [+ns] [-angle theta]\n");
+    return (FALSE);
+  }
+  
+  double Ra, Dec;
+  if (!ohana_str_to_radec (&Ra, &Dec, argv[2], argv[3])) return (FALSE);
+  float platescale = atof (argv[4]); // arcsec per pixel
+
+  Buffer *buf = NULL;
+  if ((buf = SelectBuffer (argv[1], OLDBUFFER, TRUE)) == NULL) {
+    gprint (GP_ERR, "cannot define buffer %s\n", argv[1]);
+    return FALSE;
+  }
+
+  Coords coords;
+  InitCoords (&coords, "DEC--TAN");
+
+  if (argc == 6) {
+    if (!strcasecmp (argv[5], "TAN")) 
+      strcpy (coords.ctype, "DEC--TAN");
+    if (!strcasecmp (argv[5], "SIN")) 
+      strcpy (coords.ctype, "DEC--SIN");
+    if (!strcasecmp (argv[5], "ARC")) 
+      strcpy (coords.ctype, "DEC--ARC");
+    if (!strcasecmp (argv[5], "STG")) 
+      strcpy (coords.ctype, "DEC--STG");
+    if (!strcasecmp (argv[5], "ZEA"))
+      strcpy (coords.ctype, "DEC--ZEA");
+    if (!strcasecmp (argv[5], "AIT")) 
+      strcpy (coords.ctype, "DEC--AIT");
+    if (!strcasecmp (argv[5], "GLS")) 
+      strcpy (coords.ctype, "DEC--GLS");
+    if (!strcasecmp (argv[5], "PAR")) 
+      strcpy (coords.ctype, "DEC--PAR");
+  }
+  
+  coords.crval1 = Ra;
+  coords.crval2 = Dec;
+
+  // reference pixel is the image center
+  coords.crpix1 = 0.5 * buf[0].header.Naxis[0]; // Ohana / IPP center of a pixel is X.5,X.5
+  coords.crpix2 = 0.5 * buf[0].header.Naxis[1]; // Ohana / IPP center of a pixel is X.5,X.5
+
+  float pc1_1 = flipeast  ? -1 : 1;
+  float pc2_2 = flipnorth ? -1 : 1;
+
+  coords.pc1_1 =  cos(Angle*RAD_DEG)*pc1_1;
+  coords.pc1_2 =  sin(Angle*RAD_DEG)*pc2_2;
+  coords.pc2_1 = -sin(Angle*RAD_DEG)*pc1_1;
+  coords.pc2_2 =  cos(Angle*RAD_DEG)*pc2_2;
+
+  coords.cdelt1 = platescale / 3600.0;
+  coords.cdelt2 = platescale / 3600.0;
+
+  PutCoords (&coords, &buf[0].header);
+  return (TRUE);
+}
+
Index: trunk/Ohana/src/opihi/cmd.data/Makefile
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/Makefile	(revision 39217)
+++ trunk/Ohana/src/opihi/cmd.data/Makefile	(revision 39225)
@@ -97,4 +97,5 @@
 $(SRC)/medimage_commands.$(ARCH).o \
 $(SRC)/mset.$(ARCH).o		\
+$(SRC)/needles.$(ARCH).o		\
 $(SRC)/peak.$(ARCH).o		\
 $(SRC)/periodogram.$(ARCH).o	\
Index: trunk/Ohana/src/opihi/cmd.data/init.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/init.c	(revision 39217)
+++ trunk/Ohana/src/opihi/cmd.data/init.c	(revision 39225)
@@ -86,4 +86,5 @@
 int medimage_command PROTO((int, char **));
 int mset             PROTO((int, char **));
+int needles          PROTO((int, char **));
 int peak             PROTO((int, char **));
 int periodogram      PROTO((int, char **));
@@ -261,4 +262,5 @@
   {1, "mset",         mset,             "insert a vector in an image"},
   {1, "imset",        mset,             "insert a vector in an image"},
+  {1, "needles",      needles,          "plot vectors needles"},
   {1, "parity",       parity,           "set image parity"},
   {1, "peak",         peak,             "find vector peak in range"},
Index: trunk/Ohana/src/opihi/cmd.data/needles.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/needles.c	(revision 39225)
+++ trunk/Ohana/src/opihi/cmd.data/needles.c	(revision 39225)
@@ -0,0 +1,121 @@
+# include "data.h"
+
+// generate needle plots for (x,y) (dx,dy)
+int needles (int argc, char **argv) {
+  
+  int kapa, N, Npts, valid, size, i;
+  Graphdata graphmode;
+  Vector *xvec, *yvec, *dxvec, *dyvec;
+
+  if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE;
+
+  float scale = 1.0;
+  if ((N = get_argument (argc, argv, "-scale"))) {
+    remove_argument (N, &argc, argv);
+    scale = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }    
+
+  valid  = (argc == 5);
+  valid |= (argc > 6) && !strcmp (argv[5], "where");
+  if (!valid) {
+    gprint (GP_ERR, "USAGE: needles <x> <y> <dx> <dy> [-scale scale] [style]\n");
+    gprint (GP_ERR, "   OR: needles <x> <y> <dx> <dy> [-scale scale] [style] where (condition)\n");
+    return (FALSE);
+  }
+
+  // tvec is used for logical test (truth vector)
+  Vector *tvec = NULL;
+  char *mask = NULL;
+  if (argc > 6) {
+    char *out = dvomath (argc - 6, &argv[6], &size, 1);
+    if (out == NULL) {
+      print_error ();
+      return FALSE;
+    }
+    if ((tvec = SelectVector (out, OLDVECTOR, TRUE)) == NULL) {
+      gprint (GP_ERR, " invalid logic result\n");
+      DeleteNamedVector (out);
+      free (out);
+      return (FALSE);
+    }
+  }
+
+  graphmode.etype = 0;
+  graphmode.ptype = 100;
+  
+  /* find vectors */
+  if ((xvec  = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE);
+  if ((yvec  = SelectVector (argv[2], OLDVECTOR, TRUE)) == NULL) return (FALSE);
+  if ((dxvec = SelectVector (argv[3], OLDVECTOR, TRUE)) == NULL) return (FALSE);
+  if ((dyvec = SelectVector (argv[4], OLDVECTOR, TRUE)) == NULL) return (FALSE);
+  if (xvec[0].Nelements != yvec[0].Nelements) {
+    gprint (GP_ERR, "vectors %s and %s not the same length\n", argv[1], argv[2]);
+    return (FALSE);
+  }
+  if (tvec && tvec[0].Nelements != yvec[0].Nelements) {
+    gprint (GP_ERR, "logic test vector not the same length as data vectors\n");
+    return (FALSE);
+  }
+  if (dxvec->Nelements != xvec->Nelements) goto mismatch;
+  if (dyvec->Nelements != xvec->Nelements) goto mismatch;
+
+  Npts = xvec[0].Nelements;
+  if (Npts == 0) {
+    if (tvec) DeleteVector (tvec);
+    return (TRUE);
+  }
+
+  if (tvec) {
+    Npts = 0;
+    ALLOCATE (mask, char, tvec->Nelements);
+    for (i = 0; i < tvec->Nelements; i++) {
+      mask[i] = (tvec->type == OPIHI_FLT) ? (tvec->elements.Flt[i] == 0.0) : (tvec->elements.Int[i] == 0.0);
+      if (!mask[i]) Npts ++;
+    }
+    if (Npts == 0) {
+      DeleteVector (tvec);
+      free (mask);
+      return TRUE;
+    }
+  }
+  Npts = 2*Npts;
+
+  // we need to generate the 2x length vectors
+  Vector *xfull = InitVector();
+  Vector *yfull = InitVector();
+  ResetVector (xfull, OPIHI_FLT, Npts);
+  ResetVector (yfull, OPIHI_FLT, Npts);
+
+  N = 0;
+  for (i = 0; i < xvec->Nelements; i++) {
+    if (mask && mask[i]) continue;
+    xfull->elements.Flt[N] = xvec->elements.Flt[i];
+    yfull->elements.Flt[N] = yvec->elements.Flt[i];
+    N ++;
+    myAssert (N <= Npts, "oops");
+    xfull->elements.Flt[N] = xvec->elements.Flt[i] + scale*dxvec->elements.Flt[i];
+    yfull->elements.Flt[N] = yvec->elements.Flt[i] + scale*dyvec->elements.Flt[i];
+    N ++;
+    myAssert (N <= Npts, "oops");
+  }    
+  myAssert (N == Npts, "oops");
+
+  if (!KapaPrepPlot (kapa, Npts, &graphmode)) return (FALSE);
+  PlotVectorSingle (kapa, xfull, NULL, "x");
+  PlotVectorSingle (kapa, yfull, NULL, "y");
+
+  if (tvec) {
+    free (mask);
+    DeleteVector (tvec);
+  }
+
+  FreeVector (xfull);
+  FreeVector (yfull);
+
+  return (TRUE);
+
+mismatch:
+  gprint (GP_ERR, "x,y and dx,dy lengths are mismatched\n");
+  return (FALSE);
+}
Index: trunk/Ohana/src/opihi/dvo/avmatch.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/avmatch.c	(revision 39217)
+++ trunk/Ohana/src/opihi/dvo/avmatch.c	(revision 39225)
@@ -328,4 +328,5 @@
   gprint (GP_ERR, "USAGE: avmatch (RA) (DEC) (RADIUS) field[,field,field...]\n");
   gprint (GP_ERR, "   OR: avmatch -coords (filename.fits) (RADIUS) field[,field,field...]\n");
+  gprint (GP_ERR, "   RADIUS is in arcseconds\n");
 
   if ((argc > N + 1) && !strcasecmp (argv[N+1], "fields")) {
Index: trunk/Ohana/src/opihi/dvo/imlist.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/imlist.c	(revision 39217)
+++ trunk/Ohana/src/opihi/dvo/imlist.c	(revision 39225)
@@ -21,4 +21,14 @@
   }
 
+  int VERBOSE = TRUE;
+  if ((N = get_argument (argc, argv, "-quiet"))) {
+    VERBOSE = FALSE;
+    remove_argument (N, &argc, argv);
+  }
+  if ((N = get_argument (argc, argv, "-q"))) {
+    VERBOSE = FALSE;
+    remove_argument (N, &argc, argv);
+  }
+
   TimeSelect = FALSE;
   if ((N = get_argument (argc, argv, "-time"))) {
@@ -35,5 +45,5 @@
     remove_argument (N, &argc, argv);
     TimeSelect = TRUE;
-    gprint (GP_ERR, "plotting in range %ds - %ds (%f seconds)\n", (int)tzero, (int)(tzero + trange), trange);
+    if (VERBOSE) gprint (GP_ERR, "plotting in range %ds - %ds (%f seconds)\n", (int)tzero, (int)(tzero + trange), trange);
   }
 
@@ -88,4 +98,6 @@
   GetTimeFormat (&TimeReference, &TimeFormat);
 
+  int Nfound = 0;
+
   for (j = 0; j < MAX_LIST; j++) {
     i = subset[j];
@@ -104,7 +116,13 @@
       XY_to_RD (&r, &d, 0.5*image[i].NX, 0.5*image[i].NY, &image[i].coords);
     }
-    gprint (GP_LOG, "%3lld %s %8lld %8.4f %8.4f %f %5d %2d %4.2f %5.3f %5.3f\n", 
-	    (long long) i, image[i].name, (long long) image[i].imageID, r, d, t, image[i].nstar, image[i].photcode, image[i].secz, image[i].Mcal, image[i].dMcal);
+    if (VERBOSE) gprint (GP_LOG, "%3lld %s %8lld %8.4f %8.4f %f %5d %2d %4.2f %5.3f %5.3f\n", 
+			 (long long) i, image[i].name, (long long) image[i].imageID, r, d, t, image[i].nstar, image[i].photcode, image[i].secz, image[i].Mcal, image[i].dMcal);
+
+    char name[80];
+    sprintf (name, "imlist:%d", Nfound);
+    set_str_variable (name, image[i].name);
+    Nfound ++;
   }
+  set_int_variable ("imlist:n", Nfound);
 
   FreeImagesDVO(image);
Index: trunk/Ohana/src/opihi/include/dvomath.h
===================================================================
--- trunk/Ohana/src/opihi/include/dvomath.h	(revision 39217)
+++ trunk/Ohana/src/opihi/include/dvomath.h	(revision 39225)
@@ -147,4 +147,5 @@
 Vector       *InitVector            PROTO((void));
 void          FreeVectorArray       PROTO((Vector **vec, int Nvec));
+void          FreeVector            PROTO((Vector *vec));
 int           CopyVector            PROTO((Vector *out, Vector *in));
 int           ResetVector           PROTO((Vector *vec, char type, int Nelements));
Index: trunk/Ohana/src/opihi/lib.shell/VectorOps.c
===================================================================
--- trunk/Ohana/src/opihi/lib.shell/VectorOps.c	(revision 39217)
+++ trunk/Ohana/src/opihi/lib.shell/VectorOps.c	(revision 39225)
@@ -15,4 +15,14 @@
 
 // this function is NOT thread protected : it is only used in startup and/or shutdown
+void FreeVector (Vector *vec) {
+
+  if (!vec) return;
+  if (vec->elements.Int) {
+    free (vec->elements.Int);
+  }
+  free (vec);
+}
+
+// this function is NOT thread protected : it is only used in startup and/or shutdown
 void FreeVectorArray (Vector **vec, int Nvec) {
 
@@ -21,9 +31,5 @@
   if (!vec) return;
   for (i = 0; i < Nvec; i++) {
-    if (!vec[i]) continue;
-    if (vec[i]->elements.Int) {
-      free (vec[i]->elements.Int);
-    }
-    free (vec[i]);
+    FreeVector (vec[i]);
   }
   free (vec);
