IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 15, 2007, 2:23:33 PM (19 years ago)
Author:
Paul Price
Message:

Adding --no-op option which turns off processing (so one can track only the database work flow) for everything except the phase 0 scripts (need to have some real data in the database in order to track it).

File:
1 edited

Legend:

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

    r11830 r11837  
    3333use Pod::Usage qw( pod2usage );
    3434
    35 my ($p5_id, $camera, $dbname, $workdir, $no_update);
     35my ($p5_id, $camera, $dbname, $workdir, $no_update, $no_op);
    3636GetOptions(
    3737    'p5_id|d=s'         => \$p5_id, # Phase 5 identifier
     
    3939    'dbname|d=s'        => \$dbname, # Database name
    4040    'workdir|w=s'       => \$workdir,   # Working directory, for output files
    41     'no-update'         => \$no_update,
     41    'no-update'         => \$no_update, # Don't update the database?
     42    'no-op'             => \$no_op, # Don't do any operations?
    4243) or pod2usage( 2 );
    4344
     
    6162
    6263# Get list of components for subtraction
     64my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    6365my $files;
    6466{
    65     my $command = "$p5tool -inputscfile -p5_id $p4_id";
     67    my $command = "$p5tool -inputscfile -p5_id $p5_id";
    6668    $command .= " -dbname $dbname" if defined $dbname;
    6769    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    116118
    117119my $outputName = $outputRoot . ".fits";
    118 # my $bin1Name =  $ipprc->filename("PPIMAGE.BIN1", $outputRoot, $class_id);
    119 # my $bin2Name =  $ipprc->filename("PPIMAGE.BIN2", $outputRoot, $class_id);
    120 # my $outputStats = $outputRoot . '.stats';
     120my $bin1Name =  $ipprc->filename("PPIMAGE.BIN1", $outputRoot);
     121my $bin2Name =  $ipprc->filename("PPIMAGE.BIN2", $outputRoot);
     122my $outputStats = $outputRoot . '.stats';
    121123
    122124# Perform subtraction
    123 {
     125my $stats = PS::IPP::Metadata::Stats->new(); # Stats parser
     126unless ($no_op) {
    124127    my $command = "$pois $template $input $outputName"; # Command to run pois
    125128
     
    134137#    &my_die("Couldn't find expected output file: $bin2Name",    $p5_id, $PS_EXIT_SYS_ERROR) unless -f $bin2Name;
    135138#    &my_die("Couldn't find expected output file: $outputStats", $p5_id, $PS_EXIT_SYS_ERROR) unless -f $outputStats;
    136 }
    137 
    138 # Get the statistics on the residual image
    139 if (0) { ### Disabled because pois doesn't output stats yet
    140     my $stats;                  # Statistics from ppImage
    141     {
     139
     140    # Get the statistics on the residual image
     141    if (0) { ### Disabled because pois doesn't output stats yet
    142142        my $statsFile;          # File handle
    143         open $statsFile, $outputStats or &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR);
     143        open $statsFile, $outputStats or &my_die("Can't open statistics file $outputStats: $!", $p5_id, $PS_EXIT_SYS_ERROR);
    144144        my @contents = <$statsFile>; # Contents of file
    145     close $statsFile;
    146         my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
     145        close $statsFile;
    147146        my $metadata = $mdcParser->parse(join "", @contents) or
    148             &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR);
    149         $stats = PS::IPP::Metadata::Stats->new(); # Stats parser
    150         $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR);
     147            &my_die("Unable to parse metadata config doc", $p5_id, $PS_EXIT_PROG_ERROR);
     148        $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $p5_id, $PS_EXIT_PROG_ERROR);
    151149    }
    152150}
     
    154152# Add the processed file to the database
    155153$outputName = $ipprc->convert_filename_relative( $outputName );
     154
     155my $bg = ($stats->bg_mean() or 'NAN');
     156my $bg_stdev = ($stats->bg_stdev() or 'NAN');
     157
    156158unless ($no_update) {
    157159
    158160    # Add the subtraction result
    159161    {
    160         my $command = "$p5tool -adddiffscfile -p5_id $p5_id -uri $outputName -b1_uri $outputRoot"; # Command to run p5tool
     162        my $command = "$p5tool -adddiffscfile -p5_id $p5_id -uri $outputName -b1_uri $outputRoot";
     163        $command .= " -bg $bg -bg_stdev $bg_stdev";
    161164        $command .= " -dbname $dbname" if defined $dbname;
    162        
    163         if (0) { ### Disabled because no statistics yet
    164             $command .= " -bg " . $stats->bg_mean();
    165             $command .= " -bg_stdev " . $stats->bg_stdev();
    166         }
    167165       
    168166        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    170168        unless ($success) {
    171169            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    172             &my_die("Unable to perform p5tool -adddiffscfile: $error_code", $p5_id, $iter, $exp_tag, $class_id, $error_code);
     170            &my_die("Unable to perform p5tool -adddiffscfile: $error_code", $p5_id, $error_code);
    173171        }
    174172       
     
    199197
    200198    warn($msg);
    201     if ($det_id and $iter and $exp_tag and not $no_update) {
     199    if ($p5_id and not $no_update) {
    202200        my $command = "$p5tool -updaterun -p5_id $p5_id -state stop -code $exit_code";
    203201        $command .= " -dbname $dbname" if defined $dbname;
Note: See TracChangeset for help on using the changeset viewer.