Index: trunk/ppMerge/src/ppMergeScaleZero.c
===================================================================
--- trunk/ppMerge/src/ppMergeScaleZero.c	(revision 24909)
+++ trunk/ppMerge/src/ppMergeScaleZero.c	(revision 26629)
@@ -67,7 +67,7 @@
         pmChip *chip;                   ///< Chip of interest
         while ((chip = pmFPAviewNextChip(view, fpa, 1))) {
-	    if (!chip->process || !chip->file_exists) {
-		continue;
-	    }
+            if (!chip->process || !chip->file_exists) {
+                continue;
+            }
             if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
                 goto ERROR;
@@ -76,7 +76,7 @@
             pmCell *cell;               ///< Cell of interest
             while ((cell = pmFPAviewNextCell(view, fpa, 1))) {
-		if (!cell->process || !cell->file_exists) {
-		    continue;
-		}
+                if (!cell->process || !cell->file_exists) {
+                    continue;
+                }
                 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
                     goto ERROR;
@@ -87,10 +87,11 @@
                 }
 
-		// skip cells with video data
+                // skip cells with video data
                 if (cell->readouts->n > 1) {
-		    // psError(PS_ERR_BAD_PARAMETER_VALUE, true, "File %d chip %d cell %d contains more than one readout (%ld)", i, view->chip, view->cell, cell->readouts->n);
-		    // goto ERROR;
-		  psWarning("File %d chip %d cell %d contains more than one readout (%ld), skipping", i, view->chip, view->cell, cell->readouts->n);
-		  continue;
+                    // psError(PS_ERR_BAD_PARAMETER_VALUE, true, "File %d chip %d cell %d contains more than one readout (%ld)", i, view->chip, view->cell, cell->readouts->n);
+                    // goto ERROR;
+                  psWarning("File %d chip %d cell %d contains more than one readout (%ld), skipping",
+                            i, view->chip, view->cell, cell->readouts->n);
+                  continue;
                 }
                 pmReadout *readout = cell->readouts->data[0]; ///< Readout of interest
@@ -104,9 +105,25 @@
                       float gain = psMetadataLookupF32(NULL, cell->concepts, "CELL.GAIN"); ///< Cell gain
                       if (!isfinite(gain)) {
-                        // psError(PS_ERR_BAD_PARAMETER_VALUE, false,
-                        // "CELL.GAIN for file %d chip %d cell %d is not set.",
-                        // i, view->chip, view->cell);
-                        // goto ERROR;
-                        psWarning ("CELL.GAIN for file %d chip %d cell %d is NaN", i, view->chip, view->cell);
+                          psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes,
+                                                                        PPMERGE_RECIPE); // Recipe
+                          psAssert(recipe, "Should be there!");
+                          bool override = psMetadataLookupBool(NULL, recipe,
+                                                               "GAIN.OVERRIDE"); // Override the bad gain?
+                          if (override) {
+                              psWarning("CELL.GAIN is not set for readout (%d,%d,%d) on file %d "
+                                        "--- setting to unity.",
+                                        view->chip, view->cell, view->readout, i);
+                              psMetadataItem *item = psMetadataLookup(cell->concepts,
+                                                                      "CELL.GAIN"); // Item with gain
+                              psAssert(item, "Should be there!");
+                              item->data.F32 = 1.0;
+                          } else {
+                              // psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                              // "CELL.GAIN for file %d chip %d cell %d is not set.",
+                              // i, view->chip, view->cell);
+                              // goto ERROR;
+                              psWarning("CELL.GAIN for file %d chip %d cell %d is NaN",
+                                        i, view->chip, view->cell);
+                          }
                       }
                       gains->data.F32[cellNum] = gain;
@@ -118,5 +135,6 @@
                         // i, view->chip, view->cell);
                         // goto ERROR;
-                        psWarning ("Unable to get statistics for file %d chip %d cell %d", i, view->chip, view->cell);
+                        psWarning ("Unable to get statistics for file %d chip %d cell %d",
+                                   i, view->chip, view->cell);
                         background->data.F32[i][cellNum] = NAN;
                       } else {
