Changeset 19942 for trunk/ippScripts/scripts/detrend_process_imfile.pl
- Timestamp:
- Oct 7, 2008, 9:56:11 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_process_imfile.pl
r19652 r19942 16 16 use IPC::Cmd 0.36 qw( can_run run ); 17 17 use PS::IPP::Metadata::Config; 18 use PS::IPP::Metadata::Stats;19 18 use PS::IPP::Config 1.01 qw( :standard ); 20 19 … … 68 67 my $jpeg_recipe = $ipprc->reduction($reduction, uc($det_type) . '_JPEG_IMAGE'); # Recipe name for JPEG 69 68 70 # values to extract from output metadata and the stats to calculate71 my $STATS =72 [73 # PPSTATS KEYWORD STATISTIC CHIPTOOL FLAG74 { name => "ROBUST_MEDIAN", type => "mean", flag => "-bg", dtype => "float" },75 { name => "ROBUST_MEDIAN", type => "stdev", flag => "-bg_mean_stdev", dtype => "float" },76 { name => "ROBUST_STDEV", type => "rms", flag => "-bg_stdev", dtype => "float" },77 ];78 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser79 80 69 # Look for programs we need 81 70 my $missing_tools; 82 71 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 83 72 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 73 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 84 74 if ($missing_tools) { 85 75 warn("Can't find required tools."); … … 97 87 $ipprc->outroot_prepare($outroot); 98 88 89 my $cmdflags; 90 99 91 my $outputImage = $ipprc->filename("PPIMAGE.OUTPUT", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 100 92 my $outputBin1 = $ipprc->filename("PPIMAGE.BIN1", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); … … 107 99 $command .= " -recipe PPIMAGE $ppimage_recipe"; 108 100 $command .= " -recipe JPEG $jpeg_recipe"; 109 $command .= " -recipe PPSTATS CHIPSTATS";101 $command .= " -recipe PPSTATS DETSTATS"; 110 102 $command .= " -stats $outputStats"; 111 103 $command .= " -tracedest $traceDest -log $logDest"; … … 121 113 122 114 &my_die("Couldn't find expected output file: $outputImage", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputImage); 123 &my_die("Couldn't find expected output file: $outputStats", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats);124 115 &my_die("Couldn't find expected output file: $outputBin1", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin1); 125 116 &my_die("Couldn't find expected output file: $outputBin2", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin2); 126 117 127 # Get the statistics on the processed image 128 my $statsFile; # File handle 129 open $statsFile, $ipprc->file_resolve("$outputStats") or die "Can't open statistics file $outputStats: $!\n"; 130 my @contents = <$statsFile>; # Contents of file 131 close $statsFile; 118 my $outputStatsReal = $ipprc->file_resolve($outputStats); 119 &my_die("Couldn't find expected output file: $outputStats", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStatsReal; 132 120 133 # parse the statistics MDC file 134 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 135 my $metadata = $mdcParser->parse(join "", @contents) 136 or &my_die("Unable to parse metadata config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 137 138 # extract the stats from the metadata 139 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 121 # parse stats from metadata 122 $command = "$ppStatsFromMetadata $outputStatsReal - DETREND_PROCESS_IMFILE"; 123 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 124 run(command => $command, verbose => $verbose); 125 unless ($success) { 126 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 127 &my_die("Unable to perform ppStatsFromMetadata: $error_code", $det_id, $exp_id, $class_id, $error_code); 128 } 129 foreach my $line (@$stdout_buf) { 130 $cmdflags .= " $line"; 131 } 132 chomp $cmdflags; 140 133 } 141 134 … … 148 141 $command .= " -uri $outputImage -path_base $outroot"; 149 142 $command .= " -dbname $dbname" if defined $dbname; 150 $command .= $stats->cmdflags();143 $command .= " $cmdflags"; 151 144 152 145 # Add the processed file to the database
Note:
See TracChangeset
for help on using the changeset viewer.
