Index: /trunk/psastro/src/psastroMosaicChipAstrom.c
===================================================================
--- /trunk/psastro/src/psastroMosaicChipAstrom.c	(revision 41497)
+++ /trunk/psastro/src/psastroMosaicChipAstrom.c	(revision 41498)
@@ -21,4 +21,13 @@
     pmReadout *readout = NULL;
     pmFPAview *view = pmFPAviewAlloc (0);
+
+    float minGoodChipFraction = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.MIN.GOOD.CHIP.FRACTION");
+    if (!status) { 
+      minGoodChipFraction = 0.1;      
+      psWarning ("failed to find PSASTRO.MOSAIC.MIN.GOOD.CHIP.FRACTION in recipe, assuming default of %f", minGoodChipFraction); 
+    }
+
+    int nChipGood = 0;
+    int nChipFail = 0;
 
     // this loop selects the matched stars for all chips
@@ -51,4 +60,5 @@
 		    psErrorStackPrint(stderr, "failure for one chip\n");
 		    psErrorClear();
+		    nChipFail ++;
 		    continue;
                 }
@@ -60,10 +70,27 @@
 		    psErrorStackPrint(stderr, "failure for one chip\n");
 		    psErrorClear();
+		    nChipFail ++;
 		    continue;
                 }
+		nChipGood ++;
             }
         }
     }
     psFree (view);
+
+    // if basically the entire exposure is bad, return false (calling function sets bad quality)
+    float fGood = nChipGood / ((float) (nChipGood + nChipFail));
+    if (fGood < minGoodChipFraction) {
+      psWarning ("Too few good chips (%d of %d = %.2f), setting bad quality for this exposure\n", nChipGood, (nChipGood + nChipFail), fGood);
+      // return false;
+    }
+
     return true;
 }
+
+// XXX count success and failures
+// XXX set bad quality if fraction of successes < threshold
+// XXX e.g., 5% success would mean 3 of 60 GPC1 chips are goo.
+// XXX or, 10% would be 6 of 60.
+// XXX seems like a good indicator of failure.
+// XXX also, test CERROR against a minimum value?
