Index: trunk/ippScripts/scripts/camera_exp.pl
===================================================================
--- trunk/ippScripts/scripts/camera_exp.pl	(revision 42388)
+++ trunk/ippScripts/scripts/camera_exp.pl	(revision 42986)
@@ -110,4 +110,6 @@
 &my_die("Unrecognised JPEG recipe", $cam_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe2;
 
+my $recipe_jpeg = $ipprc->reduction($reduction, 'JPEG'); # Recipe to define colors and display scale
+
 #my $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR'); # Recipe to use
 #&my_die("Unrecognised ADDSTAR recipe", $cam_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_addstar;
@@ -139,4 +141,8 @@
 print "skip astrom: $skip_astrom\n"; 
 if ($skip_astrom) { print "skip the astrom\n"; }
+
+my $skip_bkg = metadataLookupBool($recipeData, 'PSASTRO.SKIP.BACKGROUND');
+
+print "skip bkg: $skip_bkg\n";
 
 my $cmdflags;
@@ -221,5 +227,5 @@
 
 my $do_stats;
-my $do_bkg;
+my $do_bkg = !$skip_bkg;
 my $do_jpegs;
 my $fpaStats; 
@@ -227,5 +233,5 @@
 if ($run_state eq 'new') {
     $do_stats = 1;
-    $do_bkg = 1;
+    # $do_bkg = 1;
     $do_jpegs = !$skip_binned;
     $fpaStats = prepare_output("PSASTRO.STATS",      $outroot, undef, 1);
@@ -235,5 +241,5 @@
     $do_stats = 0;
     $do_jpegs = 0;
-    $do_bkg = 1;        # we could skip this step if camProcessedExp.backgroun_model is non zero
+    # $do_bkg = 1;        # we could skip this step if camProcessedExp.backgroun_model is non zero
 
     if (!$do_masks) {
@@ -277,9 +283,16 @@
 my @bkg_models;                 # Names of output background models
 foreach my $file (@$files) {
+    # use the path_base as OUTPUT root and convert the filenames with ipprc->filename:
+    my $class_id = $file->{class_id};
+
+    # include all of the binned images for the full JPEG (even if quality is bad)
+    print $list1File ($ipprc->filename("PPIMAGE.BIN1", $file->{path_base}, $class_id) . "\n");
+    print $list2File ($ipprc->filename("PPIMAGE.BIN2", $file->{path_base}, $class_id) . "\n");
+
+    # optionally generate the background (gpc1 only)
+    print $list5File ($ipprc->filename("PSPHOT.BACKMDL", $file->{path_base}, $class_id) . "\n") if $do_bkg;
+
     # we perform astrometry iff photometry output exists
     next if $file->{quality} != 0;
-
-    # use the path_base as OUTPUT root and convert the filenames with ipprc->filename:
-    my $class_id = $file->{class_id};
 
     # If there is only one chip, we use this name for the input to addstar
@@ -288,9 +301,6 @@
     my $chipMask   = $ipprc->filename("PPIMAGE.CHIP.MASK", $file->{path_base}, $class_id);
     
-    print $list1File ($ipprc->filename("PPIMAGE.BIN1", $file->{path_base}, $class_id) . "\n");
-    print $list2File ($ipprc->filename("PPIMAGE.BIN2", $file->{path_base}, $class_id) . "\n");
     print $list3File ($chipObjects . "\n");
     print $list4File ($chipMask . "\n");
-    print $list5File ($ipprc->filename("PSPHOT.BACKMDL", $file->{path_base}, $class_id) . "\n");
 
     push @outMasks, prepare_output("PSASTRO.OUTPUT.MASK", $outroot, $class_id, 1) if $do_masks;
@@ -328,4 +338,5 @@
         my $command = "$ppImage -list $list1Name $outroot"; # Command to run
         $command .= " -recipe PPIMAGE $recipe1";
+        $command .= " -recipe JPEG $recipe_jpeg" if defined $recipe_jpeg; # if not defined, use the defaults
         $command .= " -dbname $dbname" if defined $dbname;
 
@@ -342,4 +353,5 @@
         $command = "$ppImage -list $list2Name $outroot"; # Command to run
         $command .= " -recipe PPIMAGE $recipe2";
+        $command .= " -recipe JPEG $recipe_jpeg" if defined $recipe_jpeg; # if not defined, use the defaults
         $command .= " -dbname $dbname" if defined $dbname;
 
@@ -419,5 +431,5 @@
     # Construct FPA continuity corrected background images
     # if (($camera =~ /ISP/)||($camera =~ /HSC/)||($camera =~ /gpc2/i)) {
-    if ($camera =~ /gpc1/i) {
+    if ($do_bkg && ($camera =~ /gpc1/i)) {
 	print "Generating FPA continuity corrected background images for GPC1 only\n";
 	my $command;
