Index: trunk/Ohana/src/libdvo/include/dvodb.h
===================================================================
--- trunk/Ohana/src/libdvo/include/dvodb.h	(revision 36840)
+++ trunk/Ohana/src/libdvo/include/dvodb.h	(revision 37035)
@@ -22,62 +22,46 @@
 
 /* magnitude types */
-enum {MAG_NONE, 
-
-      // these magnitude types are from the measurement table (or derived therein)
-      // the following imply PSF magnitudes:
-      MAG_INST, // -2.5*log(DN) [ie, not DN/sec]
-      MAG_CAT,  // MAG_INST + 2.5*log(exptime) + C_lambda + K_lambda*(airmass - 1)
-      MAG_SYS,  // MAG_CAT + \sum_i A_i * (color_i - color_o) [color correction for measure photcode]
-      MAG_REL,  // MAG_SYS - Mcal [specific zero point for image]
-      MAG_CAL,  // MAG_REL + \sum_i A_i * (color_i - color_o) [color correction for average photcode]
-      MAG_ERR,  // error on PSF MAG
-
-      // the following imply APERTURE magnitudes:
-      MAG_APER_INST, // -2.5*log(DN) [ie, not DN/sec]
-      MAG_APER_CAT,  // MAG_APER_INST + 2.5*log(exptime) + C_lambda + K_lambda*(airmass - 1)
-      MAG_APER_SYS,  // MAG_APER_CAT + \sum_i A_i * (color_i - color_o) [color correction for measure photcode]
-      MAG_APER_REL,  // MAG_APER_SYS - Mcal [specific zero point for image]
-      MAG_APER_CAL,  // MAG_APER_REL + \sum_i A_i * (color_i - color_o) [color correction for average photcode]
-      MAG_APER_ERR,  // error on APER MAG (if known, else psf error)
-      MAG_APER,      // in mextract -> MAG_APER_REL, in avextract -> MAG_APER_AVE
-
-      // the following imply KRON magnitudes:
-      MAG_KRON_INST, // -2.5*log(DN) [ie, not DN/sec]
-      MAG_KRON_CAT,  // MAG_KRON_INST + 2.5*log(exptime) + C_lambda + K_lambda*(airmass - 1)
-      MAG_KRON_SYS,  // MAG_KRON_CAT + \sum_i A_i * (color_i - color_o) [color correction for measure photcode]
-      MAG_KRON_REL,  // MAG_KRON_SYS - Mcal [specific zero point for image]
-      MAG_KRON_CAL,  // MAG_KRON_REL + \sum_i A_i * (color_i - color_o) [color correction for average photcode]
-      MAG_KRON_ERR,  // error on KRON MAG
-      MAG_KRON,      // in mextract -> MAG_KRON_REL, in avextract -> MAG_KRON_AVE
-
-      // these magnitude types are from the average (secfilt) table:
-      // the following imply PSF magnitudes (or fluxes)
-      MAG_AVE, 
-      MAG_REF, 
-      MAG_STDEV, 
-      MAG_AVE_ERR, 
-      MAG_CHISQ,
-      MAG_20, 
-      MAG_80, 
-      MAG_FLUX_PSF,
-      MAG_FLUX_PSF_ERR,
-
-      // the following imply APERTURE magnitudes:
-      MAG_APER_AVE,
-      MAG_APER_REF,
-
-      // the following imply KRON magnitudes or fluxes:
-      MAG_KRON_AVE,
-      MAG_KRON_REF,
-      MAG_FLUX_KRON,
-      MAG_FLUX_KRON_ERR,
-
-      // other secfilt fields of interest
-      MAG_PHOT_FLAGS, 
-      MAG_NCODE,
-      MAG_NPHOT,
-      MAG_UC_DIST, 
-      MAG_STACK_DET_ID, 
-};
+
+typedef enum {
+  MAG_SRC_NONE,
+  MAG_SRC_CHP,
+  MAG_SRC_WRP,
+  MAG_SRC_STK,
+} dvoMagSourceType;
+
+typedef enum {
+  MAG_LEVEL_NONE,	// -2.5*log(DN) [ie, not DN/sec]
+  MAG_LEVEL_INST,		// -2.5*log(DN) [ie, not DN/sec]
+  MAG_LEVEL_CAT,		// MAG_INST + 2.5*log(exptime) + C_lambda + K_lambda*(airmass - 1)
+  MAG_LEVEL_SYS, // MAG_CAT + \sum_i A_i * (color_i - color_o) [color correction for measure photcode]
+  MAG_LEVEL_REL, // MAG_SYS - Mcal [specific zero point for image]
+  MAG_LEVEL_CAL, // MAG_REL + \sum_i A_i * (color_i - color_o) [color correction for average photcode]
+  MAG_LEVEL_AVE, 
+  MAG_LEVEL_REF, 
+} dvoMagLevelType;
+
+typedef enum {
+  MAG_OPTION_NONE,
+  MAG_OPTION_MAG,
+  MAG_OPTION_ERR,
+  MAG_OPTION_FLUX,
+  MAG_OPTION_FLUX_ERR,
+  MAG_OPTION_STDEV,
+  MAG_OPTION_CHISQ,
+  MAG_OPTION_MIN,
+  MAG_OPTION_MAX,
+  MAG_OPTION_NCODE,
+  MAG_OPTION_NPHOT, // Nused
+  MAG_OPTION_UC_DIST, 
+  MAG_OPTION_STACK_DET_ID, 
+  MAG_OPTION_FLAGS, 
+} dvoMagOptionType;
+
+typedef enum {
+  MAG_CLASS_NONE,
+  MAG_CLASS_PSF,
+  MAG_CLASS_KRON,
+  MAG_CLASS_APER,
+} dvoMagClassType;
 
 /* measure fields */
@@ -119,5 +103,5 @@
       MEAS_OBJ_FLAGS, 
       MEAS_SECFILT_FLAGS, 
-      MEAS_MAG, 
+      MEAS_PHOT, // photometry class of measurements
       MEAS_MINST, 
       MEAS_MCAT, 
@@ -173,11 +157,7 @@
       MEAS_EXTERN_ID,
       MEAS_EXPNAME_AS_INT,
-      MEAS_MCAL_OFFSET,
+      MEAS_MCAL_OFFSET, // make this a dvoMagOption?
       MEAS_FLAT,
       MEAS_CENTER_OFFSET,
-      MEAS_FLUX_PSF,
-      MEAS_FLUX_PSF_ERR,
-      MEAS_FLUX_KRON,
-      MEAS_FLUX_KRON_ERR,
       MEAS_REF_COLOR,
 };
@@ -211,9 +191,4 @@
       AVE_NMISS, 
       AVE_NPOS, 
-      AVE_NPHOT, 
-      AVE_NCODE, 
-      AVE_MAG, 
-      AVE_dMAG, 
-      AVE_Xm, 
       AVE_OBJ_FLAGS, 
       AVE_TYPE, 
@@ -224,5 +199,12 @@
       AVE_EXTID_LO,
       AVE_REF_COLOR,
+      AVE_PHOT, // photometry class of values
 };
+
+//       AVE_NPHOT, 
+//       AVE_NCODE, 
+//       AVE_MAG, 
+//       AVE_dMAG, 
+//       AVE_Xm, 
 
 enum {IMAGE_ZERO, 
@@ -312,5 +294,10 @@
   int table;
   int ID;
-  int magMode;
+
+  dvoMagSourceType magSource; // chip, (forced) warp, stack [only relevant for averages]
+  dvoMagLevelType magLevel;  // inst, cat, sys, rel, ave, ref, err, min, max, stdev, nphot, chisq, 
+  dvoMagOptionType magOption;  // psf, kron, aper
+  dvoMagClassType magClass;
+
   char type;
   PhotCode *photcode;
@@ -374,5 +361,5 @@
 
 int          GetMagMode             PROTO((char *string));
-PhotCode    *ParsePhotcodeField     PROTO((char *field, int *mode, int def));
+int          ParsePhotcodeField     PROTO((dbField *field, char *fieldName, int fieldID));
 int          ParseMeasureField      PROTO((dbField *field, char *fieldName));
 int          ParseAverageField      PROTO((dbField *field, char *fieldName));
