Index: unk/Ohana/src/relphot/doc/notes.html
===================================================================
--- /trunk/Ohana/src/relphot/doc/notes.html	(revision 5142)
+++ 	(revision )
@@ -1,130 +1,0 @@
-
-<h2> relphot outline </h2>
-
-<ul>
-<li> load data
-     images: match photcode and time range, reset flags
-     measure: select subset matching restritions on:
-       photcode, time, dM, Minst, Mag, dophot == 1
-<li> iterate to find Mcal, image.flags:
-     
-
-
-
-
-
-
-<h2> relphot overview </h2>
-
-<p> relphot has two primary purposes:<br>
-<ul>
-<li> calculate <b>Mcal</b> for images / measures
-<li> calculate <b>Mrel</b> for stars
-</ul>
-
-<p> relphot can also be used to determine the mosaic grid used to generate
-photometrically corrected flats (-grid option).
-
-<h2> data exclusion </h2>
-
-<p> relphot uses only a subset of the photometry data to calculate
-Mcal and Mrel.  In the first stage, calculation of the Mcal values,
-relphot loads the photometry data from each relevant catalog and
-creates an internal subset catalog with the function
-<em>bcatalog</em>, excluding some of the irrelevant data.  In
-addition, it uses flags to mark some of the data as invalid for the
-processing.
-
-<b> bcatalog exclusions </b>
-<ul>
-<li> measure.photcode not equivalent to requested photcode
-<li> measure.dophot != 1
-<li> measure.Mcat > MAG_LIM
-<li> measure.dM > SIGMA_LIM
-<li> measure.Minst out of range (ImagMin - ImagMax) [optional]
-<li> measure.t out of range (TSTART, TSTOP)
-
-<b> flagged data </b>
-
-<b> flagged image data </b>
-
-images can be flagged by setting bits of <b>image.code</b>
-
-stars can be flagged by setting bits of <b>average.code</b>
-
-measures can be flagged by setting bits of <b>measure.flag</b>
-
-<b>image.code</b>
-
-ID_IMAGE_NOCAL : ignore, irrelevant
-ID_IMAGE_POOR  : image measured bad
-ID_IMAGE_SKIP  : externally known bad
-
-dMcal > VALUE       FLAG_IMAGE_SCATTER <em>clean_images</em>
-fabs(Mcal) > VALUE  FLAG_IMAGE_ZEROPT  <em>clean_images</em>
-
-dMcal > VALUE       FLAG_IMAGE_SCATTER <em>clean_mosaics</em>
-fabs(Mcal) > VALUE  FLAG_IMAGE_ZEROPT  <em>clean_mosaics</em>
-
-<em> mark_images </em> does not seem to do anything useful?
-
-<b>average.code</b>
-
-Ngood < MEAS_TOOFEW                     <em>setMrel</em>
-Ngood < MEAS_TOOFEW                     <em>clean_measures</em>
-ChiSq > STAR_CHISQ                      <em>clean_stars</em>
-dM    > STAR_SCATTER                    <em>clean_stars</em>
-
-average.code (STAR_BAD) is not saved by relphot: it is set by
-clean_stars, clean_measures, and setMrel, but not setMrelOutput.
-STAR_BAD should only be internal since it depends on the photcode, but
-is not associated with a specific photcode in the data.  Just in case,
-it is reset to 0 in setMrelFinal.
-
-<b>measure.flag</b>
-
-X,Y out of range                        <em>setExclusions</em>
-3 sigma clipping                        <em>clean_measures</em>
-
-<h2> setting Mrel final value </h2>
-
-setMrelFinal is used to set the final average.Mrel values.  We do this
-in 4 stages.  In each stage, we set the Mrel values for stars which
-have not already been set, based on the current exclusion settings.
-At successive stages, we relax the exclusions, allowing the more
-spurious objects to have a valid Mrel value to be set.  In this loop,
-we actually run setMrelOutput twice: once to get the approximate Mrel
-value, then we flag the outlier measurements with clean_measure,
-then we redetermine the Mrel values on this basis, and mark the stars
-for exclusion from the next iteration.  
-
-exclude on
- photcode       0 1 2 3
- time range     0 1 2 3
- MEAS_POOR      0 1 2 3
- MEAS_TOOFEW    0 1 2 3
- dophot == 10   0 1 2 
- inst mag       0 1 2 
- dophot != 1,2  0 1  
- ID_IMAGE_POOR  0 1
- ID_IMAGE_SKIP  0 1
- dophot != 1    0
- measure.dM     0 
-
-for all relphot runs, Mrel is re-calculated, and measures are marked
-at least if they are outliers in mag or ccd area.
-
-setMrel.output needs to do a few things differently from setMrel:
-<ul>
-<li> set measure.Mcal (skipped in setMrel.basic)
-<li> set average.Mrel if N < TOO_FEW (not STAR_BAD) (optional!)
-<li> use MAX (stats.error, stats.sigma) (optionally)
-<li> allow STAR_BAD?
-</ul>
-
-<h2> imphotset </h2>
-
-imphotset allows you to set certain phot.image table entries.  here
-are the options:
-
-imphotset [-photcode code] [-name foo] [-trange (start) (stop)] -flag and value
Index: /trunk/Ohana/src/relphot/src/GridOps.v2.c
===================================================================
--- /trunk/Ohana/src/relphot/src/GridOps.v2.c	(revision 5142)
+++ /trunk/Ohana/src/relphot/src/GridOps.v2.c	(revision 5143)
@@ -293,5 +293,5 @@
 void plot_grid (Catalog *catalog) {
 
-  int i, j, m, c, n, N;
+  int i, j, m, c, n, N, Narea;
   float Msys, Mrel, Mcal, Mmos;
   double *xlist, *Mlist, *dlist, *ylist;
@@ -309,4 +309,5 @@
   ALLOCATE (dlist, double, N);
 
+  Narea = 0;
   N = 0;
   for (i = 0; i < Ngrid; i++) {
@@ -316,5 +317,8 @@
       c = clist[i][j];
       
-      if (catalog[c].measure[m].flags & MEAS_BAD) continue;
+      if (catalog[c].measure[m].flags & MEAS_BAD) {
+	Narea ++;
+	continue;
+      }
       if ((Mcal  = getMcal  (m, c)) == NO_MAG) continue;
       if ((Mmos  = getMmos  (m, c)) == NO_MAG) continue;
@@ -331,4 +335,6 @@
     }
   }
+
+  fprintf (stderr, "skipped %d meas for area\n", Narea);
 
   plot_defaults (&graphdata);
Index: /trunk/Ohana/src/relphot/src/ImageOps.c
===================================================================
--- /trunk/Ohana/src/relphot/src/ImageOps.c	(revision 5142)
+++ /trunk/Ohana/src/relphot/src/ImageOps.c	(revision 5143)
@@ -313,8 +313,8 @@
 
   /**** dMcal histgram ****/
-  for (i = 0; i < NBIN; i++) xlist[i] = 0.0025*i;
+  for (i = 0; i < NBIN; i++) xlist[i] = 0.00025*i;
   bzero (Mlist, NBIN*sizeof(double));
   for (i = 0; i < Nimage; i++) {
-    bin = image[i].dMcal_PS / 0.0025;
+    bin = image[i].dMcal_PS / 0.00025;
     bin = MAX (0, MIN (NBIN - 1, bin));
     Mlist[bin] += 1.0;
Index: /trunk/Ohana/src/relphot/src/MosaicOps.c
===================================================================
--- /trunk/Ohana/src/relphot/src/MosaicOps.c	(revision 5142)
+++ /trunk/Ohana/src/relphot/src/MosaicOps.c	(revision 5143)
@@ -630,5 +630,7 @@
   plot_list (&graphdata, xlist, Mlist, Nmosaic, "airmass vs Mcal", "airmass.png");
   plot_defaults (&graphdata);
-  plot_list (&graphdata, Mlist, dlist, Nmosaic, "Mcal vs dMcal", NULL);
+  graphdata.size = 1.5;
+  graphdata.ptype = 7;
+  plot_list (&graphdata, Mlist, dlist, Nmosaic, "Mcal vs dMcal", "MdM.png");
 
 # define NBIN 200
@@ -637,8 +639,8 @@
 
   /**** dMcal histgram ****/
-  for (i = 0; i < NBIN; i++) xlist[i] = 0.0025*i;
+  for (i = 0; i < NBIN; i++) xlist[i] = 0.00005*i;
   bzero (Mlist, NBIN*sizeof(double));
   for (i = 0; i < Nmosaic; i++) {
-    bin = mosaic[i].dMcal / 0.0025;
+    bin = mosaic[i].dMcal / 0.00005;
     bin = MAX (0, MIN (NBIN - 1, bin));
     Mlist[bin] += 1.0;
Index: /trunk/Ohana/src/relphot/src/StarOps.c
===================================================================
--- /trunk/Ohana/src/relphot/src/StarOps.c	(revision 5142)
+++ /trunk/Ohana/src/relphot/src/StarOps.c	(revision 5143)
@@ -403,6 +403,7 @@
 StatType statsStarS (Catalog *catalog, int Ncatalog) {
 
-  int i, j, n, Ntot, dM;
+  int i, j, n, Ntot;
   double *list, *dlist;
+  float dM;
   StatType stats;
 
@@ -446,5 +447,5 @@
   ALLOCATE (Mlist, double, NBIN);
 
-  for (i = 0; i < NBIN; i++) xlist[i] = 0.0025*i;
+  for (i = 0; i < NBIN; i++) xlist[i] = 0.00025*i;
   bzero (Mlist, NBIN*sizeof(double));
   for (i = 0; i < Ncatalog; i++) {
@@ -452,5 +453,5 @@
       if (catalog[i].average[j].code & STAR_BAD) continue;  
       dMrel = PhotPrimary ? catalog[i].average[j].dM_PS : catalog[i].secfilt[PhotNsec*j+PhotSec].dM_PS;
-      bin = dMrel / 0.0025;
+      bin = dMrel / 0.00025;
       bin = MAX (0, MIN (NBIN-1, bin));
       Mlist[bin] += 1.0;
Index: /trunk/Ohana/src/relphot/src/args.c
===================================================================
--- /trunk/Ohana/src/relphot/src/args.c	(revision 5142)
+++ /trunk/Ohana/src/relphot/src/args.c	(revision 5143)
@@ -110,5 +110,5 @@
   }
 
-  MIN_ERROR = 1;
+  MIN_ERROR = 0.001;
   if ((N = get_argument (argc, argv, "-minerror"))) {
     remove_argument (N, &argc, argv);
Index: /trunk/Ohana/src/relphot/src/global_stats.c
===================================================================
--- /trunk/Ohana/src/relphot/src/global_stats.c	(revision 5142)
+++ /trunk/Ohana/src/relphot/src/global_stats.c	(revision 5143)
@@ -21,20 +21,20 @@
   msX = statsMosaicX (catalog);
 
-  fprintf (stderr, "STATS           median    mean   sigma     min      max  Nmeas\n");
-  fprintf (stderr, "meas / image:   %6.0f  %6.1f  %6.1f  %6.0f  %7.0f  %6d\n",   imN.median, imN.mean, imN.sigma, imN.min, imN.max, imN.Nmeas);
-  fprintf (stderr, "meas / mosaic:  %6.0f  %6.1f  %6.1f  %6.0f  %7.0f  %6d\n",   msN.median, msN.mean, msN.sigma, msN.min, msN.max, msN.Nmeas);
-  fprintf (stderr, "meas / star:    %6.0f  %6.1f  %6.1f  %6.0f  %7.0f  %6d\n",   stN.median, stN.mean, stN.sigma, stN.min, stN.max, stN.Nmeas);
+  fprintf (stderr, "STATS            median     mean    sigma      min      max   Nmeas\n");
+  fprintf (stderr, "meas / image:   %7.0f  %7.0f  %7.0f  %7.0f  %7.0f  %6d\n",   imN.median, imN.mean, imN.sigma, imN.min, imN.max, imN.Nmeas);
+  fprintf (stderr, "meas / mosaic:  %7.0f  %7.0f  %7.0f  %7.0f  %7.0f  %6d\n",   msN.median, msN.mean, msN.sigma, msN.min, msN.max, msN.Nmeas);
+  fprintf (stderr, "meas / star:    %7.0f  %7.1f  %7.1f  %7.0f  %7.0f  %6d\n",   stN.median, stN.mean, stN.sigma, stN.min, stN.max, stN.Nmeas);
 
-  fprintf (stderr, "chisq image:    %6.1f  %6.1f  %6.1f  %6.1f  %7.1f  %6d\n",   imX.median, imX.mean, imX.sigma, imX.min, imX.max, imX.Nmeas);
-  fprintf (stderr, "chisq mosaic:   %6.1f  %6.1f  %6.1f  %6.1f  %7.1f  %6d\n",   msX.median, msX.mean, msX.sigma, msX.min, msX.max, msX.Nmeas);
-  fprintf (stderr, "chisq star:     %6.1f  %6.1f  %6.1f  %6.1f  %7.1f  %6d\n",   stX.median, stX.mean, stX.sigma, stX.min, stX.max, stX.Nmeas);
+  fprintf (stderr, "chisq image:    %7.1f  %7.1f  %7.1f  %7.1f  %7.1f  %6d\n",   imX.median, imX.mean, imX.sigma, imX.min, imX.max, imX.Nmeas);
+  fprintf (stderr, "chisq mosaic:   %7.1f  %7.1f  %7.1f  %7.1f  %7.1f  %6d\n",   msX.median, msX.mean, msX.sigma, msX.min, msX.max, msX.Nmeas);
+  fprintf (stderr, "chisq star:     %7.1f  %7.1f  %7.1f  %7.1f  %7.1f  %6d\n",   stX.median, stX.mean, stX.sigma, stX.min, stX.max, stX.Nmeas);
 
-  fprintf (stderr, "Mcal image:     %6.3f  %6.3f  %6.3f  %6.3f  %7.3f  %6d\n",   imM.median, imM.mean, imM.sigma, imM.min, imM.max, imM.Nmeas);
-  fprintf (stderr, "dMcal image:    %6.3f  %6.3f  %6.3f  %6.3f  %7.3f  %6d\n",   imD.median, imD.mean, imD.sigma, imD.min, imD.max, imD.Nmeas);
+  fprintf (stderr, "Mcal image:     %7.4f  %7.4f  %7.4f  %7.4f  %7.4f  %6d\n",   imM.median, imM.mean, imM.sigma, imM.min, imM.max, imM.Nmeas);
+  fprintf (stderr, "dMcal image:    %7.4f  %7.4f  %7.4f  %7.4f  %7.4f  %6d\n",   imD.median, imD.mean, imD.sigma, imD.min, imD.max, imD.Nmeas);
 
-  fprintf (stderr, "Mcal mosaic:    %6.3f  %6.3f  %6.3f  %6.3f  %7.3f  %6d\n",   msM.median, msM.mean, msM.sigma, msM.min, msM.max, msM.Nmeas);
-  fprintf (stderr, "dMcal mosaic:   %6.3f  %6.3f  %6.3f  %6.3f  %7.3f  %6d\n",   msD.median, msD.mean, msD.sigma, msD.min, msD.max, msD.Nmeas);
+  fprintf (stderr, "Mcal mosaic:    %7.4f  %7.4f  %7.4f  %7.4f  %7.4f  %6d\n",   msM.median, msM.mean, msM.sigma, msM.min, msM.max, msM.Nmeas);
+  fprintf (stderr, "dMcal mosaic:   %7.4f  %7.4f  %7.4f  %7.4f  %7.4f  %6d\n",   msD.median, msD.mean, msD.sigma, msD.min, msD.max, msD.Nmeas);
 
-  fprintf (stderr, "dMrel star:     %6.3f  %6.3f  %6.3f  %6.3f  %7.3f  %6d\n\n", stS.median, stS.mean, stS.sigma, stS.min, stS.max, stS.Nmeas);
+  fprintf (stderr, "dMrel star:     %7.4f  %7.4f  %7.4f  %7.4f  %7.4f  %6d\n\n", stS.median, stS.mean, stS.sigma, stS.min, stS.max, stS.Nmeas);
 
   initstats (STATMODE);
Index: /trunk/Ohana/src/relphot/src/plot_scatter.c
===================================================================
--- /trunk/Ohana/src/relphot/src/plot_scatter.c	(revision 5142)
+++ /trunk/Ohana/src/relphot/src/plot_scatter.c	(revision 5143)
@@ -51,5 +51,5 @@
   graphdata.ymin = PlotdMmin;
   graphdata.ymax = PlotdMmax;
-  plot_list (&graphdata, ilist, ylist, N, "imag vs dmag", NULL);
+  plot_list (&graphdata, ilist, ylist, N, "imag vs dmag", "iMag.png");
   free (xlist);
   free (ylist);
