Index: trunk/psastro/src/psastroUtils.c
===================================================================
--- trunk/psastro/src/psastroUtils.c	(revision 5575)
+++ trunk/psastro/src/psastroUtils.c	(revision 6176)
@@ -32,10 +32,5 @@
 }
 
-// measure per-chip astrometry terms 
-bool psastroChipAstrom (pmFPA *fpa, psMetadata *config) {
-
-    bool status;
-    psArray *match;
-    pmAstromStats stats;
+bool psastroNormFPA (pmFPA *fpa, psMetadata *config) {
 
     // save the raw astrometry for later reference
@@ -45,67 +40,5 @@
     for (int i = 0; i < fpa->chips->n; i++) {
 	pmChip *chip = fpa->chips->data[i];
-
-	// cells->n > 1 is not yet well-defined
-	if (chip->cells->n > 1) {
-	    psLogMsg ("pmSourcesReadCMP", 3, "undefined behavior for nCells > 1");
-	    return false;
-	}
-
-	for (int j = 0; j < chip->cells->n; j++) {
-	    pmCell *cell = chip->cells->data[j];
-
-	    // readouts->n > 1 is not yet well-defined
-	    if (cell->readouts->n > 1) {
-		psLogMsg ("pmSourcesReadCMP", 3, "undefined behavior for nReadouts > 1");
-		return false;
-	    }
-
-	    // load the corresponding reference data (DVO command)
-	    psArray *refstars = psastroLoadReference (cell->header, config);
-
-	    for (int k = 0; k < cell->readouts->n; k++) {
-
-		pmReadout *readout = cell->readouts->data[k];
-
-		// pull out the SUBSET rawstars (a view)
-		psArray *rawstars = psMetadataLookupPtr (&status, readout->analysis, "STARS.SUBSET");
-
-		// project the rawstars to the current best guess astrometry
-		psastroProjectRawstars (rawstars, readout);
-
-		// use the header & config info to project refstars onto the focal plane
-		psastroProjectRefstars (refstars, readout);
-
-		// testWriteRaw ("ref.inp", refstars);
-		// testWriteRaw ("raw.inp", rawstars);
-
-		// fprintf (stderr, "rawstars:\n");
-		// psastroDumpStars (rawstars);
-		// fprintf (stderr, "refstars:\n");
-		// psastroDumpStars (refstars);
-
-		// find initial offset / rotation
-		stats = pmAstromGridMatch (rawstars, refstars, config);
-
-		// adjust the chip.toFPA terms only
-		pmAstromGridApply (chip->toFPA, stats);
-		chip->fromFPA = p_psPlaneTransformLinearInvert (chip->toFPA);
-
-		// use fit result to re-project rawstars
-		psastroProjectRawstars (rawstars, readout);
-		psastroProjectRefstars (refstars, readout);
-
-		// testWriteRaw ("ref.dat", refstars);
-		// testWriteRaw ("raw.dat", rawstars);
-    
-		// use small radius to match stars
-		match = pmAstromRadiusMatch (rawstars, refstars, config);
-
-		// improved fit for astrometric terms
-		pmAstromMatchFit (chip->toFPA, rawstars, refstars, match, config);
-		chip->fromFPA = p_psPlaneTransformLinearInvert (chip->toFPA);
-	    }
-	    pmAstromWriteWCS (chip->toFPA, fpa->toSky, cell->header);
-	}
+	psastroChipAstrom (chip, config);
     }
 
