Index: /branches/eam_branches/ipp-20211108/ippScripts/scripts/stack_skycell.pl
===================================================================
--- /branches/eam_branches/ipp-20211108/ippScripts/scripts/stack_skycell.pl	(revision 41949)
+++ /branches/eam_branches/ipp-20211108/ippScripts/scripts/stack_skycell.pl	(revision 41950)
@@ -209,8 +209,12 @@
 my $output_nocomp = metadataLookupBool($recipe, 'OUTPUT.NOCOMP'); # change filerules to produced uncompressed output images
 my $output_logflux = metadataLookupBool($recipe, 'OUTPUT.LOGFLUX'); # change filerules to produce logflux compressed output images.
+my $output_deepexp = metadataLookupBool($recipe, 'OUTPUT.DEEPEXP'); # change filerules to produce exptime map with more depth
 my $replicate_outputs = (defined($neb) and metadataLookupBool($recipe, 'OUTPUT.REPLICATE')); # replicate output images
 my $skip_missing_inputs = metadataLookupBool($recipe, 'SKIP.MISSING.INPUTS'); # ignore missing inputs 
 if ($output_nocomp and $output_logflux) {
     &my_die("Unable to not compress and logflux compress simultaneously. Check config.",$stack_id, $PS_EXIT_CONFIG_ERROR);
+}
+if ($output_nocomp and $output_deepexp) {
+    &my_die("Unable to not compress and use deepexp simultaneously. Check config.",$stack_id, $PS_EXIT_CONFIG_ERROR);
 }
 my $stack_type = metadataLookupStr($recipe, 'STACK.TYPE');
@@ -225,8 +229,5 @@
     if ($file->{ignored}) { next; }
 
-    print $listFile "INPUT$num\tMETADATA\n";
-    $num++;
-
-    # select the input files
+    # check for the input files
     my $image    = $ipprc->filename("PSWARP.OUTPUT", $file->{path_base} ); # Image name
     my $mask     = $ipprc->filename( "PSWARP.OUTPUT.MASK", $file->{path_base} ); # Mask name
@@ -240,14 +241,15 @@
     my $have_weight  = $ipprc->file_exists( $weight );
     my $have_sources = $ipprc->file_exists( $sources );
-    my $have_psf     = $convolve and $ipprc->file_exists( $psf );
+    my $have_psf;
+    if ($convolve) { $have_psf = $ipprc->file_exists( $psf ); }
 
     if ($skip_missing_inputs) {
-	my $missing_inputs = false;
-	unless ($have_image)  { print "WARNING: MISSING INPUT $input  \n"; $missing_inputs = true; }
-	unless ($have_mask)   { print "WARNING: MISSING INPUT $mask   \n"; $missing_inputs = true; }
-	unless ($have_weight) { print "WARNING: MISSING INPUT $weight \n"; $missing_inputs = true; }
-	unless ($have_sources){ print "WARNING: MISSING INPUT $sources\n"; $missing_inputs = true; }
-	if ($convolve) { unless ($have_psf) { print "WARNING: MISSING INPUT $psf\n"; $missing_inputs = true;}}
-	if ($missing_input) { next; }
+	my $missing_inputs = 0;
+	unless ($have_image)  { print "WARNING: MISSING INPUT $image  \n"; $missing_inputs = 1; }
+	unless ($have_mask)   { print "WARNING: MISSING INPUT $mask   \n"; $missing_inputs = 1; }
+	unless ($have_weight) { print "WARNING: MISSING INPUT $weight \n"; $missing_inputs = 1; }
+	unless ($have_sources){ print "WARNING: MISSING INPUT $sources\n"; $missing_inputs = 1; }
+	if ($convolve) { unless ($have_psf) { print "WARNING: MISSING INPUT $psf\n"; $missing_inputs = 1;}}
+	if ($missing_inputs) { next; }
     } else {
 	&my_die("Image $image does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $have_image;
@@ -258,4 +260,6 @@
     }
 
+    print $listFile "INPUT$num\tMETADATA\n";
+
     print $listFile "\tIMAGE\tSTR\t"    . $image    . "\n";
     print $listFile "\tMASK\tSTR\t"     . $mask     . "\n";
@@ -266,4 +270,5 @@
 
     print $listFile "END\n\n";
+    $num++;
 }
 close($listFile);
@@ -327,10 +332,14 @@
     }
     if ($output_logflux) {
-	$command .= " -R PPSTACK.OUTPUT FITS.TYPE COMP_STACK "; # Just this one output component?
-	$command .= " -R PPSTACK.OUTPUT.VARIANCE FITS.TYPE COMP_STACK "; 
-#	$command .= " -R PPSTACK.OUTPUT.EXPWT FITS.TYPE COMP_STACK ";
-	$command .= " -R PPSTACK.UNCONV FITS.TYPE COMP_STACK ";
-	$command .= " -R PPSTACK.UNCONV.VARIANCE FITS.TYPE COMP_STACK ";
-#	$command .= " -R PPSTACK.UNCONV.EXPWT FITS.TYPE COMP_STACK ";
+	$command .= " -R PPSTACK.OUTPUT          FITS.TYPE STK_UNIONS "; # Just this one output component?
+	$command .= " -R PPSTACK.OUTPUT.VARIANCE FITS.TYPE STK_UNIONS "; 
+        $command .= " -R PPSTACK.UNCONV          FITS.TYPE STK_UNIONS";
+	$command .= " -R PPSTACK.UNCONV.VARIANCE FITS.TYPE STK_UNIONS ";
+    }
+    # if the total exposure time is long (> 6500 sec), need to use
+    # a different compression options.
+    if ($output_deepexp) {
+	$command .= " -R PPSTACK.OUTPUT.EXP FITS.TYPE EXP_UNIONS ";
+	$command .= " -R PPSTACK.UNCONV.EXP FITS.TYPE EXP_UNIONS ";
     }
     $command .= " -threads $threads" if defined $threads;
