Index: trunk/ippScripts/scripts/detrend_resid_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_resid_imfile.pl	(revision 22430)
+++ trunk/ippScripts/scripts/detrend_resid_imfile.pl	(revision 23183)
@@ -124,4 +124,24 @@
 };
 
+# The output file rule name depends on the detrend type
+my $FILERULES = { 'FLATMASK'         => 'PPIMAGE.OUTPUT.RESID',
+                  'DARKMASK'         => 'PPIMAGE.OUTPUT.RESID',
+                  'MASK'             => 'PPIMAGE.OUTPUT.RESID',
+                  'BIAS'             => 'PPIMAGE.OUTPUT.RESID',
+                  'DARK'             => 'PPIMAGE.OUTPUT.RESID',
+                  'DARK_PREMASK'     => 'PPIMAGE.OUTPUT.RESID',
+                  'SHUTTER'          => 'PPIMAGE.OUTPUT.DETREND',
+                  'FLAT_PREMASK'     => 'PPIMAGE.OUTPUT.DETREND',
+                  'DOMEFLAT_PREMASK' => 'PPIMAGE.OUTPUT.DETREND',
+                  'SKYFLAT_PREMASK'  => 'PPIMAGE.OUTPUT.DETREND',
+                  'FLAT_RAW'         => 'PPIMAGE.OUTPUT.DETREND',
+                  'DOMEFLAT_RAW'     => 'PPIMAGE.OUTPUT.DETREND',
+                  'SKYFLAT_RAW'      => 'PPIMAGE.OUTPUT.DETREND',
+                  'FLAT'             => 'PPIMAGE.OUTPUT.DETREND',
+                  'DOMEFLAT'         => 'PPIMAGE.OUTPUT.DETREND',
+                  'SKYFLAT'          => 'PPIMAGE.OUTPUT.DETREND',
+                  'FRINGE'           => 'PPIMAGE.OUTPUT.RESID',
+              };
+
 # outroot examples (HOST components must be set)
 # file://data/ipp004.0/gpc1/20080130
@@ -149,5 +169,5 @@
     $command .= " -recipe JPEG $jpeg_recipe";
     $command .= " -recipe PPSTATS RESIDUAL";
-    $command .= " -F PPIMAGE.OUTPUT PPIMAGE.OUTPUT.RESID";
+    $command .= " -F PPIMAGE.OUTPUT $FILERULES{$det_type}" if defined $FILERULES{$det_type};
     $command .= " -stats $outputStats";
     $command .= " -tracedest $traceDest -log $logDest";
