IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 6, 2008, 2:03:10 PM (18 years ago)
Author:
Paul Price
Message:

Adding dtime_script calculation. Updating the database tables.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/fake_imfile.pl

    r18562 r19932  
    22
    33## this script is run on every imfile to perform the fake source
    4 ## analysis and the forced photometry analysis. 
     4## analysis and the forced photometry analysis.
    55
    66## For the fake source analysis, we load the image, inject a number of
     
    1212
    1313## For the forced photometry, we need to use the measured astrometry
    14 ## to select the desired locations in pixel coord. 
     14## to select the desired locations in pixel coord.
    1515
    1616# XXX : seeing needs to be determined from the input PSF (not currently done in ppSim)
     
    2727print "Starting script $0 on $host\n\n";
    2828
     29use DateTime;
     30my $mjd_start = DateTime->now->mjd;   # MJD of starting script
     31
    2932use vars qw( $VERSION );
    3033$VERSION = '0.01';
     
    4144
    4245# Parse the command-line arguments
    43 my ( $exp_id, $fake_id, $class_id, $chiproot, $camroot, $camera, $outroot, 
     46my ( $exp_id, $fake_id, $class_id, $chiproot, $camroot, $camera, $outroot,
    4447     $dbname, $reduction, $verbose, $no_update, $no_op, $redirect  );
    4548GetOptions(
    46     'exp_id=s'          => \$exp_id,    # Exposure identifier
    47     'fake_id=s'         => \$fake_id,   # Chiptool identifier
    48     'class_id=s'        => \$class_id,  # Class identifier
    49     'chiproot=s'        => \$chiproot,  # Input Chip files (root)
    50     'camroot=s'         => \$camroot,   # Input Camera files (root)
    51     'camera|c=s'        => \$camera,       # Camera
    52     'outroot|w=s'       => \$outroot,   # output file base name
    53     'dbname|d=s'        => \$dbname,    # Database name
    54     'reduction=s'       => \$reduction, # Reduction class
    55     'verbose'           => \$verbose,   # Print to stdout
    56     'no-update'         => \$no_update, # Don't update the database?
    57     'no-op'             => \$no_op,        # Don't do any operations?
     49    'exp_id=s'          => \$exp_id,    # Exposure identifier
     50    'fake_id=s'         => \$fake_id,   # Chiptool identifier
     51    'class_id=s'        => \$class_id,  # Class identifier
     52    'chiproot=s'        => \$chiproot,  # Input Chip files (root)
     53    'camroot=s'         => \$camroot,   # Input Camera files (root)
     54    'camera|c=s'        => \$camera,       # Camera
     55    'outroot|w=s'       => \$outroot,   # output file base name
     56    'dbname|d=s'        => \$dbname,    # Database name
     57    'reduction=s'       => \$reduction, # Reduction class
     58    'verbose'           => \$verbose,   # Print to stdout
     59    'no-update'         => \$no_update, # Don't update the database?
     60    'no-op'             => \$no_op,        # Don't do any operations?
    5861    'redirect-output'   => \$redirect,
    5962    ) or pod2usage( 2 );
     
    6164pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    6265pod2usage( -msg => "Required options: --exp_id --fake_id --class_id --chiproot --camroot --camera --outroot",
    63            -exitval => 3) unless
     66           -exitval => 3) unless
    6467    defined $exp_id and
    6568    defined $fake_id and
     
    104107}
    105108
    106 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
     109my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    107110
    108111# outroot examples (HOST components must be set)
     
    120123my $chipPSF       = $ipprc->filename("PSPHOT.PSF.SAVE",     $chiproot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $fake_id, $class_id, $PS_EXIT_CONFIG_ERROR);
    121124my $cameraObjects = $ipprc->filename("PSASTRO.OUTPUT",      $camroot)             or &my_die("Missing entry from camera config", $exp_id, $fake_id, $class_id, $PS_EXIT_CONFIG_ERROR);
    122 my $traceDest     = $ipprc->filename("TRACE.IMFILE",        $outroot, $class_id)  or &my_die("Missing entry from camera config", $exp_id, $fake_id, $class_id, $PS_EXIT_CONFIG_ERROR);
     125my $traceDest     = $ipprc->filename("TRACE.IMFILE",        $outroot, $class_id)  or &my_die("Missing entry from camera config", $exp_id, $fake_id, $class_id, $PS_EXIT_CONFIG_ERROR);
    123126
    124127# XXX check for existence of input data
     
    128131my $command = "$ppConfigDump -camera $camera -dump-recipe PPSIM -recipe PPSIM $recipe -";
    129132my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    130         run(command => $command, verbose => $verbose);
     133        run(command => $command, verbose => $verbose);
    131134unless ($success) {
    132         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    133         &my_die("Unable to perform ppConfigDump: $error_code", $exp_id, $fake_id, $class_id, $PS_EXIT_SYS_ERROR);
     135        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     136        &my_die("Unable to perform ppConfigDump: $error_code", $exp_id, $fake_id, $class_id, $PS_EXIT_SYS_ERROR);
    134137}
    135138my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or
    136         &my_die("Unable to parse metadata config doc", $exp_id, $fake_id, $class_id, $PS_EXIT_SYS_ERROR);
     139        &my_die("Unable to parse metadata config doc", $exp_id, $fake_id, $class_id, $PS_EXIT_SYS_ERROR);
    137140
    138141## allow the output images to be optional, depending on the recipe / reduction class
     
    156159
    157160    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    158         run(command => $command, verbose => $verbose);
     161        run(command => $command, verbose => $verbose);
    159162    unless ($success) {
    160         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    161         &my_die("Unable to perform ppSim: $error_code", $exp_id, $fake_id, $class_id, $error_code);
     163        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     164        &my_die("Unable to perform ppSim: $error_code", $exp_id, $fake_id, $class_id, $error_code);
    162165    }
    163166
     
    167170    # XXX use this to parse the output metadata : eg, detection limits, Nfakes, Nforced
    168171    # Get the statistics on the processed image
    169     # my $statsFile;            # File handle
     172    # my $statsFile;            # File handle
    170173    # open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $exp_id, $fake_id, $class_id, $PS_EXIT_SYS_ERROR);
    171174    # my @contents = <$statsFile>; # Contents of file
    172175    # close $statsFile;
    173     # 
     176    #
    174177    # # parse the statistics MDC file
    175     # my $mdcParser = PS::IPP::Metadata::Config->new(); # Parser for metadata config files
     178    # my $mdcParser = PS::IPP::Metadata::Config->new(); # Parser for metadata config files
    176179    # my $metadata = $mdcParser->parse(join "", @contents);
    177180    # unless ($metadata) {
    178     #   &my_die("Unable to parse metadata config doc", $exp_id, $fake_id, $class_id, $PS_EXIT_PROG_ERROR);
     181    #   &my_die("Unable to parse metadata config doc", $exp_id, $fake_id, $class_id, $PS_EXIT_PROG_ERROR);
    179182    # }
    180     # 
     183    #
    181184    # # extract the stats from the metadata
    182185    # unless ($stats->parse($metadata)) {
    183     #   &my_die("Failure extracting metadata from the statistics output file.\n", $exp_id, $fake_id, $class_id, $PS_EXIT_PROG_ERROR);
     186    #   &my_die("Failure extracting metadata from the statistics output file.\n", $exp_id, $fake_id, $class_id, $PS_EXIT_PROG_ERROR);
    184187    # }
    185188} else {
     
    194197$command .= " -path_base $outroot";
    195198$command .= " -dbname $dbname" if defined $dbname;
     199$command .= (" -dtime_script " . (($mjd_start - DateTime->now->mjd) * 86400));
    196200# XXX add this after defined
    197201# $command .= $stats->cmdflags();
     
    200204unless ($no_update) {
    201205    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    202         run(command => $command, verbose => $verbose);
     206        run(command => $command, verbose => $verbose);
    203207    unless ($success) {
    204         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    205         warn("Unable to perform faketool -addprocessedimfile: $error_code\n");
    206         exit($error_code);
     208        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     209        warn("Unable to perform faketool -addprocessedimfile: $error_code\n");
     210        exit($error_code);
    207211    }
    208212} else {
     
    220224    carp($msg);
    221225    if (defined $exp_id and defined $fake_id and defined $class_id and not $no_update) {
    222         my $command = "$faketool -addprocessedimfile";
    223         $command .= " -fake_id $fake_id";
    224         $command .= " -exp_id $exp_id";
    225         $command .= " -class_id $class_id";
    226         $command .= " -path_base $outroot";
    227         $command .= " -code $exit_code";
    228         $command .= " -dbname $dbname" if defined $dbname;
     226        my $command = "$faketool -addprocessedimfile";
     227        $command .= " -fake_id $fake_id";
     228        $command .= " -exp_id $exp_id";
     229        $command .= " -class_id $class_id";
     230        $command .= " -path_base $outroot";
     231        $command .= (" -dtime_script " . (($mjd_start - DateTime->now->mjd) * 86400));
     232        $command .= " -code $exit_code";
     233        $command .= " -dbname $dbname" if defined $dbname;
    229234        system ($command);
    230235    }
Note: See TracChangeset for help on using the changeset viewer.