Index: trunk/Ohana/src/opihi/cmd.astro/region.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/region.c	(revision 30972)
+++ trunk/Ohana/src/opihi/cmd.astro/region.c	(revision 31160)
@@ -5,5 +5,5 @@
   double Ra, Dec, Radius;
   float dx, dy;
-  int N, kapa, NoClear;
+  int N, kapa, NoClear, dXpix, dYpix;
   char *name;
   Graphdata graphmode;
@@ -27,5 +27,5 @@
     remove_argument (N, &argc, argv);
     KapaGetImageCoords (kapa, &graphmode.coords);
-    KapaGetImageRange (kapa, &graphmode.xmin, &graphmode.xmax, &graphmode.ymax, &graphmode.ymin);
+    KapaGetImageRange (kapa, &graphmode.xmin, &graphmode.xmax, &graphmode.ymax, &graphmode.ymin, &dXpix, &dYpix);
 
     set_variable ("XMIN", graphmode.xmin);
Index: trunk/Ohana/src/opihi/cmd.data/densify.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/densify.c	(revision 30972)
+++ trunk/Ohana/src/opihi/cmd.data/densify.c	(revision 31160)
@@ -1,8 +1,10 @@
 # include "data.h"
+
+# define CHECKVAL(ARG) if (!isfinite(ARG)) { gprint (GP_ERR, "illegal value for %s: %f\n", #ARG, ARG); return (FALSE); }
 
 int densify (int argc, char **argv) {
 
-  int i, Nx, Ny, Xb, Yb, Normalize, N;
-  float Xmin, Xmax, dX, Ymin, Ymax, dY;
+  int i, Nx, Ny, Xb, Yb, Normalize, N, Xpix, Ypix, good, UseGraph;
+  double Xmin, Xmax, dX, Ymin, Ymax, dY;
   float *val;
   Buffer *bf;
@@ -16,6 +18,14 @@
   }
 
-  if (argc != 10) {
+  UseGraph = FALSE;
+  if ((N = get_argument (argc, argv, "-graph"))) {
+    remove_argument (N, &argc, argv);
+    UseGraph = TRUE;
+  }
+
+  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");
     return (FALSE);
   }
@@ -30,11 +40,32 @@
   REQUIRE_VECTOR_FLT (vy, FALSE); 
 
-  Xmin = atof (argv[4]);
-  Xmax = atof (argv[5]);
-  dX   = atof (argv[6]);
+  if (UseGraph) {
+    int kapa;
+    Graphdata graphmode;
+    if (!GetGraph (&graphmode, &kapa, NULL)) return (FALSE);
+    KapaGetImageRange (kapa, &Xmin, &Xmax, &Ymax, &Ymin, &Xpix, &Ypix);
+    Xmax = graphmode.xmax;
+    Xmin = graphmode.xmin;
+    Ymax = graphmode.ymax;
+    Ymin = graphmode.ymin;
+    dX = (Xmax - Xmin) / (Xpix - 1);
+    dY = (Ymax - Ymin) / (Ypix - 1);
+  } else {
+    Xmin = atof (argv[4]);
+    Xmax = atof (argv[5]);
+    dX   = atof (argv[6]);
 
-  Ymin = atof (argv[7]);
-  Ymax = atof (argv[8]);
-  dY   = atof (argv[9]);
+    Ymin = atof (argv[7]);
+    Ymax = atof (argv[8]);
+    dY   = atof (argv[9]);
+  }
+
+  CHECKVAL(Xmin);
+  CHECKVAL(Xmax);
+  CHECKVAL(dX);
+
+  CHECKVAL(Ymin);
+  CHECKVAL(Ymax);
+  CHECKVAL(dY);
 
   Nx = (Xmax - Xmin) / dX + 1;
Index: trunk/Ohana/src/opihi/cmd.data/fit1d.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/fit1d.c	(revision 30972)
+++ trunk/Ohana/src/opihi/cmd.data/fit1d.c	(revision 31160)
@@ -42,5 +42,5 @@
 
   if (argc != 4) {
-    gprint (GP_ERR, "USAGE: fit x y order [-dy wt] [-quiet/-q] [-clip Nsigma Niter]\n");
+    gprint (GP_ERR, "USAGE: fit1d x y order [-dy wt] [-quiet/-q] [-clip Nsigma Niter]\n");
     return (FALSE);
   }
Index: trunk/Ohana/src/opihi/cmd.data/fit2d.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/fit2d.c	(revision 30972)
+++ trunk/Ohana/src/opihi/cmd.data/fit2d.c	(revision 31160)
@@ -48,5 +48,5 @@
 
   if (argc != 5) {
-    gprint (GP_ERR, "USAGE: fit x y z order [-dz wt]\n");
+    gprint (GP_ERR, "USAGE: fit2d x y z order [-dz wt] [-quiet/-q] [-clip Nsigma Niter]\n");
     return (FALSE);
   }
Index: trunk/Ohana/src/opihi/cmd.data/histogram.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/histogram.c	(revision 30972)
+++ trunk/Ohana/src/opihi/cmd.data/histogram.c	(revision 31160)
@@ -61,5 +61,4 @@
     opihi_int *V = xvec[0].elements.Int;
     for (i = 0; i < xvec[0].Nelements; i++, V++) {
-      if (isnan(*V)) continue;
       bin = MIN (MAX (0, (*V - start) / delta), Nbins - 1);
       OUT[bin]++;
Index: trunk/Ohana/src/opihi/cmd.data/limits.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/limits.c	(revision 30972)
+++ trunk/Ohana/src/opihi/cmd.data/limits.c	(revision 31160)
@@ -3,5 +3,5 @@
 int limits (int argc, char **argv) {
 
-  int N, APPLY;
+  int N, APPLY, dX, dY;
   int kapa;
   char *name;
@@ -28,5 +28,5 @@
   if ((N = get_argument (argc, argv, "-image"))) {
     remove_argument (N, &argc, argv);
-    KapaGetImageRange (kapa, &graphmode.xmin, &graphmode.xmax, &graphmode.ymax, &graphmode.ymin);
+    KapaGetImageRange (kapa, &graphmode.xmin, &graphmode.xmax, &graphmode.ymax, &graphmode.ymin, &dX, &dY);
 
     set_variable ("XMIN", graphmode.xmin);
@@ -34,4 +34,12 @@
     set_variable ("YMIN", graphmode.ymin);
     set_variable ("YMAX", graphmode.ymax);
+
+    set_variable ("KAPA_XMIN", graphmode.xmin);
+    set_variable ("KAPA_XMAX", graphmode.xmax);
+    set_variable ("KAPA_YMIN", graphmode.ymin);
+    set_variable ("KAPA_YMAX", graphmode.ymax);
+
+    set_variable ("KAPA_XPIX", dX);
+    set_variable ("KAPA_YPIX", dY);
 
     // if (!NoClear) KapaClearSections (kapa);
Index: trunk/Ohana/src/opihi/cmd.data/section.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/section.c	(revision 30972)
+++ trunk/Ohana/src/opihi/cmd.data/section.c	(revision 31160)
@@ -68,5 +68,5 @@
   if ((argc == 1) && (action == NONE)) {
     KapaGetSection (kapa, "*");
-    gprint (GP_ERR, "USAGE: section name [x y dx dy] [options]\n");
+    gprint (GP_ERR, "USAGE: section name [x y dx dy] or [options]\n");
     gprint (GP_ERR, "OPTIONS: -list   : show properties of all sections\n");
     gprint (GP_ERR, "         -up     : move section up in display stack\n");
@@ -76,7 +76,15 @@
     gprint (GP_ERR, "         -imtool (position) : set location of image zoom / status box\n");
     gprint (GP_ERR, "                 (position may be: -x, +x, -y, +y, none)\n");
+    gprint (GP_ERR, "         -image  : define section upper-right corner so image fills the section\n");
+    gprint (GP_ERR, "         -bg (color) : set background color (see style -c help for color choices)\n");
+    
     return (TRUE);
   } 
   
+  if ((argc != 2) && (action != NONE)) {
+      gprint (GP_ERR, "can only use dash options without numbers\n");
+      return (FALSE);
+  }
+
   if (argc == 2) {
     /* select / show section */
Index: trunk/Ohana/src/opihi/dvo/dbExtractImages.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/dbExtractImages.c	(revision 30972)
+++ trunk/Ohana/src/opihi/dvo/dbExtractImages.c	(revision 31160)
@@ -59,4 +59,5 @@
   time_t t;
   dbValue value;
+  off_t Nmosaic;
 
   value.Flt = NAN;
@@ -236,4 +237,21 @@
       value.Flt = image[N].fwhm_y / 25.0;
       break;
+
+    case IMAGE_FWHM_MEDIAN:
+      if (!(Nmosaic = FindMosaicForImage (image, Nimage, N))) return value;
+      Nmosaic --; // XXX kind of a hack: FindMosaicForImage returns 0 or the mosaic seq number + 1
+      value.Flt = (image[Nmosaic].fwhm_x + image[Nmosaic].fwhm_y) / 50.0;
+      break;
+    case IMAGE_FWHM_MAJ_MEDIAN:
+      if (!(Nmosaic = FindMosaicForImage (image, Nimage, N))) return value;
+      Nmosaic --; // XXX kind of a hack: FindMosaicForImage returns 0 or the mosaic seq number + 1
+      value.Flt = image[Nmosaic].fwhm_x / 25.0;
+      break;
+    case IMAGE_FWHM_MIN_MEDIAN:
+      if (!(Nmosaic = FindMosaicForImage (image, Nimage, N))) return value;
+      Nmosaic --; // XXX kind of a hack: FindMosaicForImage returns 0 or the mosaic seq number + 1
+      value.Flt = image[Nmosaic].fwhm_y / 25.0;
+      break;
+
     case IMAGE_TRATE:
       value.Flt = image[N].trate / 10000.0;
Index: trunk/Ohana/src/opihi/dvo/dbFields.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/dbFields.c	(revision 30972)
+++ trunk/Ohana/src/opihi/dvo/dbFields.c	(revision 31160)
@@ -395,7 +395,16 @@
   if (!strcasecmp (fieldName, "cerror"   )) ESCAPE (IMAGE_CERROR,    MAG_NONE, OPIHI_FLT);
 
-  if (!strcasecmp (fieldName, "FWHM"     )) ESCAPE (IMAGE_FWHM,      MAG_NONE, OPIHI_FLT);
-  if (!strcasecmp (fieldName, "FWHM_MAJ" )) ESCAPE (IMAGE_FWHM_MAJ,  MAG_NONE, OPIHI_FLT);
-  if (!strcasecmp (fieldName, "FWHM_MIN" )) ESCAPE (IMAGE_FWHM_MIN,  MAG_NONE, OPIHI_FLT);
+  if (!strcasecmp (fieldName, "FWHM"       )) ESCAPE (IMAGE_FWHM,      MAG_NONE, OPIHI_FLT);
+  if (!strcasecmp (fieldName, "FWHM_MAJ"   )) ESCAPE (IMAGE_FWHM_MAJ,  MAG_NONE, OPIHI_FLT);
+  if (!strcasecmp (fieldName, "FWHM_MIN"   )) ESCAPE (IMAGE_FWHM_MIN,  MAG_NONE, OPIHI_FLT);
+  if (!strcasecmp (fieldName, "FWHM_MAJOR" )) ESCAPE (IMAGE_FWHM_MAJ,  MAG_NONE, OPIHI_FLT);
+  if (!strcasecmp (fieldName, "FWHM_MINOR" )) ESCAPE (IMAGE_FWHM_MIN,  MAG_NONE, OPIHI_FLT);
+
+  if (!strcasecmp (fieldName, "FWHM_MEDIAN"    ))   ESCAPE (IMAGE_FWHM_MEDIAN,      MAG_NONE, OPIHI_FLT);
+  if (!strcasecmp (fieldName, "FWHM_MAJ_MEDIAN"))   ESCAPE (IMAGE_FWHM_MAJ_MEDIAN,  MAG_NONE, OPIHI_FLT);
+  if (!strcasecmp (fieldName, "FWHM_MIN_MEDIAN"))   ESCAPE (IMAGE_FWHM_MIN_MEDIAN,  MAG_NONE, OPIHI_FLT);
+  if (!strcasecmp (fieldName, "FWHM_MAJOR_MEDIAN")) ESCAPE (IMAGE_FWHM_MAJ_MEDIAN,  MAG_NONE, OPIHI_FLT);
+  if (!strcasecmp (fieldName, "FWHM_MINOR_MEDIAN")) ESCAPE (IMAGE_FWHM_MIN_MEDIAN,  MAG_NONE, OPIHI_FLT);
+
   if (!strcasecmp (fieldName, "trate"    )) ESCAPE (IMAGE_TRATE,     MAG_NONE, OPIHI_FLT);
 
Index: trunk/Ohana/src/opihi/dvo/imextract.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/imextract.c	(revision 30972)
+++ trunk/Ohana/src/opihi/dvo/imextract.c	(revision 31160)
@@ -197,7 +197,17 @@
     gprint (GP_ERR, "  cerror : astrometric scatter\n");
 
-    gprint (GP_ERR, "  FWHM : mean fwhm of exposure\n");
-    gprint (GP_ERR, "  FWHM_MAJ : fwhm of major axis\n");
-    gprint (GP_ERR, "  FWHM_MIN : fwhm of minor axis\n");
+    gprint (GP_ERR, "  -- Note: the follow FWHM are from the PSF model --\n");
+    gprint (GP_ERR, "  FWHM : mean fwhm of chip\n");
+    gprint (GP_ERR, "  FWHM_MAJ : fwhm of chip (major axis)\n");
+    gprint (GP_ERR, "  FWHM_MIN : fwhm of chip (minor axis)\n");
+    gprint (GP_ERR, "  FWHM_MAJOR : fwhm of chip (major axis)\n");
+    gprint (GP_ERR, "  FWHM_MININ : fwhm of chip (minor axis)\n");
+
+    gprint (GP_ERR, "  FWHM_MEDIAN : median fwhm of exposure\n");
+    gprint (GP_ERR, "  FWHM_MAJ_MEDIAN : median fwhm of major axis\n");
+    gprint (GP_ERR, "  FWHM_MIN_MEDIAN : median fwhm of minor axis\n");
+    gprint (GP_ERR, "  FWHM_MAJOR_MEDIAN : median fwhm of major axis\n");
+    gprint (GP_ERR, "  FWHM_MININ_MEDIAN : median fwhm of minor axis\n");
+
     gprint (GP_ERR, "  trate : tracking rate for TDI images\n");
 
Index: trunk/Ohana/src/opihi/dvo/skycoverage.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/skycoverage.c	(revision 30972)
+++ trunk/Ohana/src/opihi/dvo/skycoverage.c	(revision 31160)
@@ -5,5 +5,5 @@
 int skycoverage (int argc, char **argv) {
 
-  int WITH_MOSAIC, SOLO_MOSAIC;
+  int WITH_MOSAIC, SOLO_MOSAIC, ShowDensity;
   off_t i, Nimage;
   int N, status, TimeSelect, ByName, xs, ys;
@@ -60,4 +60,10 @@
   }
 
+  ShowDensity = FALSE;
+  if ((N = get_argument (argc, argv, "-density"))) {
+    remove_argument (N, &argc, argv);
+    ShowDensity = TRUE;
+  }
+
   ByName = FALSE;
   if ((N = get_argument (argc, argv, "-name"))) {
@@ -141,5 +147,5 @@
   if (argc != 3) {
     gprint (GP_ERR, "USAGE: skycoverage (buffer) (Npts)\n");
-    gprint (GP_ERR, "  options: [-scale pixscale] [-center ra dec] [-size Nx Nx] [-proj projection] [-time start range] [-trange start stop] [-name name] [-photcode name] [+mosaic] [-mosaic]\n");
+    gprint (GP_ERR, "  options: [-scale pixscale] [-center ra dec] [-size Nx Nx] [-proj projection] [-time start range] [-trange start stop] [-name name] [-photcode name] [+mosaic] [-mosaic] [-density]\n");
     gprint (GP_ERR, "       (buffer) saves bitmapped image\n");
     gprint (GP_ERR, "       (Npts) gives the number of test points per image in each dimension\n");
@@ -148,4 +154,5 @@
     gprint (GP_ERR, "       -size (Nx) (Ny)    : specifies the size of the image [360/scale, 180/scale]\n");
     gprint (GP_ERR, "       -proj (projection) : specifies the projection choice [AIT]\n");
+    gprint (GP_ERR, "       -density           : create image with relative density (else binary on/off)\n");
     gprint (GP_ERR, "       note: we need 64800 / (pixscale)^2 pixels to represent the sky\n");
     return (FALSE);
@@ -186,5 +193,4 @@
 
   V = (float *)buf[0].matrix.buffer;
-  bzero (V, Nx*Ny*sizeof(float));
 
   for (ys = 0; ys < Ny; ys++) {
@@ -194,5 +200,7 @@
       status &= (r <= 360);
       if (status) {
-	V[ys*Nx + xs] = 2;
+	V[ys*Nx + xs] = ShowDensity ?  0 : 2;
+      } else {
+	V[ys*Nx + xs] = ShowDensity ? -1 : 0;
       }
     }
@@ -249,5 +257,9 @@
 	  xs = (int)Xs;
 	  ys = (int)Ys;
-	  V[ys*Nx + xs] = 1;
+	  if (ShowDensity) {
+	      V[ys*Nx + xs] += 1;
+	  } else {
+	      V[ys*Nx + xs] = 1;
+	  }
 	}
       }
Index: trunk/Ohana/src/opihi/include/dvoshell.h
===================================================================
--- trunk/Ohana/src/opihi/include/dvoshell.h	(revision 30972)
+++ trunk/Ohana/src/opihi/include/dvoshell.h	(revision 31160)
@@ -179,4 +179,5 @@
       IMAGE_TIME, 
       IMAGE_FWHM, 
+      IMAGE_FWHM_MEDIAN, 
       IMAGE_EXPTIME, 
       IMAGE_NSTAR, 
@@ -200,4 +201,6 @@
       IMAGE_FWHM_MAJ,
       IMAGE_FWHM_MIN,
+      IMAGE_FWHM_MAJ_MEDIAN,
+      IMAGE_FWHM_MIN_MEDIAN,
       IMAGE_TRATE,
       IMAGE_IMAGE_ID,
Index: trunk/Ohana/src/opihi/lib.data/graphtools.c
===================================================================
--- trunk/Ohana/src/opihi/lib.data/graphtools.c	(revision 30972)
+++ trunk/Ohana/src/opihi/lib.data/graphtools.c	(revision 31160)
@@ -59,4 +59,9 @@
   set_variable ("YMIN", graphmode[0].ymin);
   set_variable ("YMAX", graphmode[0].ymax);
+
+  set_variable ("KAPA_XMIN", graphmode[0].xmin);
+  set_variable ("KAPA_XMAX", graphmode[0].xmax);
+  set_variable ("KAPA_YMIN", graphmode[0].ymin);
+  set_variable ("KAPA_YMAX", graphmode[0].ymax);
 }
 
@@ -95,4 +100,9 @@
   SetGraph (graphmode);
 
+  set_variable ("KAPA_XMIN", graphmode[0].xmin);
+  set_variable ("KAPA_XMAX", graphmode[0].xmax);
+  set_variable ("KAPA_YMIN", graphmode[0].ymin);
+  set_variable ("KAPA_YMAX", graphmode[0].ymax);
+
   set_variable ("XMIN", graphmode[0].xmin);
   set_variable ("XMAX", graphmode[0].xmax);
Index: trunk/Ohana/src/opihi/lib.shell/VectorOps.c
===================================================================
--- trunk/Ohana/src/opihi/lib.shell/VectorOps.c	(revision 30972)
+++ trunk/Ohana/src/opihi/lib.shell/VectorOps.c	(revision 31160)
@@ -218,5 +218,5 @@
     }
     free (vec[0].elements.Int);
-    vec[0].elements.Flt = vo;
+    vec[0].elements.Flt = temp;
     vec[0].type = OPIHI_FLT;
   } else {
@@ -229,5 +229,5 @@
     }
     free (vec[0].elements.Flt);
-    vec[0].elements.Int = vo;
+    vec[0].elements.Int = temp;
     vec[0].type = OPIHI_INT;
   }
