Index: /trunk/Ohana/src/addstar/include/addstar.h
===================================================================
--- /trunk/Ohana/src/addstar/include/addstar.h	(revision 13141)
+++ /trunk/Ohana/src/addstar/include/addstar.h	(revision 13142)
@@ -77,4 +77,5 @@
 char   CCDNumKeyword[64];
 char   STKeyword[64];
+char   ExtnameKeyword[64];
 
 /* these globals modify the behavior of gstars (KEEP) */
@@ -122,5 +123,5 @@
 /*** addstar prototypes ***/
 
-void       AddToCalibration       PROTO((Average *average, Measure *measure, Measure *new, int *next, int Nstar));
+void       AddToCalibration       PROTO((Average *average, SecFilt *secfilt, Measure *measure, Measure *new, int *next, int Nstar));
 AddstarClientOptions ConfigInit   PROTO((int *argc, char **argv));
 void       FindCalibration        PROTO((Image *image));
Index: /trunk/Ohana/src/addstar/src/find_matches.c
===================================================================
--- /trunk/Ohana/src/addstar/src/find_matches.c	(revision 13141)
+++ /trunk/Ohana/src/addstar/src/find_matches.c	(revision 13142)
@@ -184,4 +184,10 @@
       catalog[0].measure[Nmeas].theta    = MIN ((0xffff/360.0)*stars[N].df, NO_MAG);
 	
+      /* adds the measurement to the calibration if appropriate color terms are found */
+      /* we call this before (optionally) setting the average magnitude to avoid auto-correlations */
+      if (options.calibrate) {
+	AddToCalibration (&catalog[0].average[n], &catalog[0].secfilt[n*Nsecfilt], catalog[0].measure, &catalog[0].measure[Nmeas], next_meas, N);
+      }
+
       /* set the average magnitude if not already set and if photcode.equiv is not 0 */
       /* in UPDATE mode, this value is not saved; use relphot to recalculate */
@@ -190,9 +196,4 @@
 	      catalog[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas]);
 	  }
-      }
-
-      /* adds the measurement to the calibration if appropriate color terms are found */
-      if (options.calibrate) {
-	AddToCalibration (&catalog[0].average[n], catalog[0].measure, &catalog[0].measure[Nmeas], next_meas, N);
       }
 
Index: /trunk/Ohana/src/addstar/src/find_matches_closest.c
===================================================================
--- /trunk/Ohana/src/addstar/src/find_matches_closest.c	(revision 13141)
+++ /trunk/Ohana/src/addstar/src/find_matches_closest.c	(revision 13142)
@@ -212,5 +212,5 @@
     /* adds the measurement to the calibration if appropriate color terms are found */
     if (options.calibrate) {
-      AddToCalibration (&catalog[0].average[n], catalog[0].measure, &catalog[0].measure[Nmeas], next_meas, N);
+      AddToCalibration (&catalog[0].average[n], &catalog[0].secfilt[n*Nsecfilt], catalog[0].measure, &catalog[0].measure[Nmeas], next_meas, N);
     }
 
