Changeset 9141 for trunk/ippScripts/scripts/detrend_norm_apply.pl
- Timestamp:
- Oct 2, 2006, 5:48:37 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_norm_apply.pl (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_norm_apply.pl
r9094 r9141 43 43 44 44 45 use constant RECIPE => 'PPIMAGE_N'; # Recipe to use with ppImage 46 45 47 # Look for programs we need 46 48 my $missing_tools; 47 49 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 48 my $pp Arith = can_run('ppArith') or (warn "Can't find ppArith" and $missing_tools = 1);50 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 49 51 die "Can't find required tools.\n" if $missing_tools; 50 52 51 53 # Output name 52 my $output = $camera . '.' . $detType . '.norm.' . $detId . '.' . $iter . '.' . $classId . '.fits'; 54 my $outputRoot = $camera . '.' . $detType . '.norm.' . $detId . '.' . $iter; # Root output name 55 my $output = $outputRoot . '.' . $classId . '.fits'; # Main output file 56 my $b1name = $outputRoot . '.' . $classId . '.b1.fits'; # Output file with binning 1 57 my $b2name = $outputRoot . '.' . $classId . '.b2.fits'; # Output file with binning 2 58 my $statName = $outputRoot . '.' . $classId . '.stats'; # Statistics file 53 59 54 60 # Run ppArith 55 my $norms;56 61 { 57 my $command = "$pp Arith -file1 $input -op * -constant $value -out $output"; # Command to run62 my $command = "$ppImage -file $input $outputRoot -norm $value -stat $statName -recipe PPIMAGE " . RECIPE(); # Command to run 58 63 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 59 64 run(command => $command, verbose => 1); 60 die "Unable to perform pp Arith: $error_code\n" if not $success;65 die "Unable to perform ppImage: $error_code\n" if not $success; 61 66 die "Can't find expected output file: $output\n" if not -e $output; 67 die "Can't find expected output file: $b1name\n" if not -e $b1name; 68 die "Can't find expected output file: $b2name\n" if not -e $b2name; 69 die "Can't find expected output file: $statName\n" if not -e $statName; 70 } 71 72 # Get the statistics on the normalised image 73 my $stats; # Statistics from ppImage 74 { 75 my $statsFile; # File handle 76 open $statsFile, $statsName or die "Can't open statistics file $statsName: $!\n"; 77 my @contents = <$statsFile>; # Contents of file 78 close $statsFile; 79 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 80 my $metadata = $mdcParser->parse(join "", @contents) 81 or die "unable to parse metadata config"; 82 $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 83 $stats->parse($metadata) or die "Unable to find all values in statistics output.\n"; 62 84 } 63 85 … … 66 88 unless ($no_update) { 67 89 my $command = "$dettool -addnormalizedimfile -det_id $detId -iteration $iter -class_id $classId ". 68 "-uri $output"; # Command to run 90 "-uri $output -b1_uri $b1name -b2_uri $b2name"; # Command to run 91 # Add the statistics triplet 92 $command .= " -bg " . $stats->bg_mean(); 93 if (defined($stats->bg_stdev())) { 94 $command .= " -bg_stdev " . $stats->bg_stdev(); 95 } else { 96 # May be undefined if there's only a single imfile 97 $command .= " -bg_stdev 0"; 98 } 99 $command .= " -bg_mean_stdev " . $stats->bg_mean_stdev(); 69 100 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 70 101 run(command => $command, verbose => 1);
Note:
See TracChangeset
for help on using the changeset viewer.
