Changeset 11837 for trunk/ippScripts/scripts/phase5_subtract.pl
- Timestamp:
- Feb 15, 2007, 2:23:33 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/phase5_subtract.pl (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/phase5_subtract.pl
r11830 r11837 33 33 use Pod::Usage qw( pod2usage ); 34 34 35 my ($p5_id, $camera, $dbname, $workdir, $no_update );35 my ($p5_id, $camera, $dbname, $workdir, $no_update, $no_op); 36 36 GetOptions( 37 37 'p5_id|d=s' => \$p5_id, # Phase 5 identifier … … 39 39 'dbname|d=s' => \$dbname, # Database name 40 40 '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? 42 43 ) or pod2usage( 2 ); 43 44 … … 61 62 62 63 # Get list of components for subtraction 64 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 63 65 my $files; 64 66 { 65 my $command = "$p5tool -inputscfile -p5_id $p 4_id";67 my $command = "$p5tool -inputscfile -p5_id $p5_id"; 66 68 $command .= " -dbname $dbname" if defined $dbname; 67 69 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 116 118 117 119 my $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';120 my $bin1Name = $ipprc->filename("PPIMAGE.BIN1", $outputRoot); 121 my $bin2Name = $ipprc->filename("PPIMAGE.BIN2", $outputRoot); 122 my $outputStats = $outputRoot . '.stats'; 121 123 122 124 # Perform subtraction 123 { 125 my $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 126 unless ($no_op) { 124 127 my $command = "$pois $template $input $outputName"; # Command to run pois 125 128 … … 134 137 # &my_die("Couldn't find expected output file: $bin2Name", $p5_id, $PS_EXIT_SYS_ERROR) unless -f $bin2Name; 135 138 # &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 142 142 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); 144 144 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; 147 146 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); 151 149 } 152 150 } … … 154 152 # Add the processed file to the database 155 153 $outputName = $ipprc->convert_filename_relative( $outputName ); 154 155 my $bg = ($stats->bg_mean() or 'NAN'); 156 my $bg_stdev = ($stats->bg_stdev() or 'NAN'); 157 156 158 unless ($no_update) { 157 159 158 160 # Add the subtraction result 159 161 { 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"; 161 164 $command .= " -dbname $dbname" if defined $dbname; 162 163 if (0) { ### Disabled because no statistics yet164 $command .= " -bg " . $stats->bg_mean();165 $command .= " -bg_stdev " . $stats->bg_stdev();166 }167 165 168 166 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 170 168 unless ($success) { 171 169 $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); 173 171 } 174 172 … … 199 197 200 198 warn($msg); 201 if ($ det_id and $iter and $exp_tagand not $no_update) {199 if ($p5_id and not $no_update) { 202 200 my $command = "$p5tool -updaterun -p5_id $p5_id -state stop -code $exit_code"; 203 201 $command .= " -dbname $dbname" if defined $dbname;
Note:
See TracChangeset
for help on using the changeset viewer.
