Index: trunk/Ohana/src/relphot/include/relphot.h
===================================================================
--- trunk/Ohana/src/relphot/include/relphot.h	(revision 41453)
+++ trunk/Ohana/src/relphot/include/relphot.h	(revision 41462)
@@ -84,7 +84,9 @@
   float secz;
   float ubercalDist;
-  unsigned short nFitPhotom;
+  unsigned int nFitPhotom;
+  unsigned int nValPhotom;
   unsigned int flags;
   char skipCal;		      // if TRUE, this mosaic is incomplete and should not be calibrated
+  char inTGroup;
   Coords coords;
 } Mosaic; 
@@ -97,6 +99,8 @@
   float dMcal;
   float dMsys;
+  float stdev;
   float McalChiSq;
-  unsigned short nFitPhotom;
+  unsigned int nFitPhotom;
+  unsigned int nValPhotom;
   unsigned int flags;
 
@@ -109,4 +113,8 @@
   off_t *measure;
   off_t *catalog;
+
+  off_t Nmosaic;
+  off_t NMOSAIC;
+  Mosaic **mosaic; // pointer to the mosaic structures
 
   void *parent;
@@ -185,4 +193,5 @@
   int     Nlist;	      // total number of measurements in list (may be more than the number to use)
   int     Nbootstrap;	      // number of bootstrap iterations
+  int     MaxIterations;      // number of IRLS iterations
 
   // input data & parameters: 
@@ -387,6 +396,11 @@
 int    VERBOSE2;
 int    VERBOSE_IMAGE;
+
 int    MOSAIC_ZEROPT;
 int    TGROUP_ZEROPT;
+
+int    FREEZE_IMAGES;
+int    FREEZE_MOSAICS;
+
 int    TGROUP_FIT_AIRMASS;
 
@@ -414,6 +428,4 @@
 double IMAGE_GOOD_FRACTION;
 int    IMAGE_BAD;
-int    FREEZE_IMAGES;
-int    FREEZE_MOSAICS;
 int    CALIBRATE_STACKS_AND_WARPS;
 int    USE_GRID;
@@ -461,4 +473,13 @@
 SkyRegion UserPatch;
 char *UserCatalog;
+
+enum {TGROUP_ZPT_MODE_NONE, TGROUP_ZPT_MODE_GOOD_NIGHT, TGROUP_ZPT_MODE_ALL, };
+int TGROUP_ZPT_MODE;
+
+enum {MOSAIC_ZPT_MODE_NONE, MOSAIC_ZPT_MODE_BAD_NIGHT, MOSAIC_ZPT_MODE_GOOD_MOSAIC, MOSAIC_ZPT_MODE_BAD_NIGHT_GOOD_MOSAIC, MOSAIC_ZPT_MODE_ALL, };
+int MOSAIC_ZPT_MODE;
+
+enum {IMAGE_ZPT_MODE_NONE, IMAGE_ZPT_MODE_BAD_NIGHT, IMAGE_ZPT_MODE_BAD_MOSAIC, IMAGE_ZPT_MODE_BAD_NIGHT_BAD_MOSAIC, IMAGE_ZPT_MODE_ALL, };
+int IMAGE_ZPT_MODE;
 
 int USE_ALL_IMAGES;
@@ -526,5 +547,5 @@
 float         getMgrid            PROTO((off_t meas, int cat));
 float         getMmos             PROTO((off_t meas, int cat));
-float         getMgrp             PROTO((off_t meas, int cat, float airmass));
+float         getMgrp             PROTO((off_t meas, int cat, float airmass, float *dZpt));
 float         getMrel             PROTO((Catalog *catalog, off_t meas, int cat, dvoMagClassType class, dvoMagSourceType source));
 short         getUbercalDist      PROTO((off_t meas, int cat));
@@ -601,14 +622,17 @@
 int           reload_images       PROTO((FITS_DB *db));
 int           setExclusions       PROTO((Catalog *catalog, int Ncatalog, int verbose));
-void          setMcal             PROTO((Catalog *catalog, int Poor, FlatCorrectionTable *flatcorr));
+void          setMgrid            PROTO((Catalog *catalog, FlatCorrectionTable *flatcorr));
 void          setMcalFromMosaics  PROTO((void));
 void          setMcalFromTGroups  PROTO((void));
 int           setMcalOutput       PROTO((Catalog *catalog, int Ncatalog, FlatCorrectionTable *flatcorr));
-void          setMgrid            PROTO((Catalog *catalog, FlatCorrectionTable *flatcorr));
-int           setMmos             PROTO((Catalog *catalog, int Poor, FlatCorrectionTable *flatcorr));
-int           setMgrp             PROTO((Catalog *catalog, int Poor, FlatCorrectionTable *flatcorr));
+
+void          setMcal             PROTO((Catalog *catalog, int Nloop, int Poor, FlatCorrectionTable *flatcorr));
+int           setMmos             PROTO((Catalog *catalog, int Nloop, int Poor, FlatCorrectionTable *flatcorr));
+int           setMgrp             PROTO((Catalog *catalog, int Nloop, int Poor, FlatCorrectionTable *flatcorr));
+
 int           setMrel             PROTO((Catalog *catalog, int Ncatalog, FlatCorrectionTable *flatcorr));
 void          setMrelFinal        PROTO((Catalog *catalog, FlatCorrectionTable *flatcorr, int simpleAverage));
 int           setMrelOutput       PROTO((Catalog *catalog, int Ncatalog, FlatCorrectionTable *flatcorr));
+
 int           setMave             PROTO((Catalog *catalog, int Ncatalog));
 void          set_ZP              PROTO((double ZERO));
@@ -627,4 +651,8 @@
 StatType      statsMosaicX        PROTO((Catalog *catalog));
 StatType      statsMosaicdM       PROTO((Catalog *catalog));
+StatType      statsTGroupM        PROTO((Catalog *catalog));
+StatType      statsTGroupX        PROTO((Catalog *catalog));
+StatType      statsTGroupdM       PROTO((Catalog *catalog));
+
 StatType      statsStarN          PROTO((Catalog *catalog, int Ncatalog, int Nsec, int seccode, FlatCorrectionTable *flatcorr));
 StatType      statsStarS          PROTO((Catalog *catalog, int Ncatalog, int Nsec));
@@ -795,2 +823,7 @@
 
 int save_images_backup (FITS_DB *db);
+
+void dump_tgroups (Catalog *catalog, int Npass);
+void dump_catalog (Catalog *catalog, off_t c, int Npass);
+
+void SetZeroPointModes (int nloop);
