Index: /trunk/ppSub/src/ppSubCamera.c
===================================================================
--- /trunk/ppSub/src/ppSubCamera.c	(revision 42855)
+++ /trunk/ppSub/src/ppSubCamera.c	(revision 42856)
@@ -359,4 +359,6 @@
     }
 
+    int did_rewrite = 0;
+    
     // Use a temporary config for the reference image, keeping the main user, site,
     // system, files, arguments entries.  This allows the reference image to be from a
@@ -371,6 +373,16 @@
     pmFPAfile *ref = defineInputFile(&success, refconfig, NULL, "PPSUB.REF", "REF", PM_FPA_FILE_IMAGE);
     if (!success) {
-	psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.REF");
-	return false;
+        psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.REF");
+
+	psErrorClear();
+	fprintf(stderr,"%s\n", config->cameraName);
+	psStringSubstitute(&( config->cameraName ),"GPC1","GPC2");
+	fprintf(stderr,"%s\n", config->cameraName);
+	did_rewrite = 1;
+	
+	ref = defineInputFile(&success, config, NULL, "PPSUB.REF", "REF", PM_FPA_FILE_IMAGE);
+	if (!success) {
+	  return false;
+	}
     }
     // Reference mask
@@ -397,10 +409,32 @@
     pmFPAfile *src = defineInputFile(&success, srcconfig, NULL, "PPSUB.REF.SOURCES", "REF.SOURCES", PM_FPA_FILE_CMF);
     if (!success) {
-	psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.REF.SOURCES");
-	return false;
+      if (did_rewrite == 1) {
+	// Sometimes we use the warp sources instead of the stack
+	psErrorClear();
+	did_rewrite = 0;
+	
+	fprintf(stderr,"%s\n", config->cameraName);
+	psStringSubstitute(&( config->cameraName ),"GPC2","GPC1");
+	fprintf(stderr,"%s\n", config->cameraName);
+	defineInputFile(&success, config, NULL, "PPSUB.REF.SOURCES", "REF.SOURCES", PM_FPA_FILE_CMF);
+	if (!success) {
+	  psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.REF.SOURCES");
+	  return false;
+	}
+      }
+      else {
+        psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.REF.SOURCES");
+        return false;
+      }
     }
     // copy src->format(RULE) PSCAMERA from input->format(RULE)
     ppSubCopyPSCamera (src, input);
     psFree (srcconfig);
+    
+    if (did_rewrite == 1) {
+      fprintf(stderr,"%s\n", config->cameraName);
+      psStringSubstitute(&( config->cameraName ),"GPC2","GPC1");
+      fprintf(stderr,"%s\n", config->cameraName);
+    }
     
     // Now that the camera has been determined, we can read the recipe
