Index: trunk/psastro/src/psastroUtils.c
===================================================================
--- trunk/psastro/src/psastroUtils.c	(revision 21422)
+++ trunk/psastro/src/psastroUtils.c	(revision 26259)
@@ -106,5 +106,5 @@
 }
 
-bool psastroUpdateChipToFPA (pmFPA *fpa, pmChip *chip, psArray *rawstars, psArray *refstars) {
+bool psastroUpdateChipToFPA (pmFPA *fpa, pmChip *chip) {
 
     psRegion *region = pmChipPixels (chip);
@@ -114,15 +114,33 @@
     psFree (region);
 
-    for (int i = 0; i < rawstars->n; i++) {
-        pmAstromObj *raw = rawstars->data[i];
-
-        psPlaneTransformApply (raw->FP, chip->toFPA, raw->chip);
-        psPlaneTransformApply (raw->TP, fpa->toTPA, raw->FP);
-        psDeproject (raw->sky, raw->TP, fpa->toSky);
-    }
-
-    for (int i = 0; i < refstars->n; i++) {
-        pmAstromObj *ref = refstars->data[i];
-        psPlaneTransformApply (ref->chip, chip->fromFPA, ref->FP);
+    // loop over cells in this chip
+    for (int nCell = 0; nCell < chip->cells->n; nCell++) {
+	pmCell *cell = chip->cells->data[nCell];
+	if (!cell->process || !cell->file_exists) { continue; }
+
+	// loop over readouts in this cell
+	for (int nRead = 0; nRead < cell->readouts->n; nRead++) {
+	    pmReadout *readout = cell->readouts->data[nRead];
+	    if (! readout->data_exists) { continue; }
+
+	    // select the raw objects for this readout
+	    psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS");
+	    if (rawstars) { 
+		for (int i = 0; i < rawstars->n; i++) {
+		    pmAstromObj *raw = rawstars->data[i];
+		    psPlaneTransformApply (raw->FP, chip->toFPA, raw->chip);
+		    psPlaneTransformApply (raw->TP, fpa->toTPA, raw->FP);
+		    psDeproject (raw->sky, raw->TP, fpa->toSky);
+		}
+	    }
+
+	    psArray *refstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.REFSTARS");
+	    if (refstars) { 
+		for (int i = 0; i < refstars->n; i++) {
+		    pmAstromObj *ref = refstars->data[i];
+		    psPlaneTransformApply (ref->chip, chip->fromFPA, ref->FP);
+		}
+	    }
+	}
     }
 
