Index: branches/eam_branches/relphot.20210521/src/MosaicOps.c
===================================================================
--- branches/eam_branches/relphot.20210521/src/MosaicOps.c	(revision 41625)
+++ branches/eam_branches/relphot.20210521/src/MosaicOps.c	(revision 41637)
@@ -1483,6 +1483,8 @@
 /* mark mosaic if: abs(Mcal - <Mcal>) too large, dMcal too large */
 
-static float MinMaxChiSq = NAN;
-static float MinMaxScatter = NAN;
+static float MinChiSqLim = NAN;
+static float MaxChiSqLim = NAN;
+static float MinScatterLim = NAN;
+static float MaxScatterLim = NAN;
 
 void clean_mosaics () {
@@ -1494,4 +1496,7 @@
 
   if (VERBOSE) fprintf (stderr, "marking poor mosaics\n");
+
+  if (isnan (MaxChiSqLim))   MaxChiSqLim   = MOSAIC_CHISQ;
+  if (isnan (MaxScatterLim)) MaxScatterLim = MOSAIC_SCATTER;
 
   ALLOCATE (mlist, double, Nmosaic);
@@ -1516,13 +1521,13 @@
   liststats (mlist, NULL, NULL, N, &stats);
   float ChiSqUpper90 = stats.Upper90; 
-  if (isnan (MinMaxChiSq)) MinMaxChiSq = 2.0*stats.median;
-  float MaxChiSq = MAX (MinMaxChiSq, ChiSqUpper90);
+  if (isnan (MinChiSqLim)) MinChiSqLim = 2.0*stats.median;             // chi-square cut cannot fall below this value (even if this is > MaxChiSqLim)
+  float ChiSqLimit = MAX(MinChiSqLim, MIN(MaxChiSqLim, ChiSqUpper90)); // chi-square cut should be between MinChiSqLim and MaxChiSqLim
 
   liststats (slist, NULL, NULL, N, &stats);
   float ScatterUpper90 = stats.Upper90; 
-  if (isnan (MinMaxScatter)) MinMaxScatter = 2.0*stats.median;
-  float MaxScatter = MAX (MinMaxScatter, ScatterUpper90);
-
-  fprintf (stderr, "MOSAIC: Max ChiSq: %f, Max Scatter: %f | ChiSquare Upper 90: %f, Scatter Upper 90: %f\n", MaxChiSq, MaxScatter, ChiSqUpper90, ScatterUpper90);
+  if (isnan (MinScatterLim)) MinScatterLim = 2.0*stats.median;         // scatter cut cannto fall below this value (even if this is > MaxScatterLim)
+  float ScatterLimit = MAX(MinScatterLim, MIN(MaxScatterLim, ScatterUpper90));
+
+  fprintf (stderr, "MOSAIC: ChiSqLimit: %f, ScatterLimit: %f | ChiSquare Upper 90: %f, Scatter Upper 90: %f\n", ChiSqLimit, ScatterLimit, ChiSqUpper90, ScatterUpper90);
   
   int Ntotal = 0, Npoor = 0, Nmark = 0, Nscatter = 0, Nfew = 0, Nchisq = 0;
@@ -1547,9 +1552,9 @@
       Nfew ++;
     }
-    if (mosaic[i].stdev > MaxScatter) {
+    if (mosaic[i].stdev > ScatterLimit) {
       mark = TRUE;
       Nscatter ++;
     }
-    if (mosaic[i].McalChiSq > MaxChiSq) {
+    if (mosaic[i].McalChiSq > ChiSqLimit) {
       mark = TRUE;
       Nchisq ++;
