Index: trunk/ippScripts/scripts/chip_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/chip_imfile.pl	(revision 19560)
+++ trunk/ippScripts/scripts/chip_imfile.pl	(revision 19932)
@@ -11,4 +11,7 @@
 print "Starting script $0 on $host\n\n";
 
+use DateTime;
+my $mjd_start = DateTime->now->mjd;   # MJD of starting script
+
 use vars qw( $VERSION );
 $VERSION = '0.01';
@@ -28,17 +31,17 @@
      $no_update, $no_op, $redirect );
 GetOptions(
-    'exp_id=s'      	=> \$exp_id,    # Exposure identifier
-    'chip_id=s'     	=> \$chip_id,   # Chiptool identifier
-    'class_id=s'    	=> \$class_id,  # Class identifier
-    'uri|u=s'       	=> \$uri,       # Input FITS file
-    'camera|c=s'    	=> \$camera,    # Camera
-    'outroot|w=s'   	=> \$outroot,   # output file base name
-    'dbname|d=s'    	=> \$dbname,    # Database name
-    'reduction=s'   	=> \$reduction, # Reduction class
+    'exp_id=s'          => \$exp_id,    # Exposure identifier
+    'chip_id=s'         => \$chip_id,   # Chiptool identifier
+    'class_id=s'        => \$class_id,  # Class identifier
+    'uri|u=s'           => \$uri,       # Input FITS file
+    'camera|c=s'        => \$camera,    # Camera
+    'outroot|w=s'       => \$outroot,   # output file base name
+    'dbname|d=s'        => \$dbname,    # Database name
+    'reduction=s'       => \$reduction, # Reduction class
     'run-state=s'       => \$run_state, # current state of the run (new, update)
-    'threads=s'       	=> \$threads,   # Number of threads to use for ppImage
-    'verbose'       	=> \$verbose,   # Print to stdout
-    'no-update'     	=> \$no_update, # Don't update the database?
-    'no-op'         	=> \$no_op,     # Don't do any operations?
+    'threads=s'         => \$threads,   # Number of threads to use for ppImage
+    'verbose'           => \$verbose,   # Print to stdout
+    'no-update'         => \$no_update, # Don't update the database?
+    'no-op'             => \$no_op,     # Don't do any operations?
     'redirect-output'   => \$redirect,
     ) or pod2usage( 2 );
@@ -73,6 +76,4 @@
 # values to extract from output metadata and the stats to calculate
 # XXX commented-out entries are not yet defined in the output files
-# XXX EAM : we are removing the astrometry analysis from chip, so we
-# do not bother to calculate those stats.
 my $STATS =
    [
@@ -86,19 +87,14 @@
        { name => "FRINGE_RESID_0", type => "rms",   flag => "-fringe_1",       dtype => "float" },
        { name => "FRINGE_ERR_0",   type => "rms",   flag => "-fringe_2",       dtype => "float" },
-#      { name => "CERROR",         type => "rms",   flag => "-sigma_ra",       dtype => "float" },
-#      { name => "CERROR",         type => "rms",   flag => "-sigma_dec",      dtype => "float" },
        { name => "APMIFIT",        type => "mean",  flag => "-ap_resid",       dtype => "float" },
        { name => "DAPMIFIT",       type => "rms",   flag => "-ap_resid_stdev", dtype => "float" },
-#      { name => "ZP??",           type => "mean",  flag => "-zp_mean",        dtype => "float" },
-#      { name => "ZP??",           type => "rms",   flag => "-zp_stdev",       dtype => "float" },
        { name => "FWHM_X",         type => "mean",  flag => "-fwhm_major",     dtype => "float" },
        { name => "FWHM_Y",         type => "mean",  flag => "-fwhm_minor",     dtype => "float" },
        { name => "DT_DET",         type => "sum",   flag => "-dtime_detrend",  dtype => "float" },
        { name => "DT_PHOT",        type => "sum",   flag => "-dtime_photom",   dtype => "float" },
-#       { name => "DT_ASTR",        type => "sum",   flag => "-dtime_astrom",   dtype => "float" },
+       { name => "DT_TOTAL",       type => "sum",   flag => "-dtime_total",    dtype => "float" },
        { name => "NSTARS",         type => "sum",   flag => "-n_stars",        dtype => "int"   },
 #      { name => "?",              type => "sum",   flag => "-n_extended",     dtype => "int"   },
 #      { name => "?",              type => "sum",   flag => "-n_cr",           dtype => "int"   },
-#      { name => "NASTRO",         type => "sum",   flag => "-n_astrom",       dtype => "int"   },
    ];
 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser
@@ -149,22 +145,22 @@
 
     if ($run_state eq "new") {
-	$command  = "$ppImage -file $uri $outroot";
-	$command .= " -recipe PPIMAGE $recipe";
-	$command .= " -threads $threads" if defined $threads;
-	$command .= " -dbname $dbname" if defined $dbname;
+        $command  = "$ppImage -file $uri $outroot";
+        $command .= " -recipe PPIMAGE $recipe";
+        $command .= " -threads $threads" if defined $threads;
+        $command .= " -dbname $dbname" if defined $dbname;
         $command .= " -dumpconfig $configuration";
-	$command .= " -tracedest $traceDest -log $logDest";
+        $command .= " -tracedest $traceDest -log $logDest";
         $do_stats = 1;
     } else {
-	$command  = "$ppImage -file $uri $outroot";
-	$command .= " -ipprc $configuration";
-	$command .= " -threads $threads" if defined $threads;
-	$command .= " -dbname $dbname" if defined $dbname;
-	$command .= " -tracedest $traceDest -log $logDest";
-	$command .= " -Db PPIMAGE:PHOTOM FALSE";
+        $command  = "$ppImage -file $uri $outroot";
+        $command .= " -ipprc $configuration";
+        $command .= " -threads $threads" if defined $threads;
+        $command .= " -dbname $dbname" if defined $dbname;
+        $command .= " -tracedest $traceDest -log $logDest";
+        $command .= " -Db PPIMAGE:PHOTOM FALSE";
     }
     if ($do_stats) {
-	$command .= " -recipe PPSTATS CHIPSTATS";
-	$command .= " -stats $outputStats";
+        $command .= " -recipe PPSTATS CHIPSTATS";
+        $command .= " -stats $outputStats";
     }
 
@@ -241,4 +237,5 @@
     $command .= " -dbname $dbname" if defined $dbname;
     $command .= $stats->cmdflags();
+    $command .= (" -dtime_script " . (($mjd_start - DateTime->now->mjd) * 86400));
 } else {
     $command = "$chiptool -tofullimfile";
@@ -279,4 +276,5 @@
             $command .= " -path_base $outroot";
             $command .= " -hostname $host" if defined $host;
+            $command .= (" -dtime_script " . (($mjd_start - DateTime->now->mjd) * 86400));
         } else {
             $command .= "$chiptool -updateprocessedimfile";
