Index: /trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm
===================================================================
--- /trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm	(revision 25128)
+++ /trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm	(revision 25129)
@@ -34,5 +34,5 @@
     my $req_type = shift;   # required
     my $img_type = shift;   # required
-    my $id       = shift;   # required unless req_type eq bycoord
+    my $id       = shift;   # required unless req_type eq bycoord or byskycell
     my $component= shift;   # class_id or skycell_id
     my $inverse  = shift;
@@ -63,5 +63,5 @@
             return undef;
         }
-        if (($img_type eq "warp") or ($img_type eq "diff")) {
+        if ($img_type eq "diff") {
             # lookup_diff has done all of the work
             return $results;
@@ -74,9 +74,14 @@
             return undef if !$id;
             # fall through and lookup byexp
+        } elsif ($img_type eq "warp") {
+            $req_type = "byid";
+            $id = $image->{warp_id};
+            return undef if !$id;
+            # fall through and lookup by warp_id
         } elsif ($img_type eq "stack") {
             $req_type = "byid";
             $id = $image->{stack_id};
             return undef if !$id;
-            # fall though and lookup by stack id
+            # fall though and lookup by stack_id
         } else {
             # shouldn't I check this elsewhere?
@@ -327,13 +332,17 @@
         }
 
-        my $warp_id;
+        my ($warp_id, $exp_id, $exp_name);
         if ($inverse and !$image->{bothways}) {
-            print STDERR "inverse image requested for diffRun that is not bothways ignoring\n";
+            print STDERR "Inverse images requested for diffRun that is not bothways. Ignoring.\n";
             $inverse = 0;
         }
         if ($inverse) {
             $warp_id =  $image->{warp2};
+            $exp_id = $image->{exp_id_2};
+            $exp_name = $image->{exp_name_2};
         } else {
             $warp_id =  $image->{warp1};
+            $exp_id = $image->{exp_id_1};
+            $exp_name = $image->{exp_name_1};
         }
         # XXX difftool currently returns max long long for null
@@ -341,52 +350,19 @@
         if ($warp_id and ($warp_id != 9223372036854775807)) {
             $image->{warp_id} = $warp_id;
-
-            ## now use the warp and go get the exposure information
-            $command = "warptool -warped -warp_id $warp_id -skycell_id $skycell_id -dbname $image_db -limit 1";
-            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-                        run(command => $command, verbose => $verbose);
-            unless ($success) {
-                # XXX: I'm not sure if we should die here
-                print STDERR @$stderr_buf;
-                return undef;
-            }
-
-            my $buf = join "", @$stdout_buf;
-            if (!$buf) {
-                next;
-            }
-
-            my $mdcParser = PS::IPP::Metadata::Config->new;
-            my $warps = parse_md_fast($mdcParser, $buf)
-                or die ("Unable to parse metadata config doc");
-            my $warp = $warps->[0];
-
-            if ($img_type eq "warp") {
-                $image = $warp;
-            } else {
-                $image->{exp_id} = $warp->{exp_id};
-                $image->{exp_name} = $warp->{exp_name};
-                $image->{camera} = $warp->{camera};
-            }
+            $image->{exp_id} = $exp_id;
+            $image->{exp_name} = $exp_name;
         } else {
             print STDERR "unexpected result warp_id not defined\n";
             next;
         }
-
-        if (($img_type eq "diff") or ($img_type eq "warp")) {
+        if ($img_type eq "diff") {
             # the $image is going to be returned directly in this case so we need to duplicate
             # some of processing that lookup does for other img_types
             if ($image->{camera}) {
                 $ipprc->define_camera($image->{camera});
-                if ($img_type eq "diff") {
-                    my $filerule_base = $inverse ? "PPSUB.INVERSE" : "PPSUB.OUTPUT";
-                    $image->{image}  = $ipprc->filename($filerule_base, $image->{path_base});
-                    $image->{mask}   = $ipprc->filename($filerule_base . ".MASK", $image->{path_base});
-                    $image->{weight} = $ipprc->filename($filerule_base . ".VARIANCE", $image->{path_base});
-                } else {
-                    $image->{image}  = $ipprc->filename("PSWARP.OUTPUT",   $image->{path_base});
-                    $image->{mask}   = $ipprc->filename("PSWARP.OUTPUT.MASK",   $image->{path_base});
-                    $image->{weight} = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $image->{path_base});
-                }
+                my $filerule_base = $inverse ? "PPSUB.INVERSE" : "PPSUB.OUTPUT";
+                $image->{image}  = $ipprc->filename($filerule_base, $image->{path_base});
+                $image->{mask}   = $ipprc->filename($filerule_base . ".MASK", $image->{path_base});
+                $image->{weight} = $ipprc->filename($filerule_base . ".VARIANCE", $image->{path_base});
             } else {
                 # XXX this will only happen if the minuend is not a warp
