Index: trunk/psastro/src/psastroOneChipFit.c
===================================================================
--- trunk/psastro/src/psastroOneChipFit.c	(revision 39926)
+++ trunk/psastro/src/psastroOneChipFit.c	(revision 41285)
@@ -36,5 +36,5 @@
 
     // select the desired chip order
-    REQUIRED_RECIPE_VALUE (int order, "PSASTRO.CHIP.ORDER", S32);
+    REQUIRED_RECIPE_VALUE (int defaultOrder, "PSASTRO.CHIP.ORDER", S32);
 
     // allowed limits for valid solutions
@@ -57,4 +57,9 @@
         }
 
+        sprintf (name, "PSASTRO.ONE.CHIP.ORDER.N%d", iter);
+        int order = psMetadataLookupS32 (&status, recipe, name);
+        if (!status) {
+            order = defaultOrder;
+        }
 
         // use small radius to match stars
@@ -76,4 +81,15 @@
 	    match = unique;
 	}
+
+	// XXX check if we correctly applied the new transformation:
+	if (psTraceGetLevel("psastro.dump") > 0) {
+	  char *filename = NULL;
+	  char *chipname = psMetadataLookupStr (&status, chip->concepts, "CHIP.NAME");
+	  psStringAppend (&filename, "match.pref.%s.%d.dat", chipname, iter);
+	  psastroDumpMatchedStars (filename, rawstars, refstars, match);
+	  psFree (filename);
+	  filename = NULL;
+	}
+
 
         // modify the order to correspond to the actual number of matched stars:
@@ -137,4 +153,14 @@
         psastroUpdateChipToFPA (fpa, chip); // updates PSASTRO.RAWSTARS and PSASTRO.REFSTARS
 
+	// XXX check if we correctly applied the new transformation:
+	if (psTraceGetLevel("psastro.dump") > 0) {
+	  char *filename = NULL;
+	  char *chipname = psMetadataLookupStr (&status, chip->concepts, "CHIP.NAME");
+	  psStringAppend (&filename, "match.post.%s.%d.dat", chipname, iter);
+	  psastroDumpMatchedStars (filename, rawstars, refstars, match);
+	  psFree (filename);
+	  filename = NULL;
+	}
+
         // toSky converts from FPA & TPA units (microns) to sky units (radians)
         float plateScale = 0.5*(fpa->toSky->Xs + fpa->toSky->Ys)*3600.0*PM_DEG_RAD;
