Index: trunk/Ohana/src/delstar/include/delstar.h
===================================================================
--- trunk/Ohana/src/delstar/include/delstar.h	(revision 35416)
+++ trunk/Ohana/src/delstar/include/delstar.h	(revision 35758)
@@ -21,4 +21,27 @@
 } IndexArray;
 
+// to determine the image ID, we need time (tzero + trate) and photcode
+typedef struct {
+  unsigned int     imageID;
+  unsigned int     externID;
+  unsigned short   NX;                   // image width
+  unsigned short   NY;                   // image height
+  unsigned int     nstar;                // number of stars on the image
+  e_time           tzero;                // readout time (row 0)
+  e_time           tmin;                 // start exp - 1
+  e_time           tmax;                 // stop exp + 1
+  unsigned char    trate;                // scan rate (100 usec/pixel)
+  short            photcode;
+} ImageSubset;
+
+typedef struct {
+  double R;
+  double D;
+  int objID;
+  int catID;
+  int detID;
+  int imageID;
+} MeasureEdge;
+
 /* global variables set in parameter file */
 char   ImageCat[DVO_MAX_PATH];
@@ -33,4 +56,8 @@
 
 char  *IMAGENAME;
+char  *IMAGES;
+char  *IMSTATS_FILE;
+char  *MEASURE_EDGE_FILE;
+char  *EDGE_DELETIONS;
 
 double NSIGMA;
@@ -52,4 +79,5 @@
 int          HOST_ID;
 char        *HOSTDIR;
+char        *SINGLE_CPT;
 
 int SKIP_IMAGES;
@@ -60,7 +88,8 @@
 
 char *PHOTCODE_LIST;
+char *UNIQUER;
 
 int    MODE;
-enum {MODE_NONE, MODE_IMAGENAME, MODE_IMAGEFILE, MODE_TIME, MODE_ORPHAN, MODE_MISSED, MODE_PHOTCODES, MODE_DUP_IMAGES};
+enum {MODE_NONE, MODE_IMAGENAME, MODE_IMAGEFILE, MODE_TIME, MODE_ORPHAN, MODE_MISSED, MODE_PHOTCODES, MODE_DUP_IMAGES, MODE_DUP_MEASURES, MODE_FIX_LAP, MODE_FIX_LAP_STATS, MODE_FIX_LAP_EDGES, MODE_FIX_LAP_EDGES_DELETE};
 
 char DateKeyword[64], DateMode[64], UTKeyword[64], MJDKeyword[64], JDKeyword[64];
@@ -109,5 +138,5 @@
 void SortAveMeasMatch (off_t *MEAS, off_t *AVE, off_t N);
 
-int delete_photcodes (int hostID, char *hostpath);
+int delete_photcodes ();
 int delete_photcodes_parallel (SkyList *sky);
 int delete_photcodes_catalog (Catalog *catalog, PhotCode **photcodes, int Nphotcodes);
@@ -115,6 +144,6 @@
 int delete_photcodes_single (char *cptname);
 
-int delete_duplicate_images (int hostID, char *hostpath, FITS_DB *db);
-int delete_duplicate_image_measures (int hostID, char *hostpath, IndexArray *imageID);
+int delete_duplicate_images (FITS_DB *db);
+int delete_duplicate_image_measures (IndexArray *imageID);
 int delete_duplicate_image_measures_parallel (SkyList *sky, IndexArray *imageID);
 int delete_duplicate_image_measures_catalog (Catalog *catalog, IndexArray *imageID);
@@ -125,2 +154,43 @@
 IndexArray *ImageIDLoad(char *filename);
 int ImageIDSave(char *filename, IndexArray *imageID);
+
+int delete_duplicate_measures ();
+int delete_duplicate_measures_parallel (SkyList *sky);
+int delete_duplicate_measures_catalog (Catalog *catalog);
+
+int delete_fix_LAP (ImageSubset *image, off_t Nimage);
+int delete_fix_LAP_catalog (Catalog *catalog, ImageSubset *image, off_t Nimage);
+int delete_fix_LAP_measures (off_t *measureDrop, Catalog *catalog, ImageSubset *image, off_t Nimage);
+int delete_fix_LAP_parallel (SkyList *sky, ImageSubset *image, off_t Nimage);
+int delete_fix_LAP_setstats (ImageSubset *image, off_t Nimage);
+
+void initImageIndex (ImageSubset *image, off_t Nimage_init);
+int *getImageIndex (int *maxIndex);
+int FindIDexp (off_t *ID, off_t *Seq, e_time time, short photcode);
+int FindIDstk (off_t *ID, off_t *Seq, short *photcode, off_t extID);
+
+ImageSubset *ImageSubsetLoad(char *filename, off_t *nimage);
+int ImageSubsetSave(char *filename, ImageSubset *image, off_t Nimage);
+ImageSubset *ImagesToSubset (Image *image, off_t N);
+
+void sort_fullIDs (uint64_t *I, int *S, off_t N);
+
+int ImageValidSave(char *filename);
+int ImageValidLoad(char *filename);
+void SummaryImageStats (ImageSubset *image, off_t Nimage_comp);
+void SummaryImageStats_Full (Image *image, off_t Nimage_comp);
+void BumpInvalidImage (int Seq);
+void BumpValidImage (int Seq);
+
+MeasureEdge *delete_fix_LAP_edges (off_t *nmeasure_edge);
+MeasureEdge *delete_fix_LAP_edges_parallel (SkyList *sky, off_t *nmeasure_edge);
+MeasureEdge *delete_fix_LAP_edges_get_measures (Catalog *catalog, MeasureEdge *measure_edge, off_t *Nmeasure_edge_in, off_t *NMEASURE_EDGE_IN);
+int          delete_fix_LAP_edges_find_dups (MeasureEdge *measure_edge, off_t Nmeasure_edge);
+
+MeasureEdge *MeasureEdgeMerge (MeasureEdge *measure_edge_all, off_t *Nmeasure_edge_in, off_t *NMEASURE_EDGE_IN, MeasureEdge *measure_edge, off_t Nmeasure_edge);
+int MeasureEdgeSave(char *filename, MeasureEdge *measure_edge, off_t Nmeasure_edge);
+MeasureEdge *MeasureEdgeLoad(char *filename, off_t *Nmeasure_edge);
+
+int delete_fix_LAP_edges_delete ();
+int delete_fix_LAP_edges_drop_measures (Catalog *catalog, MeasureEdge *measure_edge, off_t Nmeasure_edge, int catIDcount);
+int delete_fix_LAP_edges_delete_parallel (SkyList *sky);
