Index: trunk/Ohana/src/opihi/dvo/avselect.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/avselect.c	(revision 40524)
+++ trunk/Ohana/src/opihi/dvo/avselect.c	(revision 40525)
@@ -8,9 +8,9 @@
    * loop over the catalogs
    * within a catalog, use the find_match code to find the matching coordinates
-   * use dbExtractAverages to get the fields for the matched entry 
+   * use dbExtractAverages to get the fields for the matched entry
  */
 
 int avselect (int argc, char **argv) {
-  
+
   off_t i, j, n, m;
   int N, Ncat, Npts, NPTS, last, Nfields, Nsecfilt, Ninvec;
@@ -83,5 +83,5 @@
 
   // init locally static variables (time refs)
-  dbExtractAveragesInit (); 
+  dbExtractAveragesInit ();
 
   RAvec  = NULL;
@@ -138,5 +138,5 @@
     targv[targc+1] = CoordsFile; // this gets freed with targv
     targc += 2;
-    
+
     // if needed, add the index vector to the args list
     if (IDXvec) {
@@ -145,5 +145,5 @@
       targv[targc+1] = strcreate (IDXvec[0].name);
       targc += 2;
-    }      
+    }
     if (RADvec) {
       REALLOCATE (targv, char *, targc + 2);
@@ -151,10 +151,10 @@
       targv[targc+1] = strcreate (RADvec[0].name);
       targc += 2;
-    }      
+    }
 
     // I need to pass the RA & DEC vectors to the remote clients...
     int status = HostTableParallelOps (skylist, targc, targv, RESULT_FILE, TRUE, 0, VERBOSE);
     if (vec) free (vec);
-    
+
     // free up targv
     for (i = 0; i < targc; i++) {
@@ -226,5 +226,5 @@
 
     if (VERBOSE) gprint (GP_ERR, "trying %s ("OFF_T_FMT" of "OFF_T_FMT")\n", catalog.filename,  i,  skylist[0].Nregions);
-      
+
     // an error exit status here is a significant error
     if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
@@ -259,23 +259,23 @@
 
       // reset counters for saved fields, extract fields
-      dbExtractAveragesInitAve (); 
+      dbExtractAveragesInitAve ();
       for (n = 0; n < Nfields; n++) {
-	values[n] = dbExtractAverages (average, secfilt, measure, lensobj, starpar, NULL, &fields[n]);
+        values[n] = dbExtractAverages (average, secfilt, measure, lensobj, starpar, NULL, &fields[n]);
       }
 
       // set resulting values
       for (n = 0; n < Nfields; n++) {
-	if (vec[n][0].type == OPIHI_FLT) {
-	  vec[n][0].elements.Flt[Npts] = values[n].Flt;
-	} else {
-	  vec[n][0].elements.Int[Npts] = values[n].Int;
-	}
+        if (vec[n][0].type == OPIHI_FLT) {
+          vec[n][0].elements.Flt[Npts] = values[n].Flt;
+        } else {
+          vec[n][0].elements.Int[Npts] = values[n].Int;
+        }
       }
       // set (optional) IDXvec and RADvec
       if (IDXvec) {
-	IDXvec[0].elements.Int[Npts] = result[j].Nseq;;
+        IDXvec[0].elements.Int[Npts] = result[j].Nseq;;
       }
       if (RADvec) {
-	RADvec[0].elements.Flt[Npts] = result[j].Roff;;
+        RADvec[0].elements.Flt[Npts] = result[j].Roff;;
       }
 
@@ -283,14 +283,14 @@
       Npts++;
       if (Npts >= NPTS) {
-	NPTS += 2000;
-	for (n = 0; n < Nfields; n++) {
-	  REALLOCATE (vec[n][0].elements.Flt, opihi_flt, NPTS);
-	}
-	if (IDXvec) {
-	  REALLOCATE (IDXvec[0].elements.Int, opihi_int, NPTS);
-	}
-	if (RADvec) {
-	  REALLOCATE (RADvec[0].elements.Flt, opihi_flt, NPTS);
-	}
+        NPTS += 2000;
+        for (n = 0; n < Nfields; n++) {
+          REALLOCATE (vec[n][0].elements.Flt, opihi_flt, NPTS);
+        }
+        if (IDXvec) {
+          REALLOCATE (IDXvec[0].elements.Int, opihi_int, NPTS);
+        }
+        if (RADvec) {
+          REALLOCATE (RADvec[0].elements.Flt, opihi_flt, NPTS);
+        }
       }
     }
@@ -345,9 +345,13 @@
 
  help:
-  gprint (GP_ERR, "USAGE: avselect (RA) (DEC) (RADIUS) field[,field,field...]\n");
+  gprint (GP_ERR, "USAGE: avselect (RA) (DEC) (RADIUS) field[,field,field...] [-index index] [-radius radius]\n");
   gprint (GP_ERR, "   OR: avselect -coords (filename.fits) (RADIUS) field[,field,field...]\n");
   gprint (GP_ERR, "   RADIUS is in arcseconds\n");
+  gprint (GP_ERR, "   -index index : return an index into the input RA,DEC vectors (e.g, field[i] matches RA[index[i]])\n");
+  gprint (GP_ERR, "   -radius radius : return the distance (in arcseconds) between the returned object and the matched coordinate\n");
 
   if ((argc > N + 1) && !strcasecmp (argv[N+1], "fields")) {
+    gprint (GP_ERR, "  NOTE: the list below is incomplete\n");
+
     gprint (GP_ERR, "  RA : right ascension (J2000) [degrees]\n");
     gprint (GP_ERR, "  DEC : declination [degrees]\n");
