Index: /branches/eam_branches/ipp-20121219/Ohana/src/delstar/Makefile
===================================================================
--- /branches/eam_branches/ipp-20121219/Ohana/src/delstar/Makefile	(revision 34871)
+++ /branches/eam_branches/ipp-20121219/Ohana/src/delstar/Makefile	(revision 34872)
@@ -31,4 +31,5 @@
 $(SRC)/delete_image_photcodes.$(ARCH).o \
 $(SRC)/delete_photcodes.$(ARCH).o \
+$(SRC)/delete_photcodes_single.$(ARCH).o \
 $(SRC)/delete_times.$(ARCH).o 	  \
 $(SRC)/gimages.$(ARCH).o   	  \
@@ -45,4 +46,5 @@
 $(SRC)/args.$(ARCH).o	          \
 $(SRC)/delete_photcodes.$(ARCH).o \
+$(SRC)/delete_photcodes_single.$(ARCH).o \
 $(SRC)/Shutdown.$(ARCH).o          
 
Index: /branches/eam_branches/ipp-20121219/Ohana/src/delstar/include/delstar.h
===================================================================
--- /branches/eam_branches/ipp-20121219/Ohana/src/delstar/include/delstar.h	(revision 34871)
+++ /branches/eam_branches/ipp-20121219/Ohana/src/delstar/include/delstar.h	(revision 34872)
@@ -100,2 +100,3 @@
 int delete_photcodes_catalog (Catalog *catalog, PhotCode **photcodes, int Nphotcodes);
 int delete_image_photcodes (FITS_DB *db);
+int delete_photcodes_single (char *cptname);
Index: /branches/eam_branches/ipp-20121219/Ohana/src/delstar/src/args.c
===================================================================
--- /branches/eam_branches/ipp-20121219/Ohana/src/delstar/src/args.c	(revision 34871)
+++ /branches/eam_branches/ipp-20121219/Ohana/src/delstar/src/args.c	(revision 34872)
@@ -169,11 +169,42 @@
 goodtime:
 
+  if ((N = get_argument (argc, argv, "-cpt"))) {
+    remove_argument (N, &argc, argv);
+    char *filename = strcreate (argv[N]);
+    remove_argument (N, &argc, argv);
+
+    if (argc != 1) {
+      fprintf (stderr, "USAGE: delstar -cpt filename.cpt\n");
+      exit (2);
+    }
+
+    switch (MODE) {
+      case MODE_IMAGEFILE:
+      case MODE_IMAGENAME:
+      case MODE_TIME:
+      case MODE_ORPHAN:
+      case MODE_MISSED:
+	fprintf (stderr, "mode not available for single cpt deletion\n");
+	break;
+      case MODE_PHOTCODES: {
+	if (!delete_photcodes_single (filename)) {
+	  fprintf (stderr, "failure deleting measurements\n");
+	  exit (1);
+	}
+	exit (0);
+      }
+      default:
+	usage ();
+    }
+    exit (0);
+  }
+
   /* restrict to a single photcode (not compatible with -image) 
-  PHOTCODE = NULL;
-  if ((N = get_argument (argc, argv, "-photcode"))) {
-    remove_argument (N, &argc, argv);
-    PHOTCODE = GetPhotcodebyName (argv[N]);
-    remove_argument (N, &argc, argv);
-  }*/
+     PHOTCODE = NULL;
+     if ((N = get_argument (argc, argv, "-photcode"))) {
+     remove_argument (N, &argc, argv);
+     PHOTCODE = GetPhotcodebyName (argv[N]);
+     remove_argument (N, &argc, argv);
+     }*/
 
   if (argc != 1) usage ();
Index: /branches/eam_branches/ipp-20121219/Ohana/src/delstar/src/delete_photcodes_single.c
===================================================================
--- /branches/eam_branches/ipp-20121219/Ohana/src/delstar/src/delete_photcodes_single.c	(revision 34872)
+++ /branches/eam_branches/ipp-20121219/Ohana/src/delstar/src/delete_photcodes_single.c	(revision 34872)
@@ -0,0 +1,33 @@
+# include "delstar.h"
+
+int delete_photcodes_single (char *cptname) {
+
+  Catalog catalog;
+
+  int Nphotcodes = 0;
+  PhotCode **photcodes = ParsePhotcodeList (PHOTCODE_LIST, &Nphotcodes, FALSE);
+
+  catalog.filename  = cptname;
+  catalog.Nsecfilt  = GetPhotcodeNsecfilt ();
+  catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
+
+  if (VERBOSE) fprintf (stderr, "deleting from %s\n", catalog.filename);
+
+  // an error exit status here is a significant error
+  if (!dvo_catalog_open (&catalog, NULL, VERBOSE2, "a")) {
+    fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
+    return FALSE;
+  }
+  if (!catalog.Naves_disk) {
+    if (VERBOSE2) fprintf (stderr, "no data in %s, skipping\n", catalog.filename);
+    dvo_catalog_unlock (&catalog);
+    dvo_catalog_free (&catalog);
+    return FALSE;
+  }
+
+  delete_photcodes_catalog (&catalog, photcodes, Nphotcodes);
+  dvo_catalog_save_complete (&catalog, VERBOSE2);
+  dvo_catalog_unlock (&catalog);
+  dvo_catalog_free (&catalog);
+  return TRUE;
+}
Index: /branches/eam_branches/ipp-20121219/Ohana/src/libdvo/include/dvo.h
===================================================================
--- /branches/eam_branches/ipp-20121219/Ohana/src/libdvo/include/dvo.h	(revision 34871)
+++ /branches/eam_branches/ipp-20121219/Ohana/src/libdvo/include/dvo.h	(revision 34872)
@@ -658,4 +658,5 @@
 SkyTable  *SkyTableLoadOptimal 	   PROTO((char *catdir, char *SKYFILE, char *GSCFILE, int readwrite, int depth, int VERBOSE));
 int        SkyTableSetDepth    	   PROTO((SkyTable *sky, int depth));
+SkyList   *SkyRegionByCPT          PROTO((SkyTable *table, char *filename));
 SkyList   *SkyRegionByPoint    	   PROTO((SkyTable *table, int depth, double ra, double dec));
 SkyList   *SkyListByPoint      	   PROTO((SkyTable *table, double ra, double dec));
Index: /branches/eam_branches/ipp-20121219/Ohana/src/libdvo/src/skyregion_ops.c
===================================================================
--- /branches/eam_branches/ipp-20121219/Ohana/src/libdvo/src/skyregion_ops.c	(revision 34871)
+++ /branches/eam_branches/ipp-20121219/Ohana/src/libdvo/src/skyregion_ops.c	(revision 34872)
@@ -7,4 +7,51 @@
    If the region at the given depth is populated with an image table, then 'image' is TRUE.
    I have defined no accelerators other than the table hierarchy */
+
+/* given /path/file.ext return pointer to file.ext */
+char *filebasename_ptr (char *name) {
+ 
+  char *c, *file;
+
+  c = strrchr (name, '/');
+  if (c) return (c+1);
+  return name;
+}
+
+/* find region which matches the named file */
+SkyList *SkyRegionByCPT (SkyTable *table, char *filename) {
+  
+  int i, Ns, Ne, No;
+  SkyRegion *region;
+  SkyList *list;
+
+  ALLOCATE (list, SkyList, 1);
+  ALLOCATE (list[0].regions,  SkyRegion *, 1);
+  ALLOCATE (list[0].filename,  char *, 1);
+  list[0].Nregions = 0;
+  list[0].ownElements = FALSE; // this list is only holding a view to the elements
+  strcpy (list[0].hosts, table[0].hosts);
+
+  // i'd like to select the region from the given cpt filename, but
+  // in a parallel environment, the filename does not match the canonical name
+  // i select the basename to match 
+
+  // we might have been given foo.cpt or just foo:
+  char *tgtbase = filebasename_ptr (filename);
+  int Ntgtbase = strlen(tgtbase);
+  if ((Ntgtbase > 4) && (!strcmp (&tgtbase[Ntgtbase - 4], ".cpt"))) {
+    Ntgtbase -= 4;
+  }
+
+  for (i = 0; i < table[0].Nregions; i++) {
+    char *regbase = filebasename_ptr (table[0].region[i].name);
+    if (strncmp (regbase, tgtbase, Ntgtbase)) continue;
+
+    list[0].regions[0] = &table[0].region[i];
+    list[0].filename[0] = table[0].filename[i];
+    list[0].Nregions = 1;
+    return (list);
+  }
+  return NULL;
+}
 
 /* find region which overlaps c at given depth (-1 : populated ) */
Index: /branches/eam_branches/ipp-20121219/Ohana/src/uniphot/src/initialize_setposangle.c
===================================================================
--- /branches/eam_branches/ipp-20121219/Ohana/src/uniphot/src/initialize_setposangle.c	(revision 34871)
+++ /branches/eam_branches/ipp-20121219/Ohana/src/uniphot/src/initialize_setposangle.c	(revision 34872)
@@ -58,4 +58,28 @@
   // XXX for now, hardwire gpc1 photcodes
 
+  SINGLE_CPT = NULL;
+  if ((N = get_argument (argc, argv, "-cpt"))) {
+    remove_argument (N, &argc, argv);
+    SINGLE_CPT = strcreate (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  // region of interest
+  UserPatch.Rmin = 0;
+  UserPatch.Rmax = 360;
+  UserPatch.Dmin = -90;
+  UserPatch.Dmax = +90;
+  if ((N = get_argument (argc, argv, "-region"))) {
+    remove_argument (N, &argc, argv);
+    UserPatch.Rmin = atof (argv[N]);
+    remove_argument (N, &argc, argv);
+    UserPatch.Rmax = atof (argv[N]);
+    remove_argument (N, &argc, argv);
+    UserPatch.Dmin = atof (argv[N]);
+    remove_argument (N, &argc, argv);
+    UserPatch.Dmax = atof (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
   PARALLEL = FALSE;
   if ((N = get_argument (argc, argv, "-parallel"))) {
Index: /branches/eam_branches/ipp-20121219/Ohana/src/uniphot/src/update_dvo_setposangle.c
===================================================================
--- /branches/eam_branches/ipp-20121219/Ohana/src/uniphot/src/update_dvo_setposangle.c	(revision 34871)
+++ /branches/eam_branches/ipp-20121219/Ohana/src/uniphot/src/update_dvo_setposangle.c	(revision 34872)
@@ -36,9 +36,10 @@
 
   // determine the populated SkyRegions overlapping the requested area (default depth)
-  UserPatch.Rmin = 0;
-  UserPatch.Rmax = 360;
-  UserPatch.Dmin = -90;
-  UserPatch.Dmax = +90;
-  skylist = SkyListByPatch (sky, -1, &UserPatch);
+  if (!SINGLE_CPT) {
+      skylist = SkyListByPatch (sky, -1, &UserPatch);
+  } else {
+      skylist = SkyListByCPT (sky, cptname);
+  }
+  myAssert (skylist, "ooops!");
 
   // update measurements for each populated catalog
@@ -113,5 +114,5 @@
 
     char command[1024];
-    snprintf (command, 1024, "setposangle_client -hostID %d -catdir %s -hostdir %s -images %s", 
+    snprintf (command, 1024, "setposangle_client -hostID %d -catdir %s -hostdir %s -images %s -region STUFF", 
 	      table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, imageFile);
 
