Changeset 8763 for trunk/ippScripts/scripts/detrend_reject_exp.pl
- Timestamp:
- Sep 6, 2006, 4:32:51 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_reject_exp.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_reject_exp.pl
r8715 r8763 4 4 use strict; 5 5 6 use vars qw( $VERSION ); 7 $VERSION = '0.01'; 8 6 9 use IPC::Cmd qw( can_run run ); 7 10 use PS::IPP::Metadata::Config; 8 11 use PS::IPP::Metadata::List qw( parse_md_list ); 9 12 use Statistics::Descriptive; 10 use Data::Dumper; 13 14 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 15 use Pod::Usage qw( pod2usage ); 16 17 my ($det_id, $iter, $det_type); 18 GetOptions( 19 'det_id|d=s' => \$det_id, 20 'iteration=s' => \$iter, 21 'det_type|t=s' => \$det_type, 22 ) or pod2usage( 2 ); 23 24 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 25 pod2usage( 26 -msg => "Required options: --det_id --exp_id --class_id --det_type --input_uri --output_uri", 27 -exitval => 3, 28 ) unless defined $det_id 29 and defined $iter 30 and defined $det_type; 31 32 my $detType = shift @ARGV; # Detrend type 11 33 12 34 # Rejection threshold for the mean, in terms of the standard deviation … … 34 56 }; 35 57 36 # Parse command-line arguments37 die "Reject exposures based on the sample of exposures.\n\n" .38 "Usage: $0 DET_ID ITER DETREND_TYPE\n\n"39 if scalar @ARGV != 3;40 my $detId = shift @ARGV; # Detrend ID41 my $iter = shift @ARGV; # Iteration number42 my $detType = shift @ARGV; # Detrend type43 44 58 # Look for programs we need 45 59 my $missing_tools; … … 51 65 my $exposures; # Array of exposures 52 66 { 53 my $command = "$dettool -residexp -det_id $det Id -iteration $iter"; # Command to run67 my $command = "$dettool -residexp -det_id $det_id -iteration $iter"; # Command to run 54 68 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 55 69 run(command => $command, verbose => 1); … … 82 96 83 97 # Check the existence of the required rejection levels as a function of detrend type 84 die "Unknown mean rejection level for detrend type $det Type\n"85 if not exists REJECT_MEAN->{$det Type};86 die "Unknown stdev rejection level for detrend type $det Type\n"87 if not exists REJECT_STDEV->{$det Type};88 die "Unknown mean stdev rejection level for detrend type $det Type\n"89 if not exists REJECT_MEAN_STDEV->{$det Type};98 die "Unknown mean rejection level for detrend type $det_type\n" 99 if not exists REJECT_MEAN->{$det_type}; 100 die "Unknown stdev rejection level for detrend type $det_type\n" 101 if not exists REJECT_STDEV->{$det_type}; 102 die "Unknown mean stdev rejection level for detrend type $det_type\n" 103 if not exists REJECT_MEAN_STDEV->{$det_type}; 90 104 91 105 # Go through again to do rejection, and update the database for each exposure … … 93 107 for (my $i = 0; $i < scalar @means; $i++) { 94 108 my $expId = $expIds[$i]; # Exposure ID 95 my $command = "$dettool -updateresidexp -det_id $det Id -iteration $iter -exp_id $expId"; # Command to run109 my $command = "$dettool -updateresidexp -det_id $det_id -iteration $iter -exp_id $expId"; # Command to run 96 110 my $reject = 0; # Reject this exposure? 97 if (defined REJECT_MEAN->{$det Type} and111 if (defined REJECT_MEAN->{$det_type} and 98 112 defined $meanStats->standard_deviation() and 99 113 $meanStats->standard_deviation() > 0 and 100 ($means[$i] - $meanStats->mean()) / $meanStats->standard_deviation() > REJECT_MEAN->{$det Type}) {114 ($means[$i] - $meanStats->mean()) / $meanStats->standard_deviation() > REJECT_MEAN->{$det_type}) { 101 115 print "Rejecting $expId based on bad mean: " . 102 116 (($means[$i] - $meanStats->mean()) / $meanStats->standard_deviation()) . 103 " vs " . REJECT_MEAN->{$det Type} . "\n";117 " vs " . REJECT_MEAN->{$det_type} . "\n"; 104 118 $reject = 1; 105 } elsif (defined REJECT_STDEV->{$det Type} and119 } elsif (defined REJECT_STDEV->{$det_type} and 106 120 defined $stdevStats->standard_deviation() and 107 121 $stdevStats->standard_deviation() > 0 and 108 122 ($stdevs[$i] - $stdevStats->mean()) / $stdevStats->standard_deviation() > 109 REJECT_STDEV->{$det Type}) {123 REJECT_STDEV->{$det_type}) { 110 124 print "Rejecting $expId based on bad stdev: " . 111 125 (($stdevs[$i] - $stdevStats->mean()) / $stdevStats->standard_deviation()) . 112 " vs " . REJECT_STDEV->{$det Type} . "\n";126 " vs " . REJECT_STDEV->{$det_type} . "\n"; 113 127 $reject = 1; 114 } elsif (defined REJECT_MEAN_STDEV->{$det Type} and128 } elsif (defined REJECT_MEAN_STDEV->{$det_type} and 115 129 defined $meanStdevStats->standard_deviation() and 116 130 $meanStdevStats->standard_deviation() > 0 and 117 131 ($meanStdevs[$i] - $meanStdevStats->mean()) / $meanStdevStats->standard_deviation() > 118 REJECT_MEAN_STDEV->{$det Type}) {132 REJECT_MEAN_STDEV->{$det_type}) { 119 133 print "Rejecting $expId based on bad stdev: " . 120 134 (($meanStdevs[$i] - $meanStdevStats->mean()) / $meanStdevStats->standard_deviation()) . 121 " vs " . REJECT_MEAN_STDEV->{$det Type} . "\n";135 " vs " . REJECT_MEAN_STDEV->{$det_type} . "\n"; 122 136 $reject = 1; 123 137 } … … 147 161 # Put the result into the database 148 162 { 149 my $command = "$dettool -adddetrunsummary -det_id $det Id -iteration $iter " .163 my $command = "$dettool -adddetrunsummary -det_id $det_id -iteration $iter " . 150 164 "-bg " . $meanStats->mean() . " -bg_stdev " . $stdevStats->mean() . 151 165 " -bg_mean_stdev " . $meanStdevStats->mean(); … … 159 173 # Re-run processing if required 160 174 { 161 my $command = "$dettool -updatedetrun -det_id $det Id";175 my $command = "$dettool -updatedetrun -det_id $det_id"; 162 176 if ($stop) { 163 177 $command .= ' -stop';
Note:
See TracChangeset
for help on using the changeset viewer.
