Changeset 8998 for trunk/ippScripts/scripts/detrend_calc_norm.pl
- Timestamp:
- Sep 26, 2006, 3:37:34 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_calc_norm.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_calc_norm.pl
r8887 r8998 4 4 use strict; 5 5 6 use IPC::Cmd qw( can_run run ); 6 use IPC::Cmd qw( can_run ); 7 use IPC::Run qw ( run ); 7 8 use PS::IPP::Metadata::Config; 8 9 use PS::IPP::Metadata::List qw( parse_md_list ); … … 13 14 14 15 15 use constant STATISTIC => 'bg'; # Background statistic to use from the database16 17 16 # Parse command-line arguments 18 my ($detId, # Detrend id 19 $iter # Iteration 17 my ($detId, # Detrend id 18 $iter, # Iteration 19 $camera, # Camera name 20 $detType # Detrend type 20 21 ); 21 22 GetOptions( 22 23 'det_id|d=s' => \$detId, 23 24 'iteration|i=s' => \$iter, 25 'camera|c=s' => \$camera, 26 'det_type|t=s' => \$detType 24 27 ) or pod2usage( 2 ); 25 28 26 29 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 27 pod2usage( -msg => "Required options --det_id --iteration ",30 pod2usage( -msg => "Required options --det_id --iteration --camera --det_type", 28 31 -exitval => 3, 29 ) unless defined $detId 30 and defined $iter; 32 ) unless defined $detId 33 and defined $iter 34 and defined $camera 35 and defined $detType; 31 36 32 37 … … 45 50 { 46 51 my $command = "$dettool -processed -unmask -det_id $detId -iteration $iter"; # Command to run 47 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =48 run(command => $command, verbose => 1); 49 die "Unable to perform dettool -processed -unmask on detrend $detId/$iter: $error_code\n"50 if not $success;52 my @command = split /\s+/, $command; 53 my ( $stdin, $stdout, $stderr ); # Buffers for running program 54 run \@command, \$stdin, \$stdout, \$stderr or 55 die "Unable to perform dettool -processed -unmask on detrend $detId/$iter: $?"; 51 56 52 57 # Parse the output 53 my $metadata = $mdcParser->parse(join "", @$stdout _buf)58 my $metadata = $mdcParser->parse(join "", @$stdout) 54 59 or die "unable to parse metadata config doc"; 55 60 $files = parse_md_list($metadata); … … 67 72 } 68 73 69 my $normName = 'normCalc_' . $detId . '_' . $iter . '.mdc'; # Name for ppNormCalc input file 70 my $normFile; # File handle for ppNormCalc input 71 open $normFile, ">" . $normName; 74 # Generate the input for ppNormCalc 75 my $normData; # Normalisation data 72 76 foreach my $expId (keys %matrix) { 73 print $normFile"$expId\tMETADATA\n";77 $normData .= "$expId\tMETADATA\n"; 74 78 foreach my $classId (keys %{$matrix{$expId}}) { 75 print $normFile"\t" . $classId . "\tF32\t" . $matrix{$expId}->{$classId} . "\n";79 $normData .= "\t" . $classId . "\tF32\t" . $matrix{$expId}->{$classId} . "\n"; 76 80 } 77 print $normFile"END\n\n";81 $normData .= "END\n\n"; 78 82 } 79 close $normFile;80 83 81 84 # Run ppNormCalc 82 85 my $norms; 83 86 { 84 my $command = "$ppNormCalc $normName"; # Command to run 85 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 86 run(command => $command, verbose => 1); 87 die "Unable to perform ppNormCalc: $error_code\n" 88 if not $success; 89 $norms = $mdcParser->parse(join "", @$stdout_buf) 87 my ( $stdout, $stderr ); # Buffers for running program 88 my @command = split /\s+/, $ppNormCalc; 89 run \@command, \$normData, \$stdout, \$stderr or 90 die "Unable to perform ppNormCalc: $?"; 91 92 # Parse the output 93 $norms = $mdcParser->parse(join "", @$stdout) 90 94 or die "unable to parse metadata config doc"; 91 95 } … … 99 103 my $command = "$dettool -addnormstat -det_id $detId -iteration $iter -class_id $className ". 100 104 "-norm $normalisation"; # Command to run 101 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 102 run(command => $command, verbose => 1); 103 die "Unable to perform dettool -addnormstat: $error_code\n" 104 if not $success; 105 my @command = split /\s+/, $command; 106 107 my ( $stdin, $stdout, $stderr ); # Buffers for running program 108 run \@command, \$stdin, \$stdout, \$stderr or 109 die "Unable to perform dettool -addnormstat for $className: $?"; 105 110 } 106 111 }
Note:
See TracChangeset
for help on using the changeset viewer.
