Index: /branches/eam_branches/ipp-20120905/Ohana/src/delstar/include/delstar.h
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/delstar/include/delstar.h	(revision 34689)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/delstar/include/delstar.h	(revision 34690)
@@ -12,9 +12,11 @@
 
 /* global variables set in parameter file */
-char   ImageCat[256];
-char   ImageTemplate[256];
-char   CatTemplate[256];
-char   GSCFILE[256];
-char   CATDIR[256];
+char   ImageCat[DVO_MAX_PATH];
+char   ImageTemplate[DVO_MAX_PATH];
+char   CatTemplate[DVO_MAX_PATH];
+char   GSCFILE[DVO_MAX_PATH];
+
+char  *CATDIR;
+
 char   CATMODE[16];    /* raw, mef, split, mysql */
 char   CATFORMAT[16];  /* internal, elixir, loneos, panstarrs */
@@ -27,5 +29,5 @@
 int    ORPHAN;
 int    MISSED;
-char   SKY_TABLE[256];
+char   SKY_TABLE[DVO_MAX_PATH];
 int    SKY_DEPTH;  /** XXX EAM : depth of catalog tables, fix usage */
 
Index: /branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/ConfigInit.c
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/ConfigInit.c	(revision 34689)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/ConfigInit.c	(revision 34690)
@@ -5,5 +5,4 @@
   char *config, *file;
   char CatdirPhotcodeFile[256];
-  char MasterPhotcodeFile[256];
 
   /*** load configuration info ***/
@@ -20,10 +19,15 @@
   ScanConfig (config, "ALPHA",                  "%lf", 0, &ALPHA);
   ScanConfig (config, "GSCFILE",                "%s", 0, GSCFILE);
-  ScanConfig (config, "CATDIR",                 "%s", 0, CATDIR);
   ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
   ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
-  ScanConfig (config, "PHOTCODE_FILE",         	"%s",  0, MasterPhotcodeFile);
 
-  sprintf (ImageCat, "%s/Images.dat", CATDIR);
+  // force CATDIR to be absolute (so parallel mode will work)
+  char *tmpcatdir = NULL;
+  ALLOCATE (tmpcatdir, char, DVO_MAX_PATH);
+  ScanConfig (config, "CATDIR",                 "%s",  0, tmpcatdir);
+  CATDIR = abspath (tmpcatdir, DVO_MAX_PATH);
+  free (tmpcatdir);
+
+  snprintf (ImageCat, DVO_MAX_PATH, "%s/Images.dat", CATDIR);
 
   ScanConfig (config, "DATE-KEYWORD",           "%s", 0, DateKeyword);
@@ -45,6 +49,6 @@
   /* XXX this does not yet write out the master photcode table */
   sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
-  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
-    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
+  if (!LoadPhotcodes (CatdirPhotcodeFile, NULL, FALSE)) {
+    fprintf (stderr, "error loading photcode table %s\n", CatdirPhotcodeFile);
     exit (1);
   }
Index: /branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/args.c
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/args.c	(revision 34689)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/args.c	(revision 34690)
@@ -156,5 +156,5 @@
 goodtime:
 
-  /* restrict to a single photcode (not compatible with -image) */
+  /* restrict to a single photcode (not compatible with -image) 
   PHOTCODE = NULL;
   if ((N = get_argument (argc, argv, "-photcode"))) {
@@ -162,5 +162,5 @@
     PHOTCODE = GetPhotcodebyName (argv[N]);
     remove_argument (N, &argc, argv);
-  }
+  }*/
 
   if (argc != 1) usage ();
Index: /branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/delete_photcodes.c
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/delete_photcodes.c	(revision 34689)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/delete_photcodes.c	(revision 34690)
@@ -1,32 +1,3 @@
 # include "delstar.h"
-
-# if (0)
-void delete_photcodes (FITS_DB *db, photcodes, Nphotcodes) {
-
-  int found, code;
-  off_t i, j, k, n;
-  off_t Nregions, NREGIONS;
-  off_t *imlist;
-  SkyList *skylist, *skyset;
-  SkyTable *sky;
-  Catalog catalog;
-
-  // xxx where does this go?
-  photcodesDrop = ParsePhotcodeList (PHOTCODE_LIST, &NphotcodesDrop, FALSE);
-
-  /* load sky from correct table */
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
-  SkyTableSetFilenames (sky, CATDIR, "cpt");
-
-  // determine the populated SkyRegions overlapping the requested area (default depth)
-  skylist = SkyListByPatch (sky, -1, &UserPatch);
-
-  // delete images with these photcodes
-  delete_photcodes_catalogs (db, photcodesDrop, NphotcodesDrop);
-
-  fprintf (stderr, "SUCCESS\n");
-  exit (0);
-}
-# endif
 
 int delete_photcodes (SkyList *skylist, int hostID, char *hostpath) {
@@ -73,5 +44,5 @@
 
     delete_photcodes_catalog (&catalog, photcodes, Nphotcodes);
-    dvo_catalog_save (&catalog, VERBOSE);
+    dvo_catalog_save_complete (&catalog, VERBOSE);
     dvo_catalog_unlock (&catalog);
     dvo_catalog_free (&catalog);
@@ -165,6 +136,9 @@
   Measure *measureOut = NULL;
   Average *averageOut = NULL;
+  SecFilt *secfiltOut = NULL;
 
   off_t *measureDrop, *measureSeqRaw, *measureSeqOut, *measureRefOut, *measureAveRaw, *averageNmeas, *averageDmeas, *averageSeqOut, *averageRefOut, *measureAveOut;
+
+  int Nsecfilt = GetPhotcodeNsecfilt ();
 
   /* internal counters */
@@ -174,4 +148,5 @@
   Measure *measure = catalog[0].measure;
   Average *average = catalog[0].average;
+  SecFilt *secfilt = catalog[0].secfilt;
   
   if (VERBOSE) fprintf (stderr, "starting with Nave, Nmeas: "OFF_T_FMT" "OFF_T_FMT"\n",  catalog[0].Naverage,  catalog[0].Nmeasure);
@@ -286,4 +261,13 @@
   }
 
+  // copy the secfilt entries for the (kept) average entries
+  ALLOCATE (secfiltOut, SecFilt, NaveOut*Nsecfilt);
+  for (i = 0; i < NaveOut; i++) {
+    j = averageSeqOut[i];
+    for (m = 0; m < Nsecfilt; m++) {
+      secfiltOut[i*Nsecfilt + m] = secfilt[j*Nsecfilt + m];
+    }
+  }
+
   // update the values of average.measureOffset and average.Nmeasure
   FREE(measure);
@@ -291,4 +275,7 @@
   catalog[0].measure = measureOut;
   catalog[0].average = averageOut;
+  catalog[0].secfilt = secfiltOut;
+  catalog[0].Nmeasure = NmeasOut;
+  catalog[0].Naverage = NaveOut;
 
   // update catalog.Nmeasure and catalog.Naverage, double check 
@@ -296,5 +283,5 @@
   int measureOffsetOK = TRUE;
   int averefOK = TRUE;
-  for (i = 0; i < Naverage; i++) {
+  for (i = 0; i < NaveOut; i++) {
     NmeasureTotal += catalog[0].average[i].Nmeasure;
     if (VERBOSE && !(NmeasureTotal <= catalog[0].Nmeasure)) {
@@ -333,4 +320,6 @@
 
   catalog[0].sorted = TRUE;
+
+  if (VERBOSE) fprintf (stderr, "ending with Nave, Nmeas: "OFF_T_FMT" "OFF_T_FMT"\n",  catalog[0].Naverage,  catalog[0].Nmeasure);
 
   FREE (measureDrop);
