Index: /branches/eam_branches/ipp-20110505/Ohana/src/opihi/cmd.astro/czplot.c
===================================================================
--- /branches/eam_branches/ipp-20110505/Ohana/src/opihi/cmd.astro/czplot.c	(revision 31535)
+++ /branches/eam_branches/ipp-20110505/Ohana/src/opihi/cmd.astro/czplot.c	(revision 31536)
@@ -3,5 +3,5 @@
 int czplot (int argc, char **argv) {
   
-  int i, kapa;
+  int i, kapa, Npts, status;
   double min, range, Rmin, Rmax;
   opihi_flt *out, *r, *d, *x, *y;
@@ -18,6 +18,6 @@
   min = atof(argv[4]);
   range = atof(argv[5]) - min;
-  Rmin = graphmode.coords.crval1 - 180.0;
-  Rmax = graphmode.coords.crval1 + 180.0;
+  Rmin = graphmode.coords.crval1 - 182.0;
+  Rmax = graphmode.coords.crval1 + 182.0;
 
   /* find vectors */
@@ -46,21 +46,30 @@
   x   = Xvec.elements.Flt;
   y   = Yvec.elements.Flt;
-  for (i = 0; i < Zvec.Nelements; i++, r++, d++, x++, y++) {
+  out = Zvec.elements.Flt;
+
+  Npts = 0;
+  for (i = 0; i < xvec[0].Nelements; i++, r++, d++) {
     *r = ohana_normalize_angle (*r);
-    RD_to_XY (x, y, *r, *d, &graphmode.coords);
+    while (*r < Rmin) *r += 360.0;
+    while (*r > Rmax) *r -= 360.0;
+
+    status = RD_to_XY (x, y, *r, *d, &graphmode.coords);
+    if (!status) continue;
+
+    if (zvec->type == OPIHI_FLT) {
+      opihi_flt *in  = zvec[0].elements.Flt;
+      *out = MIN (1.0, MAX (0.01, (in[i] - min) / range));
+    } else {
+      opihi_int *in  = zvec[0].elements.Int;
+      *out = MIN (1.0, MAX (0.01, (in[i] - min) / range));
+    }
+    x++;
+    y++;
+    out++;
+    Npts++;
   }
-
-  out = Zvec.elements.Flt;
-  if (zvec->type == OPIHI_FLT) {
-    opihi_flt *in  = zvec[0].elements.Flt;
-    for (i = 0; i < Zvec.Nelements; i++, in++, out++) {
-      *out = MIN (1.0, MAX (0.01, (*in - min) / range));
-    }
-  } else {
-    opihi_int *in  = zvec[0].elements.Int;
-    for (i = 0; i < Zvec.Nelements; i++, in++, out++) {
-      *out = MIN (1.0, MAX (0.01, (*in - min) / range));
-    }
-  }
+  Xvec.Nelements = Npts;
+  Yvec.Nelements = Npts;
+  Zvec.Nelements = Npts;
 
   graphmode.style = 2;
