Index: trunk/Ohana/src/opihi/cmd.data/Makefile
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/Makefile	(revision 38454)
+++ trunk/Ohana/src/opihi/cmd.data/Makefile	(revision 38463)
@@ -25,4 +25,5 @@
 $(SRC)/book.$(ARCH).o		\
 $(SRC)/book_commands.$(ARCH).o	\
+$(SRC)/bisection.$(ARCH).o		\
 $(SRC)/cast.$(ARCH).o		\
 $(SRC)/center.$(ARCH).o	\
Index: trunk/Ohana/src/opihi/cmd.data/bisection.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/bisection.c	(revision 38463)
+++ trunk/Ohana/src/opihi/cmd.data/bisection.c	(revision 38463)
@@ -0,0 +1,37 @@
+# include "data.h"
+
+int bisection (int argc, char **argv) {
+  
+  int N;
+  Vector *vec;
+
+  int QUIET = FALSE;
+  if ((N = get_argument (argc, argv, "-q"))) {
+    QUIET = TRUE;
+    remove_argument (N, &argc, argv);
+  }
+
+  if (argc != 3) {
+    gprint (GP_ERR, "USAGE: bisection <vector> (threshold)\n");
+    gprint (GP_ERR, "  return the vector index for which the vector is last below the threshold via bisection\n");
+    gprint (GP_ERR, "  vector must be sorted\n");
+    return (FALSE);
+  }
+  
+  if ((vec = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE);
+  double threshold = atof (argv[2]);
+  
+  int isFlt = (vec[0].type == OPIHI_FLT);
+
+  if (isFlt) {
+    N = ohana_bisection_double (vec[0].elements.Flt, vec[0].Nelements, threshold);
+  } else {
+    // N = ohana_bisection_int (vec[0].elements.Flt, vec[0].Nelements);
+  }
+
+  set_variable ("bisecbin", N);
+
+  if (!QUIET) gprint (GP_LOG, "bin %d for theshold %f\n", N, threshold);
+
+  return (TRUE);
+}
Index: trunk/Ohana/src/opihi/cmd.data/init.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/init.c	(revision 38454)
+++ trunk/Ohana/src/opihi/cmd.data/init.c	(revision 38463)
@@ -9,6 +9,6 @@
 int box              PROTO((int, char **));
 int book_command     PROTO((int, char **));
+int bisection        PROTO((int, char **));
 int center           PROTO((int, char **));
-int parity           PROTO((int, char **));
 int cast             PROTO((int, char **));
 int circstats        PROTO((int, char **));
@@ -90,4 +90,5 @@
 int plot             PROTO((int, char **));
 int dot              PROTO((int, char **));
+int parity           PROTO((int, char **));
 int point            PROTO((int, char **));
 int ps               PROTO((int, char **));
@@ -176,4 +177,5 @@
   {1, "applyfit2d",   applyfit2d,       "apply 2-d fit to new vector"},
   {1, "applyfit3d",   applyfit3d,       "apply 3-d fit to new vector"},
+  {1, "bisection",    bisection,        "use bisection to find threshold in vector"},
   {1, "book",         book_command,     "commands to manipulate book/page/word data"},
   {1, "box",          box,              "draw a box on the plot"},
Index: trunk/Ohana/src/opihi/cmd.data/tvcolors.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/tvcolors.c	(revision 38454)
+++ trunk/Ohana/src/opihi/cmd.data/tvcolors.c	(revision 38463)
@@ -16,12 +16,34 @@
   FREE (name);
 
+  int SetNAN = FALSE;
+  int red, green, blue;
+  if ((N = get_argument (argc, argv, "-nan"))) {
+    if (N > argc - 4) { 
+      gprint (GP_ERR, "ERROR: -nan (red) (green) (blue) does not have enough arguments\n"); 
+      return FALSE; 
+    }
+    remove_argument (N, &argc, argv);
+    red = strtol (argv[N], NULL, 0);
+    remove_argument (N, &argc, argv);
+    green = strtol (argv[N], NULL, 0);
+    remove_argument (N, &argc, argv);
+    blue = strtol (argv[N], NULL, 0);
+    remove_argument (N, &argc, argv);
+    SetNAN = TRUE;
+  }
+
   // use the currently-set zero,range values if not supplied
-  if (argc != 2) {
-    gprint (GP_ERR, "USAGE: tvcolors (colormap)\n");
+  if (!SetNAN && (argc != 2)) {
+    gprint (GP_ERR, "USAGE: tvcolors (colormap) [-nan red green blue]\n");
     gprint (GP_ERR, " colormap options : greyscale, -greyscale, rainbow, heat, fullcolor, ruffcolor (also grayscale, -grayscale)\n");
     return (FALSE);
   }
 
-  KiiSetColormap (kapa, argv[1]);
+  if (SetNAN) {
+    KiiSetNanColor (kapa, red, green, blue);
+  }
+  if (argc == 2) {
+    KiiSetColormap (kapa, argv[1]);
+  }
   return (TRUE);
 }
