Index: /tags/ipp-ops-20220906/ippScripts/scripts/camera_exp.pl
===================================================================
--- /tags/ipp-ops-20220906/ippScripts/scripts/camera_exp.pl	(revision 43111)
+++ /tags/ipp-ops-20220906/ippScripts/scripts/camera_exp.pl	(revision 43112)
@@ -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;
@@ -132,4 +134,15 @@
         &my_die("Unable to parse metadata config doc", $cam_id, $PS_EXIT_CONFIG_ERROR);
 }
+
+## option to skip the astrometry analysis (but still do the jpegs)
+## if not defined in the config file, default is to not skip
+my $skip_astrom = 0;
+$skip_astrom = metadataLookupBool($recipeData, 'PSASTRO.SKIP.ASTROMETRY');
+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;
@@ -183,12 +196,16 @@
         ($expFWHM) = $cmdflags =~ /-fwhm_major (\d+)/;	
         
-        if ($expFWHM > $maxFWHM) {
+	if (not defined $expFWHM) {
+	    print "FWHM not measured (no photometry?), Setting quality to 4077\n";
+            $cmdflags .= " -quality 4077 "; # This corresponds to PSASTRO_ERR_DATA
+            $skip_astrom = 1;
+	} elsif ($expFWHM > $maxFWHM) {
             print "Setting quality to 4007 due to large FWHM: exposure: $expFWHM  maximum: $maxFWHM\n";
             $cmdflags .= " -quality 4007 "; # This corresponds to PSASTRO_ERR_DATA
-            $no_op = 1;
-        }
-    }
-}
-
+            # $no_op = 1;
+            $skip_astrom = 1; # skip astrometry, but make the jpegs
+        }
+    }
+}
 
 my $do_masks;               # Produce masks?
@@ -210,5 +227,5 @@
 
 my $do_stats;
-my $do_bkg;
+my $do_bkg = !$skip_bkg;
 my $do_jpegs;
 my $fpaStats; 
@@ -216,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);
@@ -224,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) {
@@ -266,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
@@ -277,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;
@@ -297,5 +318,5 @@
 my $jpeg1      = prepare_output("PPIMAGE.JPEG1",      $outroot, undef, 1) if $do_jpegs;
 my $jpeg2      = prepare_output("PPIMAGE.JPEG2",      $outroot, undef, 1) if $do_jpegs;
-my $fpaObjects = prepare_output("PSASTRO.OUTPUT",     $outroot, undef, 1) if !$bkg_only;
+my $fpaObjects = prepare_output("PSASTRO.OUTPUT",     $outroot, undef, 1) if (!$bkg_only && !$skip_astrom);
 
 my $configuration;
@@ -317,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;
 
@@ -331,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;
 
@@ -342,5 +365,5 @@
     }
 
-    if (!$bkg_only) {
+    if (!$bkg_only && !$skip_astrom) {
         # run psastro on the chipObjects, producing fpaObjects
         my $command;
@@ -408,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;
