Index: /branches/eam_branch_20071015/Ohana/src/absphot/Makefile
===================================================================
--- /branches/eam_branch_20071015/Ohana/src/absphot/Makefile	(revision 15425)
+++ /branches/eam_branch_20071015/Ohana/src/absphot/Makefile	(revision 15426)
@@ -21,27 +21,17 @@
 
 ABSPHOT = \
+$(SRC)/absphot.$(ARCH).o	 \
+$(SRC)/initialize.$(ARCH).o	 \
 $(SRC)/ConfigInit.$(ARCH).o	 \
-$(SRC)/GridOps.$(ARCH).o	 \
-$(SRC)/ImageOps.$(ARCH).o	 \
-$(SRC)/MosaicOps.$(ARCH).o	 \
-$(SRC)/SetSignals.$(ARCH).o 	 \
-$(SRC)/Shutdown.$(ARCH).o 	 \
-$(SRC)/StarOps.$(ARCH).o	 \
 $(SRC)/args.$(ARCH).o		 \
-$(SRC)/bcatalog.$(ARCH).o	 \
-$(SRC)/global_stats.$(ARCH).o	 \
-$(SRC)/initialize.$(ARCH).o	 \
+$(SRC)/find_regions.$(ARCH).o	 \
+$(SRC)/load_catalogs.$(ARCH).o	 \
+$(SRC)/subset_catalog.$(ARCH).o	 \
+$(SRC)/fit_trend.$(ARCH).o	 \
 $(SRC)/liststats.$(ARCH).o	 \
-$(SRC)/load_catalogs.$(ARCH).o	 \
-$(SRC)/load_images.$(ARCH).o	 \
-$(SRC)/plot_scatter.$(ARCH).o	 \
-$(SRC)/plotstuff.$(ARCH).o	 \
-$(SRC)/reload_catalogs.$(ARCH).o \
-$(SRC)/absphot.$(ARCH).o	 \
-$(SRC)/select_images.$(ARCH).o	 \
-$(SRC)/setExclusions.$(ARCH).o 	 \
-$(SRC)/setMrelFinal.$(ARCH).o 	 \
-$(SRC)/sort.$(ARCH).o		 \
-$(SRC)/write_coords.$(ARCH).o
+$(SRC)/sort.$(ARCH).o	 	 \
+$(SRC)/plotstuff.$(ARCH).o
+
+# $(SRC)/plot_residuals.$(ARCH).o	 \
 
 $(ABSPHOT): $(INC)/absphot.h
Index: /branches/eam_branch_20071015/Ohana/src/absphot/include/absphot.h
===================================================================
--- /branches/eam_branch_20071015/Ohana/src/absphot/include/absphot.h	(revision 15425)
+++ /branches/eam_branch_20071015/Ohana/src/absphot/include/absphot.h	(revision 15426)
@@ -3,27 +3,4 @@
 # include <kapa.h>
 # include <signal.h>
-
-/* # define GRID_V1 */
-# define GRID_V2
-# define NO_IMAGE -100
-
-# if (0)
-typedef struct {
-  double xmin, xmax, ymin, ymax;
-  int style, ptype, ltype, etype, color;
-  double lweight, size;
-} Graphdata;
-# endif
-
-typedef struct {
-  unsigned int start;
-  unsigned int stop;
-  float Mcal;
-  float dMcal;
-  short Xm;
-  float secz;
-  char code;
-  Coords coords;
-} Mosaic; 
 
 typedef struct {
@@ -41,45 +18,21 @@
 /* global variables set in parameter file */
 char   ImageCat[256];
-char   ImageTemplate[256];
-char   CatTemplate[256];
 char   GSCFILE[256];
 char   CATDIR[256];
 char   CATMODE[16];    /* raw, mef, split, mysql */
 char   CATFORMAT[16];  /* internal, elixir, loneos, panstarrs */
-char   CameraConfig[256];
+
 char   SKY_TABLE[256];
 int    SKY_DEPTH;  /** XXX EAM : depth of catalog tables, fix usage */
 
-double MAG_LIM;
-double SIGMA_LIM;
-double IMAGE_SCATTER;
-double IMAGE_OFFSET;
-double STAR_SCATTER;
-double STAR_CHISQ;
-double MIN_ERROR;
-
 int    VERBOSE;
 
-int    NLOOP;
-int    RESET;
 int    UPDATE;
 int    PLOTSTUFF;
 int    SAVEPLOT;
-int    SHOW_PARAMS;
-char   MOSAICNAME[256];
-char   STATMODE[32];
-int    STAR_BAD;
-int    MEAS_BAD;
-int    STAR_TOOFEW;
-int    IMAGE_TOOFEW;
-double IMAGE_GOOD_FRACTION;
-int    IMAGE_BAD;
-int    FREEZE_IMAGES;
-int    USE_GRID;
 int    PLOTDELAY;
 
-int    RELPHOT_GRID_X;
-int    RELPHOT_GRID_Y;
-int    RELPHOT_GRID_BINNING;
+int    SHOW_PARAMS;
+char   STATMODE[32];
 
 PhotCode      *photcode;
@@ -87,126 +40,20 @@
 int            PhotSec;
 
-int AreaSelect;
-double AreaXmin, AreaXmax, AreaYmin, AreaYmax;
-
-int ImagSelect, ImagMin, ImagMax;
-
-int DophotSelect, DophotValue;
-
 double  PlotMmin, PlotMmax, PlotdMmin, PlotdMmax;
-enum {black, white, red, orange, yellow, green, blue, indigo, violet};
-
-int TimeSelect;
-time_t TSTART, TSTOP;
 
 SkyRegion UserPatch;
-int UserPatchSelect;
 
-# ifdef GRID_V1
-int setGridMeasure (int meas, int cat, double X, double Y);
-# endif
-
-# ifdef GRID_V2
-int setGridMeasure (int meas, int cat, double X, double Y, int ccdnum);
-# endif
-
-/*** relphot prototypes ***/
+/*** absphot prototypes ***/
+int           main                PROTO((int argc, char **argv));
+void          initialize          PROTO((int argc, char **argv));
+int           args                PROTO((int argc, char **argv));
 void          ConfigInit          PROTO((int *argc, char **argv));
 void          GetConfig           PROTO((char *config, char *field, char *format, int N, void *ptr));
-char         *GetPhotnamebyCode   PROTO((PhotCodeData *photcodes, int code));
-void          InterpolateGrid     PROTO((float *buffer, int Nx, int Ny, Coords *ccd, Coords *gcoords));
-int          *SelectRefMosaic     PROTO((Mosaic **refmosaic, int *Nimage));
-int           args                PROTO((int argc, char **argv));
-int           bcatalog            PROTO((Catalog *subcatalog, Catalog *catalog));
-void          clean_images        PROTO(());
-void          clean_measures      PROTO((Catalog *catalog, int Ncatalog, int final));
-void          clean_mosaics       PROTO(());
-void          clean_stars         PROTO((Catalog *catalog, int Ncatalog));
-int           corner_check        PROTO((double *x1, double *y1, double *x2, double *y2));
-void          dumpGrid            PROTO(());
-void          dump_grid           PROTO(()); 
-int           edge_check          PROTO((double *x1, double *y1, double *x2, double *y2));
-void          findImages          PROTO((Catalog *catalog, int Ncatalog));
-int           findMosaics         PROTO((Catalog *catalog, int Ncatalog));
+Catalog      *load_catalogs       PROTO((SkyList *skylist));
+int           subset_catalog      PROTO((Catalog *subcatalog, Catalog *catalog));
+void          free_catalogs       PROTO((Catalog *catalog, int Ncatalog));
 
-void set_db (FITS_DB *in);
-int Shutdown (char *format, ...);
-void TrapSignal (int sig);
-void SetProtect (int mode);
-int SetSignals ();
-
-void          freeGridBins        PROTO((int Ncatalog));
-void          freeImageBins       PROTO((int Ncatalog));
-void          freeMosaicBins      PROTO((int Ncatalog));
-void          free_catalogs       PROTO((Catalog *catalog, int Ncatalog));
-int           gcatalog            PROTO((Catalog *catalog, int FINAL));
-Coords       *getCoords           PROTO((int meas, int cat));
-float         getMcal             PROTO((int meas, int cat));
-float         getMgrid            PROTO((int meas, int cat));
-float         getMmos             PROTO((int meas, int cat));
-float         getMrel             PROTO((Catalog *catalog, int meas, int cat));
-Image        *getimage            PROTO((int N));
-Image        *getimages           PROTO((int *N));
-void          global_stats        PROTO((Catalog *catalog, int Ncatalog));
-void          initGrid            PROTO((int dX, int dY));
-void          initGridBins        PROTO((Catalog *catalog, int Ncatalog));
-void          initImageBins       PROTO((Catalog *catalog, int Ncatalog));
-void          initImages          PROTO((Image *input, int N));
-void          initMosaicBins      PROTO((Catalog *catalog, int Ncatalog));
-void          initMosaicGrid      PROTO((Image *image, int Nimage));
-void          initMosaics         PROTO((Image *image, int Nimage));
-void          initMrel            PROTO((Catalog *catalog, int Ncatalog));
-void          initialize          PROTO((int argc, char **argv));
 void          initstats           PROTO((char *mode));
 int           liststats           PROTO((double *value, double *dvalue, int N, StatType *stats));
-Catalog       *load_catalogs      PROTO((SkyList *skylist, int *Ncatalog));
-SkyList      *load_images         PROTO((FITS_DB *db, char *regionName, SkyRegion *region, int RegionSelect));
-Image         *select_images      PROTO((SkyList *skylist, Image *timage, int Ntimage, int **LineNumber, int *Nimage));
 
-int           main                PROTO((int argc, char **argv));
-void          mark_images         PROTO((Image *image, int Nimage, Image *timage, int Ntimage));
-void          matchImage          PROTO((Catalog *catalog, int meas, int cat));
-void          matchMosaics        PROTO((Catalog *catalog, int meas, int cat));
-double        opening_angle       PROTO((double x1, double y1, double x2, double y2, double x3, double y3));
-void          plot_chisq          PROTO((Catalog *catalog, int Ncatalog));
-void          plot_defaults       PROTO((Graphdata *graphdata));
-void          plot_grid           PROTO((Catalog *catalog));
-void          plot_images         PROTO(());
-void          plot_list           PROTO((Graphdata *graphdata, double *xlist, double *ylist, int N, char *label, char *file));
-void          plot_mosaic_fields  PROTO((Catalog *catalog));
-void          plot_mosaics        PROTO(());
-void          plot_scatter        PROTO((Catalog *catalog, int Ncatalog));
-void          plot_star_coords    PROTO((Catalog *catalog, int Ncatalog));
-void          plot_stars          PROTO((Catalog *catalog, int Ncatalog));
-void          reload_catalogs     PROTO((SkyList *skylist));
-int           reload_images       PROTO((FITS_DB *db));
-int           setExclusions       PROTO((Catalog *catalog, int Ncatalog));
-void          setMcal             PROTO((Catalog *catalog, int Poor));
-void          setMcalFinal        PROTO(());
-int           setMcalOutput       PROTO((Catalog *catalog, int Ncatalog));
-void          setMgrid            PROTO((Catalog *catalog));
-int           setMmos             PROTO((Catalog *catalog, int Poor));
-int           setMrel             PROTO((Catalog *catalog, int Ncatalog));
-void          setMrelFinal        PROTO((Catalog *catalog));
-int           setMrelOutput       PROTO((Catalog *catalog, int Ncatalog, int mark));
-void          set_ZP              PROTO((double ZERO));
-int           setrefcode          PROTO((Image *image, int Nimage)); 
-void          skip_measurements   PROTO((Catalog *catalog, int pass));
-void          sortA               PROTO((double *X, int N));
-void          sortB               PROTO((double *X, double *Y, int N));
-void          sortC               PROTO((double *X, double *Y, double *F1, double *F2, int N));
-void          sortD               PROTO((double *X, double *Y, double *Z, int N));
-StatType      statsImageM         PROTO((Catalog *catalog));
-StatType      statsImageN         PROTO((Catalog *catalog));
-StatType      statsImageX         PROTO((Catalog *catalog));
-StatType      statsImagedM        PROTO((Catalog *catalog));
-StatType      statsMosaicM        PROTO((Catalog *catalog));
-StatType      statsMosaicN        PROTO((Catalog *catalog));
-StatType      statsMosaicX        PROTO((Catalog *catalog));
-StatType      statsMosaicdM       PROTO((Catalog *catalog));
-StatType      statsStarN          PROTO((Catalog *catalog, int Ncatalog));
-StatType      statsStarS          PROTO((Catalog *catalog, int Ncatalog));
-StatType      statsStarX          PROTO((Catalog *catalog, int Ncatalog));
-void          wcatalog            PROTO((Catalog *catalog));
-void          wimages             PROTO(());
-void          write_coords        PROTO((Header *header, Coords *coords));
+SkyList      *find_regions        PROTO((FITS_DB *db, SkyRegion *region));
Index: /branches/eam_branch_20071015/Ohana/src/absphot/src/ConfigInit.c
===================================================================
--- /branches/eam_branch_20071015/Ohana/src/absphot/src/ConfigInit.c	(revision 15425)
+++ /branches/eam_branch_20071015/Ohana/src/absphot/src/ConfigInit.c	(revision 15426)
@@ -1,4 +1,3 @@
 # include "absphot.h"
-
 void ConfigInit (int *argc, char **argv) {
 
@@ -18,17 +17,6 @@
   if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file);
 
-  GetConfig (config, "MAG_LIM",                "%lf", 0, &MAG_LIM);
-  GetConfig (config, "SIGMA_LIM",              "%lf", 0, &SIGMA_LIM);
-  GetConfig (config, "STAR_SCATTER",           "%lf", 0, &STAR_SCATTER);
-  GetConfig (config, "IMAGE_SCATTER",          "%lf", 0, &IMAGE_SCATTER);
-  GetConfig (config, "IMAGE_OFFSET",           "%lf", 0, &IMAGE_OFFSET);
-
-  GetConfig (config, "STAR_CHISQ",             "%lf", 0, &STAR_CHISQ);
-  GetConfig (config, "STAR_TOOFEW",            "%d",  0, &STAR_TOOFEW);
-  GetConfig (config, "IMAGE_TOOFEW",           "%d",  0, &IMAGE_TOOFEW);
-  GetConfig (config, "IMAGE_GOOD_FRACTION",    "%lf", 0, &IMAGE_GOOD_FRACTION);
-
-  GetConfig (config, "GSCFILE",                "%s",  0, GSCFILE);
-  GetConfig (config, "CATDIR",                 "%s",  0, CATDIR);
+  GetConfig (config, "GSCFILE",                 "%s",  0, GSCFILE);
+  GetConfig (config, "CATDIR",                  "%s",  0, CATDIR);
   ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
   ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
@@ -46,13 +34,10 @@
   GetConfig (config, "ZERO_PT",                "%lf", 0, &ZERO_POINT);
 
-  GetConfig (config, "RELPHOT_GRID_X",         "%d",  0, &RELPHOT_GRID_X);
-  GetConfig (config, "RELPHOT_GRID_Y",         "%d",  0, &RELPHOT_GRID_Y);
-  GetConfig (config, "RELPHOT_GRID_BINNING",   "%d",  0, &RELPHOT_GRID_BINNING);
-  GetConfig (config, "CAMERA_CONFIG",          "%s",  0, CameraConfig);
-
+  // XXX these are used to set the default values if we are opening a new catalog,
+  // but this program requires the existence of a catalog (with observations and references)
   if (*CATMODE == 0) strcpy (CATMODE, "RAW");
   if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
 
-  /* XXX this does not yet write out the master photcode table */
+  // XXX this does not yet write out the master photcode table 
   sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
Index: /branches/eam_branch_20071015/Ohana/src/absphot/src/absphot.c
===================================================================
--- /branches/eam_branch_20071015/Ohana/src/absphot/src/absphot.c	(revision 15425)
+++ /branches/eam_branch_20071015/Ohana/src/absphot/src/absphot.c	(revision 15426)
@@ -9,25 +9,32 @@
   SkyList *skylist = NULL;
 
-  /* get configuration info, args */
+  // get configuration info, interpret args
   initialize (argc, argv);
 
-  /* lock and load the photcode table */
-  if (UPDATE) dvo_photcode_lock (); 
+  // lock and load the photcode table
+  // XXX need to define this
+  // if (UPDATE) dvo_photcode_lock (); 
 
-  /* load catalog data from region files */
+  // restrict to user-specified region
+  skylist = find_regions (&db, &UserPatch);
+
+  // load catalog data from selected regions
   catalog = load_catalogs (skylist);
   
-  /* add in a loop over the catalogs calling dvo_catalog_chipcoords */
-  fit_trend (catalog);
+  // fit the trend of the obs - ref vs color...
+  // XXX define this
+  // fit_trend (catalog);
 
   if (PLOTSTUFF) {
-    plot_residuals (catalog);
+    // XXX define this
+    // plot_residuals (catalog);
   }
 
   if (!UPDATE) exit (0);
 
-  /* load catalog data from region files, update Mrel include all data */
-  dvo_photcode_update ();
-  dvo_photcode_unlock (); 
+  // write out modifications to the photcode table (how do we record historical values?)
+  // XXX define these
+  // dvo_photcode_update ();
+  // dvo_photcode_unlock (); 
 
   exit (0);
Index: /branches/eam_branch_20071015/Ohana/src/absphot/src/args.c
===================================================================
--- /branches/eam_branch_20071015/Ohana/src/absphot/src/args.c	(revision 15425)
+++ /branches/eam_branch_20071015/Ohana/src/absphot/src/args.c	(revision 15426)
@@ -7,31 +7,4 @@
   double trange;
 
-  /* define time */
-  TimeSelect = FALSE;
-  if ((N = get_argument (argc, argv, "-time"))) {
-    remove_argument (N, &argc, argv);
-    if (!ohana_str_to_time (argv[N], &TSTART)) { 
-      fprintf (stderr, "ERROR: syntax error\n");
-      return (FALSE);
-    }
-    remove_argument (N, &argc, argv);
-    if (!ohana_str_to_dtime (argv[N], &trange)) { 
-      if (!ohana_str_to_time (argv[N], &TSTOP)) { 
-	fprintf (stderr, "ERROR: syntax error\n");
-	return (FALSE);
-      }
-    } else {
-      if (trange < 0) {
-	trange = fabs (trange);
-	TSTOP = TSTART;
-	TSTART -= trange;
-      } else {
-	TSTOP = TSTART + trange;
-      }
-    }
-    remove_argument (N, &argc, argv);
-    TimeSelect = TRUE;
-  }
-
   /* specify portion of the sky */
   UserPatch.Rmin = 0;
@@ -39,5 +12,4 @@
   UserPatch.Dmin = -90;
   UserPatch.Dmax = +90;
-  UserPatchSelect = FALSE;
   if ((N = get_argument (argc, argv, "-region"))) {
     remove_argument (N, &argc, argv);
@@ -50,5 +22,4 @@
     UserPatch.Dmax = atof (argv[N]);
     remove_argument (N, &argc, argv);
-    UserPatchSelect = TRUE;
   }
 
@@ -79,23 +50,4 @@
   }
 
-  NLOOP = 8;
-  if ((N = get_argument (argc, argv, "-n"))) {
-    remove_argument (N, &argc, argv);
-    NLOOP = atof (argv[N]);
-    remove_argument (N, &argc, argv);
-  }
-
-  RESET = FALSE;
-  if ((N = get_argument (argc, argv, "-reset"))) {
-    remove_argument (N, &argc, argv);
-    RESET = TRUE;
-  }
-
-  UPDATE = FALSE;
-  if ((N = get_argument (argc, argv, "-update"))) {
-    remove_argument (N, &argc, argv);
-    UPDATE = TRUE;
-  }
-
   SHOW_PARAMS = FALSE;
   if ((N = get_argument (argc, argv, "-params"))) {
@@ -105,5 +57,5 @@
 
   PlotMmin = 10.0; PlotMmax = 20.0; PlotdMmin = -1.0; PlotdMmax = 1.0;
-  if ((N = get_argument (argc, argv, "-plrange"))) {
+  if ((N = get_argument (argc, argv, "-plotrange"))) {
     remove_argument (N, &argc, argv);
     PlotMmin = atof (argv[N]);
@@ -117,70 +69,5 @@
   }
 
-  /* group images by mosaic, find Mmos */
-  MOSAICNAME[0] = 0;
-  if ((N = get_argument (argc, argv, "-mosaic"))) {
-    remove_argument (N, &argc, argv);
-    strcpy (MOSAICNAME, argv[N]);
-    remove_argument (N, &argc, argv);
-  }
-
-  FREEZE_IMAGES = FALSE;
-  if ((N = get_argument (argc, argv, "-imfreeze"))) {
-    remove_argument (N, &argc, argv);
-    FREEZE_IMAGES = TRUE;
-  }
-
-  USE_GRID = FALSE;
-  if ((N = get_argument (argc, argv, "-grid"))) {
-    remove_argument (N, &argc, argv);
-    USE_GRID = TRUE;
-    if (!MOSAICNAME[0]) {
-      fprintf (stderr, "-grid is only valid with -mosaic\n");
-      exit (2);
-    }
-  }
-
-  MIN_ERROR = 0.001;
-  if ((N = get_argument (argc, argv, "-minerror"))) {
-    remove_argument (N, &argc, argv);
-    MIN_ERROR = atof (argv[N]);
-    remove_argument (N, &argc, argv);
-    /* require MIN_ERROR > 0 */
-  }  
-
-  AreaSelect = FALSE;
-  if ((N = get_argument (argc, argv, "-area"))) {
-    remove_argument (N, &argc, argv);
-    AreaXmin = atof (argv[N]);
-    remove_argument (N, &argc, argv);
-    AreaXmax = atof (argv[N]);
-    remove_argument (N, &argc, argv);
-    AreaYmin = atof (argv[N]);
-    remove_argument (N, &argc, argv);
-    AreaYmax = atof (argv[N]);
-    remove_argument (N, &argc, argv);
-    AreaSelect = TRUE;
-  }
-
-  ImagSelect = FALSE;
-  if ((N = get_argument (argc, argv, "-instmag"))) {
-    remove_argument (N, &argc, argv);
-    ImagMin = atof (argv[N]);
-    remove_argument (N, &argc, argv);
-    ImagMax = atof (argv[N]);
-    remove_argument (N, &argc, argv);
-    ImagSelect = TRUE;
-  }
-
-  DophotSelect = FALSE;
-  if ((N = get_argument (argc, argv, "-dophot"))) {
-    remove_argument (N, &argc, argv);
-    DophotValue = atof (argv[N]);
-    remove_argument (N, &argc, argv);
-    DophotSelect = TRUE;
-  }
-
-  if ( UserPatchSelect && (argc != 2)) usage ();
-  if (!UserPatchSelect && (argc != 3)) usage ();
+  if (argc != 2) usage ();
 
   return TRUE;
@@ -188,21 +75,12 @@
 
 void usage () {
-  fprintf (stderr, "ERROR: USAGE: absphot (region) (photcode)\n");
-  fprintf (stderr, "       or:    absphot (photcode) -region RA RA DEC DEC\n");
+  fprintf (stderr, "ERROR: USAGE: absphot (photcode) -region RA RA DEC DEC\n");
   fprintf (stderr, "  options: \n");
-  fprintf (stderr, "  -time (start) (stop)\n");
   fprintf (stderr, "  -v\n");
   fprintf (stderr, "  -plot\n");
   fprintf (stderr, "  -plotdelay (seconds)\n");
   fprintf (stderr, "  -statmode (mode)\n");
-  fprintf (stderr, "  -n (nloop)\n");
-  fprintf (stderr, "  -reset\n");
-  fprintf (stderr, "  -update\n");
   fprintf (stderr, "  -params\n");
-  fprintf (stderr, "  -mosaic (mosaic)\n");
-  fprintf (stderr, "  -imfreeze\n");
-  fprintf (stderr, "  -grid\n");
-  fprintf (stderr, "  -area Xmin Xmax Ymin Ymax\n");
-  fprintf (stderr, "  -instmag min max\n");
+  fprintf (stderr, "  -plotrange Mmin Mmax dMmin dMmax\n");
   fprintf (stderr, "  \n");
   exit (2);
Index: /branches/eam_branch_20071015/Ohana/src/absphot/src/find_regions.c
===================================================================
--- /branches/eam_branch_20071015/Ohana/src/absphot/src/find_regions.c	(revision 15426)
+++ /branches/eam_branch_20071015/Ohana/src/absphot/src/find_regions.c	(revision 15426)
@@ -0,0 +1,20 @@
+# include "absphot.h"
+
+SkyList *find_regions (FITS_DB *db, SkyRegion *region) {
+
+  Image     *image, *subset;
+  int        Nimage, Nsubset, Nchar;
+  int       *LineNumber;
+
+  SkyTable *sky = NULL;
+  SkyList *skylist = NULL;
+
+  // load the current sky table (layout of all SkyRegions) 
+  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
+  SkyTableSetFilenames (sky, CATDIR, "cpt");
+  
+  // determine the populated SkyRegions overlapping the requested area
+  skylist = SkyListByPatch (sky, -1, region);
+
+  return (skylist);
+}
Index: /branches/eam_branch_20071015/Ohana/src/absphot/src/fit_trend.c
===================================================================
--- /branches/eam_branch_20071015/Ohana/src/absphot/src/fit_trend.c	(revision 15425)
+++ /branches/eam_branch_20071015/Ohana/src/absphot/src/fit_trend.c	(revision 15426)
@@ -1,5 +1,13 @@
-# include "absphot.c"
+# include "absphot.h"
 
 int fit_trend (Catalog *catalog) {
+
+  // XXX define this : obs - ref vs color(obs)
+  // target is the ref photcode (derived from obs photcode table entry)
+  PhotCode *target; 
+
+  int i, Nc0, Nc1, Nc2;
+  float *x, *y, *dy;
+  float c0, m0, dc0, dm0, c1, c2;
 
   ALLOCATE (x, float, catalog[0].Naverage);
@@ -9,7 +17,7 @@
   // XXX I must have code that does this in another program
   // XXX perhaps relphot for the grid colors?
-  Nc0 = getNsecphot (target.c0);
-  Nc1 = getNsecphot (target.c1);
-  Nc2 = getNsecphot (target.c2);
+  Nc0 = GetPhotcodeNsec (target->code);
+  Nc1 = GetPhotcodeNsec (target->c1);
+  Nc2 = GetPhotcodeNsec (target->c2);
 
   if (catalog[0].Naverage != catalog[0].Nmeasure) abort();
@@ -18,12 +26,12 @@
 
     // XXX I probably need to apply some corrections?
-    c0 = catalog[0].secfilt[i*Nsecfilt + Nc0].mag;
-    m0 = catalog[0].measure[i].mag;
+    c0 = catalog[0].secfilt[i*PhotNsec + Nc0].M;
+    m0 = catalog[0].measure[i].M;
 
-    dc0 = catalog[0].secfilt[i*Nsecfilt + Nc0].dmag;
-    dm0 = catalog[0].measure[i].dmag;
+    dc0 = catalog[0].secfilt[i*PhotNsec + Nc0].dM;
+    dm0 = catalog[0].measure[i].dM;
 
-    c1 = catalog[0].secfilt[i*Nsecfilt + Nc1].mag;
-    c2 = catalog[0].secfilt[i*Nsecfilt + Nc2].mag;
+    c1 = catalog[0].secfilt[i*PhotNsec + Nc1].M;
+    c2 = catalog[0].secfilt[i*PhotNsec + Nc2].M;
 
     x[i] = c1 - c2;
@@ -33,5 +41,11 @@
   }
 
-  fit_vectors (x, y, dy);
+  // XXX define this
+  // fit_vectors (x, y, dy);
+  // do something with the result!
+
+  free (x);
+  free (y);
+  free (dy);
 
 }
Index: /branches/eam_branch_20071015/Ohana/src/absphot/src/initialize.c
===================================================================
--- /branches/eam_branch_20071015/Ohana/src/absphot/src/initialize.c	(revision 15425)
+++ /branches/eam_branch_20071015/Ohana/src/absphot/src/initialize.c	(revision 15426)
@@ -8,11 +8,11 @@
   args (argc, argv);
 
-  N = UserPatchSelect ? 1 : 2;
-  if ((photcode = GetPhotcodebyName (argv[N])) == NULL) {
-    fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", argv[N]);
+  // XXX what type of photcodes are allowed / required?
+  if ((photcode = GetPhotcodebyName (argv[1])) == NULL) {
+    fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", argv[1]);
     exit (1);
   }
   if (photcode[0].type != PHOT_SEC) {
-    fprintf (stderr, "photcode %s is not a primary or secondary filter\n", argv[N]);
+    fprintf (stderr, "photcode %s is not a primary or secondary filter\n", argv[1]);
     exit (1);
   }
@@ -23,26 +23,8 @@
   initstats (STATMODE);
 
-  IMAGE_BAD = ID_IMAGE_POOR | ID_IMAGE_FEW | ID_IMAGE_SKIP;
-  STAR_BAD  = ID_STAR_POOR | ID_STAR_FEW;
-  MEAS_BAD  = ID_MEAS_NOCAL | ID_MEAS_POOR | ID_MEAS_SKIP | ID_MEAS_AREA;
-
   if (SHOW_PARAMS) {
     fprintf (stderr, "current parameter settings:\n");
-    if (TimeSelect) {
-      fprintf (stderr, "TimeSelect: TRUE (%s - %s)\n", ohana_sec_to_date (TSTART), ohana_sec_to_date (TSTOP));
-    } else {
-      fprintf (stderr, "TimeSelect: FALSE\n");
-    }
     fprintf (stderr, "VERBOSE: %d, PLOTSTUFF: %d\n", VERBOSE, PLOTSTUFF);
-    fprintf (stderr, "GRID_X: %d, GRID_Y: %d, BINNING: %d == Nmx: %d, Nmy: %d\n", 
-	     RELPHOT_GRID_X, 
-	     RELPHOT_GRID_Y, 
-	     RELPHOT_GRID_BINNING, 
-	     (int)(RELPHOT_GRID_X/RELPHOT_GRID_BINNING), (int)(RELPHOT_GRID_Y/RELPHOT_GRID_BINNING));
 
-    fprintf (stderr, "MAG_LIM                %lf\n", MAG_LIM);
-    fprintf (stderr, "STAR_SCATTER           %lf\n", STAR_SCATTER);
-    fprintf (stderr, "IMAGE_SCATTER          %lf\n", IMAGE_SCATTER);
-    fprintf (stderr, "IMAGE_OFFSET           %lf\n", IMAGE_OFFSET);
     fprintf (stderr, "IMAGE_CATALOG          %s\n",  ImageCat);
     fprintf (stderr, "GSCFILE                %s\n",  GSCFILE);
Index: /branches/eam_branch_20071015/Ohana/src/absphot/src/plotstuff.c
===================================================================
--- /branches/eam_branch_20071015/Ohana/src/absphot/src/plotstuff.c	(revision 15425)
+++ /branches/eam_branch_20071015/Ohana/src/absphot/src/plotstuff.c	(revision 15426)
@@ -138,5 +138,5 @@
   graphdata[0].ltype = 0;
   graphdata[0].etype = 0;
-  graphdata[0].color = black;
+  graphdata[0].color = 0;
   graphdata[0].lweight = 0;
   graphdata[0].size = 0.5;
Index: /branches/eam_branch_20071015/Ohana/src/absphot/src/subset_catalog.c
===================================================================
--- /branches/eam_branch_20071015/Ohana/src/absphot/src/subset_catalog.c	(revision 15425)
+++ /branches/eam_branch_20071015/Ohana/src/absphot/src/subset_catalog.c	(revision 15426)
@@ -3,5 +3,9 @@
 int subset_catalog (Catalog *subcatalog, Catalog *catalog) {
   
-  int i, j, offset, ecode;
+  // XXX define this : obs - ref vs color(obs)
+  // target is the ref photcode (derived from obs photcode table entry)
+  PhotCode *target; 
+
+  int i, j, offset, averef, ecode;
   int NAVERAGE, NMEASURE, Naverage, Nmeasure, Nm;
   float mag;
@@ -30,21 +34,21 @@
 
     // find desired target photcode measurements
-    if (catalog[0].measure[i].photcode != target.photcode) continue;
+    if (catalog[0].measure[i].photcode != target[0].code) continue;
 
     // some possible exclusions based on the target measurements
-    mag = PhotCat (&catalog[0].measure[i]);
-    if (mag > MAG_LIM) continue;
+    // mag = PhotCat (&catalog[0].measure[i]);
+    // if (mag > MAG_LIM) continue;
 
     /* select measurements by measurement error */
-    if ((SIGMA_LIM > 0) && (catalog[0].measure[i].dM > SIGMA_LIM)) continue;
+    // if ((SIGMA_LIM > 0) && (catalog[0].measure[i].dM > SIGMA_LIM)) continue;
 
-    ave = catalog[0].measure[i].averef;
+    averef = catalog[0].measure[i].averef;
 
     // copy the average and secfilt data for this average object
     // XXX potentially skip this source on some basis here
-    subcatalog[0].average[Naverage] = catalog[0].average[ave];
+    subcatalog[0].average[Naverage] = catalog[0].average[averef];
     subcatalog[0].average[Naverage].offset = Nmeasure;
     for (j = 0; j < PhotNsec; j++) {
-      subcatalog[0].secfilt[PhotNsec*Naverage+j] = catalog[0].secfilt[PhotNsec*ave+j];
+      subcatalog[0].secfilt[PhotNsec*Naverage+j] = catalog[0].secfilt[PhotNsec*averef+j];
     }
 
