Index: /branches/eam_branches/ipp-20230313/Ohana/src/opihi/cmd.data/interpolate_presort.c
===================================================================
--- /branches/eam_branches/ipp-20230313/Ohana/src/opihi/cmd.data/interpolate_presort.c	(revision 42684)
+++ /branches/eam_branches/ipp-20230313/Ohana/src/opihi/cmd.data/interpolate_presort.c	(revision 42685)
@@ -17,5 +17,5 @@
   /** check basic syntax **/
   if (argc != 5) {
-    gprint (GP_ERR, "USAGE: interpolate Xi Yi Xo Yo\n");
+    gprint (GP_ERR, "USAGE: interpolate Xi Yi Xo Yo [-fill-ends]\n");
     gprint (GP_ERR, "  Xi Yi - sorted reference vectors\n");
     gprint (GP_ERR, "  Xo    - output positions (vector)\n");
@@ -23,4 +23,5 @@
     gprint (GP_ERR, "  (vectors must be pre-sorted)\n");
     gprint (GP_ERR, "  (use 'threshold' to interpolate to a value)\n");
+    gprint (GP_ERR, "  -fill-ends : values outside of range are set to end-point values\n");
     return (FALSE);
   }
Index: /branches/eam_branches/ipp-20230313/Ohana/src/opihi/cmd.data/vgroup.c
===================================================================
--- /branches/eam_branches/ipp-20230313/Ohana/src/opihi/cmd.data/vgroup.c	(revision 42684)
+++ /branches/eam_branches/ipp-20230313/Ohana/src/opihi/cmd.data/vgroup.c	(revision 42685)
@@ -70,5 +70,7 @@
   ALLOCATE (values, double, xin[0].Nelements);
 
-  for (i = 0; i < xout[0].Nelements - 1; i++) {
+  // if we specify binsize, then we need to examine all bins
+  int Nout = isnan(binsize) ? xout[0].Nelements - 1 : xout[0].Nelements;
+  for (i = 0; i < Nout; i++) {
     if (isnan(binsize)) {
       xmin = xout[0].elements.Flt[i];
@@ -81,6 +83,6 @@
     N = 0;
     for (j = 0; j < xin[0].Nelements; j++) {
-      if (xin[0].elements.Flt[j] < xmin) continue;
-      if (xin[0].elements.Flt[j] > xmax) continue;
+      if (xin[0].elements.Flt[j] <  xmin) continue;
+      if (xin[0].elements.Flt[j] >= xmax) continue;
       if (yin) {
 	values[N] = yin[0].elements.Flt[j];
