Index: trunk/pstamp/scripts/pstamp_finish.pl
===================================================================
--- trunk/pstamp/scripts/pstamp_finish.pl	(revision 25957)
+++ trunk/pstamp/scripts/pstamp_finish.pl	(revision 26048)
@@ -208,6 +208,11 @@
 
                     # ra_deg and dec_deg are the coordinates of center of the stamp
+                    # first assume that the image is compressed and check the first extension.
+                    # If not found check the PHU. If that doesn't work just set them to zero.
                     # XXX do this more cleanly
-                    my (undef, $ra_deg, $dec_deg) = split " ", `echo $out_dir/$img_name | fields -x -1 RA_DEG DEC_DEG`;
+                    my (undef, $ra_deg, $dec_deg) = split " ", `echo $out_dir/$img_name | fields -x 0 RA_DEG DEC_DEG`;
+                    if (!defined $ra_deg) {
+                        (undef, $ra_deg, $dec_deg) = split " ", `echo $out_dir/$img_name | fields RA_DEG DEC_DEG`;
+                    }
                     $ra_deg = 0.0 if (!$ra_deg);
                     $dec_deg = 0.0 if (!$dec_deg);
@@ -372,5 +377,5 @@
     my $ra_deg   = $exp->{ra} * RADIANS_TO_DEGREES;
     my $decl_deg = $exp->{decl} * RADIANS_TO_DEGREES;
-    my $mjd_obs = dateobs_to_mjd($exp->{dateobs}, $exp->{exp_time});
+    my $mjd_obs = dateobs_to_mjd($exp->{dateobs});
 
     my $info = "$mjd_obs|$ra_deg|$decl_deg|$exp->{filter}|$exp->{exp_time}|$exp->{exp_name}";
@@ -381,5 +386,4 @@
 sub dateobs_to_mjd {
     my $dateobs = shift;
-    my $exp_time = shift;
 
     # dateobs is in format: 1970-01-01T00:00:00
@@ -391,6 +395,4 @@
     my $ticks = timegm($sec, $min, $hr, $day, $mon-1, $year-1900);
 
-    $ticks += $exp_time / 2.0;
-
     return 40587.0 + ($ticks/86400.);
 }
