Index: trunk/ippScripts/scripts/diff_skycell.pl
===================================================================
--- trunk/ippScripts/scripts/diff_skycell.pl	(revision 23435)
+++ trunk/ippScripts/scripts/diff_skycell.pl	(revision 23438)
@@ -95,4 +95,6 @@
 my $tess_id;                    # Tesselation identifier
 my $camera;                     # Camera
+my $magicked_0;
+my $magicked_1;
 foreach my $file (@$files) {
     if (defined $file->{template} and $file->{template}) {
@@ -103,4 +105,6 @@
             $templateVariance = "PPSTACK.OUTPUT.VARIANCE";
             $templateSources = "PSPHOT.OUT.CMF.MEF";  ## this must be consistent with the value in stack_skycell.pl:161
+            # template is a stack so it doesn't need to be magicked
+            $magicked_1 = 1;
             ## use an explicit stack name for psphot output objects
         } else {
@@ -108,8 +112,10 @@
             $templateVariance = "PSWARP.OUTPUT.VARIANCE";
             $templateSources = "PSWARP.OUTPUT.SOURCES";
+            $magicked_1 = $file->{magicked};
         }
     } else {
         $input = $file->{uri};
         $inputPath = $file->{path_base};
+        $magicked_0 = $file->{magicked};    # if input is a stack the output can't be "magicked"
         if ($file->{warp_id} == 0) {
             $inputMask = "PPSTACK.OUTPUT.MASK";
@@ -146,4 +152,11 @@
 &my_die("Unable to identify camera", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless defined $camera;
 $ipprc->define_camera($camera);
+
+# Compute the magicked status of the output.
+# The output file will be considered magicked if the input has been magicked and the
+# template is either a stack or a warp that has been magicked.
+# note that difftool -inputskyfile outputs the magicked boolean as an int not T or F
+# because the output is constructed from a union of two selects
+my $magicked = $magicked_0 && $magicked_1;
 
 # Recipes to use based on reduction class
@@ -265,4 +278,5 @@
         my $command = "$difftool -adddiffskyfile -diff_id $diff_id -skycell_id $skycell_id -uri $outputName -path_base $outroot";
         $command .= " $cmdflags";
+        $command .= " -magicked" if $magicked;
         $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400));
         $command .= " -hostname $host" if defined $host;
