Index: trunk/Ohana/src/opihi/dvo/gstar.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/gstar.c	(revision 41426)
+++ trunk/Ohana/src/opihi/dvo/gstar.c	(revision 41427)
@@ -5,4 +5,6 @@
   GSTAR_BY_TIME,
   GSTAR_BY_PHOTCODE,
+  GSTAR_BY_IMAGE_ID,
+  GSTAR_BY_DET_ID,
 } GSTAR_SORT_CODES;
 
@@ -101,4 +103,16 @@
       sortCode = GSTAR_BY_PHOTCODE;
     }
+    if (!strcasecmp (argv[N], "image")) {
+      sortCode = GSTAR_BY_IMAGE_ID;
+    }
+    if (!strcasecmp (argv[N], "det")) {
+      sortCode = GSTAR_BY_DET_ID;
+    }
+    if (!strcasecmp (argv[N], "imageID")) {
+      sortCode = GSTAR_BY_IMAGE_ID;
+    }
+    if (!strcasecmp (argv[N], "detID")) {
+      sortCode = GSTAR_BY_DET_ID;
+    }
     remove_argument (N, &argc, argv);
   }
@@ -201,13 +215,51 @@
   }
 
-  // int PARALLEL = FALSE;
-  if ((N = get_argument (argc, argv, "-parallel"))) {
-    remove_argument (N, &argc, argv);
-    // PARALLEL = TRUE;
-    // can this now be deprecated?
+  PhotCode *photcode = NULL;
+  int photcodeEquiv = FALSE;
+  if ((N = get_argument (argc, argv, "-p"))) {
+    remove_argument (N, &argc, argv);
+    photcode = GetPhotcodebyName (argv[N]);
+    if (photcode == NULL) {
+      gprint (GP_ERR, "photcode %s not found\n", argv[N]);
+      return FALSE;
+    }
+    remove_argument (N, &argc, argv);
+    int Nsec = GetPhotcodeNsec (photcode->code);
+    if (Nsec != -1) photcodeEquiv = TRUE;
+  }
+  if ((N = get_argument (argc, argv, "-photcode"))) {
+    remove_argument (N, &argc, argv);
+    photcode = GetPhotcodebyName (argv[N]);
+    if (photcode == NULL) {
+      gprint (GP_ERR, "photcode %s not found\n", argv[N]);
+      return FALSE;
+    }
+    remove_argument (N, &argc, argv);
+    int Nsec = GetPhotcodeNsec (photcode->code);
+    if (Nsec != -1) photcodeEquiv = TRUE;
   }
 
   if (argc != 4) {
-    gprint (GP_ERR, "USAGE: gstar RA DEC Radius [-m]\n");
+    gprint (GP_ERR, "USAGE: gstar RA DEC Radius [options]\n");
+    gprint (GP_ERR, "OPTIONS:\n");    
+    gprint (GP_ERR, "-sort [photcode,time,image,det,imageID,detID]\n");    
+    gprint (GP_ERR, "-q : quiet\n");    
+    gprint (GP_ERR, "-inst : report instrumental mags\n");    
+    gprint (GP_ERR, "-masks : show masks\n");    
+    gprint (GP_ERR, "-save : save m, t, z, f, dr, dd in vectors\n");    
+    gprint (GP_ERR, "-full : show more information\n");    
+    gprint (GP_ERR, "+stack: report stack averages\n");    
+    gprint (GP_ERR, "+warp : report warp averages\n");    
+    gprint (GP_ERR, "+extras : extra output fields\n");    
+    gprint (GP_ERR, "+flux : report average fluxes\n");    
+    gprint (GP_ERR, "-mag : suppress magnitude fielss\n");    
+    gprint (GP_ERR, "+kron : report kron mags\n");    
+    gprint (GP_ERR, "+aper : report aper mags\n");    
+    gprint (GP_ERR, "-m : report individual measurements\n");    
+    gprint (GP_ERR, "-meas : report individual measurements\n");    
+    gprint (GP_ERR, "-lens : report lensing data\n");    
+    gprint (GP_ERR, "-p [photcode] : restrict to photcode\n");    
+    gprint (GP_ERR, "-photcode [photcode] : restrict to photcode\n");    
+    gprint (GP_ERR, "\n");    
     return (FALSE);
   }
@@ -695,4 +747,10 @@
 	      value[j] = catalog.measure[j + m].t;
 	      break;
+	    case GSTAR_BY_IMAGE_ID:
+	      value[j] = catalog.measure[j + m].imageID;
+	      break;
+	    case GSTAR_BY_DET_ID:
+	      value[j] = catalog.measure[j + m].detID;
+	      break;
 	  }
 	}
@@ -703,4 +761,9 @@
 
 	  int Nv = index[j];
+
+	  if (photcode) {
+	    if ( photcodeEquiv && (photcode[0].code != GetPhotcodeEquivCodebyCode(catalog.measure[Nv].photcode))) continue;
+	    if (!photcodeEquiv && (photcode[0].code != catalog.measure[Nv].photcode)) continue;
+	  }
 
 	  Mcat = PhotCat (&catalog.measure[Nv], MAG_CLASS_PSF);
