Index: /trunk/ippScripts/scripts/detrend_norm_apply.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_norm_apply.pl	(revision 9891)
+++ /trunk/ippScripts/scripts/detrend_norm_apply.pl	(revision 9892)
@@ -47,4 +47,6 @@
     and defined $detType;
 
+$ipprc->define_camera($camera);
+
 
 use constant RECIPE => 'PPIMAGE_N'; # Recipe to use with ppImage
@@ -62,7 +64,9 @@
 my $outputRoot = $camera . '.' . $detType . '.norm.' . $detId . '.' . $iter; # Root output name
 $outputRoot = File::Spec->rel2abs( File::Spec->catpath( $vol, $dir, $outputRoot ), $ipprc->workdir() );
-my $output = $outputRoot . '.' . $classId . '.fits'; # Main output file
-my $b1name = $outputRoot . '.' . $classId . '.b1.fits';	# Output file with binning 1
-my $b2name = $outputRoot . '.' . $classId . '.b2.fits';	# Output file with binning 2
+
+my $output = $ipprc->filename("PPIMAGE.OUTPUT", $outputRoot, $classId);
+my $b1name = $ipprc->filename("PPIMAGE.BIN1", $outputRoot, $classId);
+my $b2name = $ipprc->filename("PPIMAGE.BIN2", $outputRoot, $classId);
+
 my $statsName = $outputRoot . '.' . $classId . '.stats'; # Statistics file
 
Index: /trunk/ippScripts/scripts/detrend_norm_exp.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_norm_exp.pl	(revision 9891)
+++ /trunk/ippScripts/scripts/detrend_norm_exp.pl	(revision 9892)
@@ -36,4 +36,6 @@
      and defined $camera
      and defined $det_type;
+
+$ipprc->define_camera($camera);
 
 use constant RECIPE1 => 'PPIMAGE_J1'; # Recipe to use for ppImage to make JPEGs
@@ -110,6 +112,6 @@
 
 # Output products --- need to synch with the camera configuration!
-my $jpeg1Name = $outputRoot . ".b1.jpg"; # Binned JPEG #1
-my $jpeg2Name = $outputRoot . ".b2.jpg"; # Binned JPEG #2
+my $jpeg1Name = $ipprc->filename("PPIMAGE.JPEG1", $outputRoot); # Binned JPEG #1
+my $jpeg2Name = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2
 
 # Make the jpeg for binning 1
Index: /trunk/ippScripts/scripts/detrend_process_exp.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_process_exp.pl	(revision 9891)
+++ /trunk/ippScripts/scripts/detrend_process_exp.pl	(revision 9892)
@@ -19,8 +19,9 @@
 use Pod::Usage qw( pod2usage );
 
-my ($det_id, $exp_tag, $no_update);
+my ($det_id, $exp_tag, $camera, $no_update);
 GetOptions(
     'det_id|d=s'        => \$det_id,
     'exp_tag|e=s'       => \$exp_tag,
+    'camera|c=s'        => \$camera,
     'no-update'         => \$no_update
 ) or pod2usage( 2 );
@@ -28,8 +29,11 @@
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
 pod2usage(
-    -msg => "Required options: --det_id --exp_tag",
+    -msg => "Required options: --det_id --exp_tag --camera",
     -exitval => 3,
 ) unless defined $det_id
-    and defined $exp_tag;
+    and defined $exp_tag,
+    and defined $camera;
+
+$ipprc->define_camera($camera);
 
 use constant RECIPE1 => 'PPIMAGE_J1'; # Recipe to use for ppImage to make JPEGs
@@ -105,7 +109,7 @@
 close $list2File;
 
-# Output products --- need to synch with the camera configuration!
-my $jpeg1Name = $outputRoot . ".b1.jpg"; # Binned JPEG #1
-my $jpeg2Name = $outputRoot . ".b2.jpg"; # Binned JPEG #2
+# Output products
+my $jpeg1 = $ipprc->filename("PPIMAGE.JPEG1", $outputRoot); # Binned JPEG #1
+my $jpeg2 = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2
 
 # Make the jpeg for binning 1
@@ -114,5 +118,5 @@
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	run(command => $command, verbose => 1);
-    die "Unable to find expected output file: $jpeg1Name\n" if not -f $jpeg1Name;
+    die "Unable to find expected output file: $jpeg1\n" if not -f $jpeg1;
 }
 
@@ -122,5 +126,5 @@
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	run(command => $command, verbose => 1);
-    die "Unable to find expected output file: $jpeg2Name\n" if not -f $jpeg2Name;
+    die "Unable to find expected output file: $jpeg2\n" if not -f $jpeg2;
 }
 
@@ -128,9 +132,9 @@
 # Add the result into the database
 $outputRoot = File::Spec->abs2rel( $outputRoot, $ipprc->workdir() );
-$jpeg1Name  = File::Spec->abs2rel( $jpeg1Name, $ipprc->workdir() );
-$jpeg2Name  = File::Spec->abs2rel( $jpeg2Name, $ipprc->workdir() );
+$jpeg1  = File::Spec->abs2rel( $jpeg1, $ipprc->workdir() );
+$jpeg2  = File::Spec->abs2rel( $jpeg2, $ipprc->workdir() );
 unless ($no_update) {
     my $command = "$dettool -addprocessedexp -det_id $det_id -exp_tag $exp_tag " .
-	"-recip " . RECIPE1() . "," . RECIPE2() . " -b1_uri $jpeg1Name -b2_uri $jpeg2Name " .
+	"-recip " . RECIPE1() . "," . RECIPE2() . " -b1_uri $jpeg1 -b2_uri $jpeg2 " .
 	"-bg $bg -bg_stdev $bg_stdev -bg_mean_stdev $bg_mean_stdev"; # Command to run
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
Index: /trunk/ippScripts/scripts/detrend_process_imfile.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 9891)
+++ /trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 9892)
@@ -18,11 +18,12 @@
 use Pod::Usage qw( pod2usage );
 
-my ($det_id, $exp_tag, $class_id, $det_type, $input_uri, $output_uri, $no_update);
+my ($det_id, $exp_tag, $class_id, $det_type, $input_uri, $camera, $no_update);
 GetOptions(
     'det_id|d=s'        => \$det_id,
-    'exp_tag|e=s'        => \$exp_tag,
+    'exp_tag|e=s'       => \$exp_tag,
     'class_id|i=s'      => \$class_id,
     'det_type|t=s'      => \$det_type,
     'input_uri|u=s'     => \$input_uri,
+    'camera|c=s'        => \$camera,
     'no-update'         => \$no_update
 ) or pod2usage( 2 );
@@ -30,5 +31,5 @@
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
 pod2usage(
-    -msg => "Required options: --det_id --exp_tag --class_id --det_type --input_uri",
+    -msg => "Required options: --det_id --exp_tag --class_id --det_type --input_uri --camera",
     -exitval => 3,
 ) unless defined $det_id
@@ -36,5 +37,8 @@
     and defined $class_id
     and defined $det_type
-    and defined $input_uri;
+    and defined $input_uri
+    and defined $camera;
+
+$ipprc->define_camera($camera);
 
 # Recipes to use, as a function of the detrend type
@@ -57,13 +61,15 @@
 die "Unrecognised detrend type: $det_type\n" if not defined $recipe;
 
-### Output file name --- must match camera configuration!
+### Output file name
 my ($vol, $dir, $file) = File::Spec->splitpath( $input_uri );
 my $outputRoot = $exp_tag . '.detproc.' . $det_id; # Root name
 $outputRoot = File::Spec->rel2abs( File::Spec->catpath( $vol, $dir, $outputRoot ), $ipprc->workdir() );
 $input_uri = File::Spec->rel2abs( $input_uri, $ipprc->workdir() );
-my $outputImage = $outputRoot . '.' . $class_id . '.fits';
+
+my $outputImage = $ipprc->filename("PPIMAGE.OUTPUT", $outputRoot, $class_id);
+my $outputBin1 = $ipprc->filename("PPIMAGE.BIN1", $outputRoot, $class_id);
+my $outputBin2 = $ipprc->filename("PPIMAGE.BIN2", $outputRoot, $class_id);
+
 my $outputStats = $outputRoot . '.' . $class_id . '.stats';
-my $outputBin1 = $outputRoot . '.' . $class_id . '.b1.fits';
-my $outputBin2 = $outputRoot . '.' . $class_id . '.b2.fits';
 
 # Run ppImage
Index: /trunk/ippScripts/scripts/detrend_reject_imfile.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_reject_imfile.pl	(revision 9891)
+++ /trunk/ippScripts/scripts/detrend_reject_imfile.pl	(revision 9892)
@@ -40,4 +40,6 @@
     and defined $det_type
     and defined $camera;
+
+$ipprc->define_camera($camera);
 
 use constant RECIPE1 => 'PPIMAGE_J1'; # Recipe to use for ppImage to make JPEGs
@@ -87,6 +89,6 @@
 
 # Output products --- need to synch with the camera configuration!
-my $jpeg1Name = $outputRoot . ".b1.jpg"; # Binned JPEG #1
-my $jpeg2Name = $outputRoot . ".b2.jpg"; # Binned JPEG #2
+my $jpeg1Name = $ipprc->filename("PPIMAGE.JPEG1", $outputRoot); # Binned JPEG #1
+my $jpeg2Name = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2
 
 # Make the jpeg for binning 1
@@ -106,5 +108,4 @@
 }
 
-$ipprc->define_camera( $camera);
 my $expected = rejection_limit( 'EXPECTED', $det_type, $filter ); # Expected mean
 # Rejection thresholds
Index: /trunk/ippScripts/scripts/detrend_resid.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_resid.pl	(revision 9891)
+++ /trunk/ippScripts/scripts/detrend_resid.pl	(revision 9892)
@@ -20,13 +20,14 @@
 
 my ($det_id, $iter, $exp_tag, $class_id, $det_type, $detrend,
-        $input_uri, $no_update);
+        $input_uri, $camera, $no_update);
 GetOptions(
     'det_id|d=s'        => \$det_id,
     'iteration=s'       => \$iter,
-    'exp_tag|e=s'        => \$exp_tag,
+    'exp_tag|e=s'       => \$exp_tag,
     'class_id|i=s'      => \$class_id,
     'det_type|t=s'      => \$det_type,
     'detrend=s'         => \$detrend,
     'input_uri|u=s'     => \$input_uri,
+    'camera|c=s'        => \$camera,
     'no-update'         => \$no_update
 ) or pod2usage( 2 );
@@ -34,5 +35,5 @@
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
 pod2usage(
-    -msg => "Required options: --det_id --iteration --exp_tag --class_id --det_type --detrend --input_uri",
+    -msg => "Required options: --det_id --iteration --exp_tag --class_id --det_type --detrend --camera --input_uri",
     -exitval => 3,
 ) unless defined $det_id
@@ -42,5 +43,8 @@
     and defined $det_type
     and defined $detrend
-    and defined $input_uri;
+    and defined $input_uri
+    and defined $camera;
+
+$ipprc->define_camera($camera);
 
 # Recipes to use, as a function of the detrend type
@@ -84,8 +88,10 @@
 $input_uri = File::Spec->rel2abs( $input_uri, $ipprc->workdir() );
 $detrend = File::Spec->rel2abs( $detrend, $ipprc->workdir() );
-my $outputName = $outputRoot . '.' . $class_id . '.fits'; # Name for 
+
+my $outputName = $ipprc->filename("PPIMAGE.OUTPUT", $outputRoot, $class_id);
+my $bin1Name =  $ipprc->filename("PPIMAGE.BIN1", $outputRoot, $class_id);
+my $bin2Name =  $ipprc->filename("PPIMAGE.BIN2", $outputRoot, $class_id);
+
 my $outputStats = $outputRoot . '.' . $class_id . '.stats';
-my $bin1Name = $outputRoot . '.' . $class_id . '.b1.fits';
-my $bin2Name =  $outputRoot . '.' . $class_id . '.b2.fits';
 
 # Run ppImage
Index: /trunk/ippScripts/scripts/phase2.pl
===================================================================
--- /trunk/ippScripts/scripts/phase2.pl	(revision 9891)
+++ /trunk/ippScripts/scripts/phase2.pl	(revision 9892)
@@ -21,4 +21,5 @@
     $classId,			# Class Id
     $input,			# Input FITS file
+    $camera,			# Camera
     $no_update			# Don't update the database?
     );
@@ -27,4 +28,5 @@
     'class_id|i=s'  => \$classId,
     'uri|u=s'       => \$input,
+    'camera|c=s'    => \$camera,
     'no-update'     => \$no_update
 ) or pod2usage( 2 );
@@ -32,9 +34,12 @@
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
 pod2usage(
-    -msg => "Required options: --exp_tag --class_id --uri",
+    -msg => "Required options: --exp_tag --class_id --uri --camera",
     -exitval => 3,
 ) unless defined $expTag 
     and defined $classId 
-    and defined $input;
+    and defined $input
+    and defined $camera;
+
+$ipprc->define_camera($camera);
 
 # Look for programs we need
@@ -49,8 +54,8 @@
 $outputRoot = File::Spec->rel2abs( File::Spec->catpath( $vol, $dir, $outputRoot ), $ipprc->workdir() );
 $input = File::Spec->rel2abs( $input, $ipprc->workdir() );
-my $outputImage = $outputRoot  . '.' . $classId . '.fits';
+my $outputImage = $ipprc->filename("PPIMAGE.OUTPUT", $outputRoot, $classId);
+my $outputBin1 = $ipprc->filename("PPIMAGE.BIN1", $outputRoot, $classId);
+my $outputBin2 = $ipprc->filename("PPIMAGE.BIN2", $outputRoot, $classId);
 my $outputStats = $outputRoot  . '.' . $classId . '.stats';
-my $outputBin1Name = $outputRoot . '.' . $classId . '.b1.fits';
-my $outputBin2Name = $outputRoot . '.' . $classId . '.b2.fits';
 
 # Run ppImage
@@ -62,6 +67,6 @@
     die "Unable to perform ppImage on $input: $error_code\n" if not $success;
     die "Couldn't find expected output file: $outputImage\n" if not -f $outputImage;
-    die "Couldn't find expected output file: $outputBin1Name\n" if not -f $outputBin1Name;
-    die "Couldn't find expected output file: $outputBin2Name\n" if not -f $outputBin2Name;
+    die "Couldn't find expected output file: $outputBin1\n" if not -f $outputBin1;
+    die "Couldn't find expected output file: $outputBin2\n" if not -f $outputBin2;
     die "Couldn't find expected output file: $outputStats\n" if not -f $outputStats;
 }
@@ -83,6 +88,6 @@
 # Add the processed file to the database
 $outputImage = File::Spec->abs2rel( $outputImage, $ipprc->workdir() );
-$outputBin1Name = File::Spec->abs2rel( $outputBin1Name, $ipprc->workdir() );
-$outputBin2Name = File::Spec->abs2rel( $outputBin2Name, $ipprc->workdir() );
+$outputBin1 = File::Spec->abs2rel( $outputBin1, $ipprc->workdir() );
+$outputBin2 = File::Spec->abs2rel( $outputBin2, $ipprc->workdir() );
 unless ($no_update) {
     # Command to run dettool
@@ -92,6 +97,6 @@
     $command .= " -recip " . RECIPE;
     $command .= " -uri $outputImage";
-    $command .= " -b1_uri $outputBin1Name";
-    $command .= " -b2_uri $outputBin2Name";
+    $command .= " -b1_uri $outputBin1";
+    $command .= " -b2_uri $outputBin2";
     $command .= " -bg " . $stats->bg_mean();
     $command .= " -bg_stdev " . $stats->bg_stdev();
Index: /trunk/ippScripts/scripts/phase3.pl
===================================================================
--- /trunk/ippScripts/scripts/phase3.pl	(revision 9891)
+++ /trunk/ippScripts/scripts/phase3.pl	(revision 9892)
@@ -22,4 +22,5 @@
 GetOptions(
     'exp_tag|e=s'       => \$exp_tag,
+    'camera|c=s'        => \$camera,
     'no-update'         => \$no_update
 ) or pod2usage( 2 );
@@ -27,7 +28,10 @@
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
 pod2usage(
-    -msg => "Required options: --exp_tag",
+    -msg => "Required options: --exp_tag --camera",
     -exitval => 3,
-) unless defined $exp_tag;
+) unless defined $exp_tag
+    and defined $camera;
+
+$ipprc->define_camera($camera);
 
 use constant RECIPE1 => 'PPIMAGE_J1'; # Recipe to use for ppImage to make JPEGs
@@ -110,6 +114,6 @@
 
 # Output products --- need to synch with the camera configuration!
-my $jpeg1Name = $outputRoot . ".b1.jpg"; # Binned JPEG #1
-my $jpeg2Name = $outputRoot . ".b2.jpg"; # Binned JPEG #2
+my $jpeg1 = $ipprc->filename("PPIMAGE.JPEG1", $outputRoot); # Binned JPEG #1
+my $jpeg2 = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2
 
 # Make the jpeg for binning 1
@@ -118,5 +122,5 @@
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	run(command => $command, verbose => 1);
-    die "Unable to find expected output file: $jpeg1Name\n" if not -f $jpeg1Name;
+    die "Unable to find expected output file: $jpeg1\n" if not -f $jpeg1;
 }
 
@@ -126,5 +130,5 @@
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	run(command => $command, verbose => 1);
-    die "Unable to find expected output file: $jpeg2Name\n" if not -f $jpeg2Name;
+    die "Unable to find expected output file: $jpeg2\n" if not -f $jpeg2;
 }
 
@@ -132,9 +136,9 @@
 # Add the result into the database
 $outputRoot = File::Spec->abs2rel( $outputRoot, $ipprc->workdir() );
-$jpeg1Name  = File::Spec->abs2rel( $jpeg1Name, $ipprc->workdir() );
-$jpeg2Name  = File::Spec->abs2rel( $jpeg2Name, $ipprc->workdir() );
+$jpeg1  = File::Spec->abs2rel( $jpeg1, $ipprc->workdir() );
+$jpeg2  = File::Spec->abs2rel( $jpeg2, $ipprc->workdir() );
 unless ($no_update) {
     my $command = "$p3tool -addprocessedexp -exp_tag $exp_tag -uri UNKNOWN " .
-	"-recip " . RECIPE1() . "," . RECIPE2() . " -b1_uri $jpeg1Name -b2_uri $jpeg2Name " .
+	"-recip " . RECIPE1() . "," . RECIPE2() . " -b1_uri $jpeg1 -b2_uri $jpeg2 " .
 	"-bg $bg -bg_stdev $bg_stdev -bg_mean_stdev $bg_mean_stdev " .
 	"-sigma_ra 0.0 -sigma_dec 0.0 -nastro 0 -zp_mean 0.0 -zp_stdev 0.0"; # Command to run
