Index: /branches/eam_branches/ipp-20150419/Ohana/src/kapa2/include/prototypes.h
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/kapa2/include/prototypes.h	(revision 38438)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/kapa2/include/prototypes.h	(revision 38439)
@@ -83,4 +83,5 @@
 int           SetChannel          PROTO((int sock));
 int           SetColormapFromPipe PROTO((int sock));
+int           SetNanColorFromPipe PROTO((int sock));
 
 int           LoadVectorData      PROTO((int sock, KapaGraphWidget *graph, int N, char *type));
Index: /branches/eam_branches/ipp-20150419/Ohana/src/kapa2/include/structures.h
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/kapa2/include/structures.h	(revision 38438)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/kapa2/include/structures.h	(revision 38439)
@@ -35,4 +35,5 @@
   unsigned long *color;      // graph plotting colors
   int            Ncolors;
+  char          *colormapName;
 
   unsigned long *pixels;      // image pixel colors
Index: /branches/eam_branches/ipp-20150419/Ohana/src/kapa2/src/CheckPipe.c
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/kapa2/src/CheckPipe.c	(revision 38438)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/kapa2/src/CheckPipe.c	(revision 38439)
@@ -316,4 +316,10 @@
   }
 
+  if (!strcmp (word, "CNAN")) {
+    status = SetNanColorFromPipe (sock);
+    KiiSendCommand (sock, 4, "DONE");
+    FINISHED (status);
+  }
+
   if (!strcmp (word, "SAVE")) {
     status = SaveOverlay (sock);
Index: /branches/eam_branches/ipp-20150419/Ohana/src/kapa2/src/InterpretKeys.c
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/kapa2/src/InterpretKeys.c	(revision 38438)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/kapa2/src/InterpretKeys.c	(revision 38439)
@@ -102,4 +102,5 @@
       UpdateStatusBox (graphic, image, X, Y, 0.0, 1); \
       Remap (graphic, image); \
+      Refresh (); \
       break;
 
Index: /branches/eam_branches/ipp-20150419/Ohana/src/kapa2/src/SetChannel.c
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/kapa2/src/SetChannel.c	(revision 38438)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/kapa2/src/SetChannel.c	(revision 38439)
@@ -57,5 +57,5 @@
     // image = section->image;
     SetColorScale (graphic, section->image);
-    if (!USE_XWINDOW) return (TRUE);
+    if (!USE_XWINDOW) return TRUE;
     Remap (graphic, section->image);
   }
@@ -66,2 +66,36 @@
   return (TRUE);
 }
+
+int SetNanColorFromPipe (int sock) {
+
+  int i, red_value, green_value, blue_value;
+  KiiScanMessage (sock, "%d %d %d", &red_value, &green_value, &blue_value);
+
+  NAN_RED   = red_value;
+  NAN_GREEN = green_value;
+  NAN_BLUE  = blue_value;
+
+  // use graphic->colormapName saved value
+  SetColormap (NULL);
+
+  if (!USE_XWINDOW) return (TRUE);
+  
+  Graphic *graphic = GetGraphic ();
+
+  int NeedRefresh = FALSE;
+  int Nsection = GetNumberOfSections ();
+  for (i = 0; i < Nsection; i++) {
+    Section *section = GetSectionByNumber (i);
+    if (section->image) { 
+      NeedRefresh = TRUE;
+      SetColorScale (graphic, section->image);
+      Remap (graphic, section->image);
+    }
+  }
+  if (NeedRefresh) {
+    Refresh ();
+    XFlush (graphic[0].display);
+  }
+
+  return (TRUE);
+}
Index: /branches/eam_branches/ipp-20150419/Ohana/src/kapa2/src/SetColormap.c
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/kapa2/src/SetColormap.c	(revision 38438)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/kapa2/src/SetColormap.c	(revision 38439)
@@ -16,5 +16,5 @@
 // display of) an image, we simply remap the lit pixels (in Remap32.c, etc).
 
-int SetColormap (char *name) {
+int SetColormap (char *inName) {
 
   int i, red, blue, green;
@@ -24,4 +24,11 @@
   graphic = GetGraphic();
 
+  if (!inName && !graphic->colormapName) abort();
+
+  if (inName) {
+    if (graphic->colormapName) free (graphic->colormapName);
+    graphic->colormapName = strcreate (inName);
+  }
+
   int NANValue = graphic[0].Npixels - 1;
   int MaxValue = graphic[0].Npixels - 1;
@@ -29,5 +36,5 @@
   // the "fullcolor" colormap is uniquely defined for each image;
   // defer to the 'SetColorScale' step
-  if (!strcasecmp (name, "fullcolor")) {
+  if (!strcasecmp (graphic->colormapName, "fullcolor")) {
     graphic[0].ColorScaleMode = KAPA_SCALE_3D_FULL;
     if (SetColorCubeHistogram ()) return TRUE;
@@ -44,5 +51,5 @@
 
   // very simple color model: evenly spaced cube 
-  if (!strcasecmp (name, "ruffcolor")) {
+  if (!strcasecmp (graphic->colormapName, "ruffcolor")) {
       graphic[0].nRed  = pow (graphic[0].Npixels, 0.333);
       graphic[0].nBlue = pow (graphic[0].Npixels, 0.333);
@@ -79,5 +86,5 @@
 
   /* greyscale */
-  if ((!strcasecmp (name, "grayscale")) || (!strcasecmp (name, "greyscale"))) {
+  if ((!strcasecmp (graphic->colormapName, "grayscale")) || (!strcasecmp (graphic->colormapName, "greyscale"))) {
     for (i = 0; i < MaxValue; i++) {  
       SETVALUE (graphic[0].cmap[i].red,   0xffff - i*scale, 0, 0xffff);
@@ -89,5 +96,5 @@
   }
   /* -grayscale */
-  if ((!strcasecmp (name, "-grayscale")) || (!strcasecmp (name, "-greyscale"))) {
+  if ((!strcasecmp (graphic->colormapName, "-grayscale")) || (!strcasecmp (graphic->colormapName, "-greyscale"))) {
     for (i = 0; i < MaxValue; i++) {  
       SETVALUE (graphic[0].cmap[i].red,   i*scale, 0, 0xffff);
@@ -99,5 +106,5 @@
   }
   /* heat */
-  if (!strcasecmp (name, "Heat")) {
+  if (!strcasecmp (graphic->colormapName, "Heat")) {
     greenRef = 0.25*MaxValue*scale*2.0;
     blueRef  = 0.50*MaxValue*scale*2.0;
@@ -129,5 +136,5 @@
   }
   /* rainbow */
-  if (!strcasecmp (name, "Rainbow")) {
+  if (!strcasecmp (graphic->colormapName, "Rainbow")) {
     redRef   = 0.25*MaxValue*scale*4.0;
     greenRef = 0.50*MaxValue*scale*4.0;
@@ -167,5 +174,5 @@
   }
   /* anuenue */
-  if (!strcasecmp (name, "anuenue")) {
+  if (!strcasecmp (graphic->colormapName, "anuenue")) {
     redRef   = 0.25*MaxValue*scale*4.0; // value at 0.0
     greenRef = 0.50*MaxValue*scale*4.0;
@@ -207,8 +214,8 @@
 
   /* anuenue */
-  if (!strncmp (name, "file:", 5)) {
-    FILE *f = fopen (&name[5], "r");
+  if (!strncmp (graphic->colormapName, "file:", 5)) {
+    FILE *f = fopen (&graphic->colormapName[5], "r");
     if (!f) {
-      fprintf (stderr, "failed to open colormap file %s\n", &name[5]);
+      fprintf (stderr, "failed to open colormap file %s\n", &graphic->colormapName[5]);
       return FALSE;
     }
Index: /branches/eam_branches/ipp-20150419/Ohana/src/kapa2/src/SetUpGraphic.c
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/kapa2/src/SetUpGraphic.c	(revision 38438)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/kapa2/src/SetUpGraphic.c	(revision 38439)
@@ -42,4 +42,6 @@
   CheckColors (graphic, argc, argv);
 
+  graphic->colormapName = NULL;
+
   icon.width = icon_width;
   icon.height = icon_height;
Index: /branches/eam_branches/ipp-20150419/Ohana/src/libkapa/include/kapa.h
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/libkapa/include/kapa.h	(revision 38438)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/libkapa/include/kapa.h	(revision 38439)
@@ -146,4 +146,5 @@
 int KiiSetChannel (int fd, int channel);
 int KiiSetColormap (int fd, char *colormap);
+int KiiSetNanColor (int fd, int red, int green, int blue);
 int KiiNewPicture1D (int fd, KiiImage *image, KapaImageData *data, Coords *coords);
 int KiiNewPicture2D (int fd, KiiImage *image, KapaImageData *data, Coords *coords);
Index: /branches/eam_branches/ipp-20150419/Ohana/src/libkapa/src/KiiPicture.c
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/libkapa/src/KiiPicture.c	(revision 38438)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/libkapa/src/KiiPicture.c	(revision 38439)
@@ -14,4 +14,13 @@
   KiiSendCommand (fd, 4, "CMAP"); /* tell kapa to look for the incoming image */
   KiiSendMessage (fd, "%s", colormap);
+  
+  KiiWaitAnswer (fd, "DONE");
+  return (TRUE);
+}
+
+int KiiSetNanColor (int fd, int red, int green, int blue) {
+
+  KiiSendCommand (fd, 4, "CNAN"); /* tell kapa to look for the incoming image */
+  KiiSendMessage (fd, "%d %d %d ", red, green, blue);
   
   KiiWaitAnswer (fd, "DONE");
Index: /branches/eam_branches/ipp-20150419/Ohana/src/opihi/cmd.data/tvcolors.c
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/opihi/cmd.data/tvcolors.c	(revision 38438)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/opihi/cmd.data/tvcolors.c	(revision 38439)
@@ -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);
 }
