Changeset 9505 for trunk/ippScripts/scripts/detrend_reject_exp.pl
- Timestamp:
- Oct 12, 2006, 10:14:50 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_reject_exp.pl (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_reject_exp.pl
r9458 r9505 12 12 use Statistics::Descriptive; 13 13 14 use PS::IPP::Config; 15 my $ipprc = PS::IPP::Config->new(); # IPP configuration 16 14 17 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 15 18 use Pod::Usage qw( pod2usage ); 16 19 17 my ($det_id, $iter, $det_type, $ no_update);20 my ($det_id, $iter, $det_type, $camera, $filter, $no_update); 18 21 GetOptions( 19 'det_id|d=s' => \$det_id, 20 'iteration=s' => \$iter, 21 'det_type|t=s' => \$det_type, 22 'no-update' => \$no_update 22 'det_id|d=s' => \$det_id, 23 'iteration=s' => \$iter, 24 'det_type|t=s' => \$det_type, 25 'camera=s' => \$camera, 26 'filter=s' => \$filter, 27 'no-update' => \$no_update 23 28 ) or pod2usage( 2 ); 24 29 25 30 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 26 31 pod2usage( 27 -msg => "Required options: --det_id --iteration --det_type ",32 -msg => "Required options: --det_id --iteration --det_type --camera", 28 33 -exitval => 3, 29 34 ) unless defined $det_id 30 35 and defined $iter 31 and defined $det_type; 32 33 # Rejection threshold for the mean, in terms of the standard deviation 34 # This measures how close it is to what's expected 35 use constant REJECT_MEAN => { 36 'bias' => 0, # Should be fairly flat; some CRs 37 'dark' => 0, # Lots of CRs 38 'shutter' => 10, # Should be less than 10 sec 39 'flat' => undef # Can't define expected value (depends on exposure level) 40 }; 41 42 # Rejection threshold for the standard deviation, in terms of the standard deviation of the stdevs 43 # This measures how much variation there is within the components of an exposure, compared to "typical" 44 use constant REJECT_STDEV => { 45 'bias' => 0, # Components should have the same degree of variation 46 'dark' => 0, # Components should have the same degree of variation 47 'shutter' => undef, # Might be significant variation 48 'flat' => 0 # Components should have the same degree of variation 49 }; 50 51 # Rejection threshold for the mean of the stdev, in terms of the standard deviation of the mean of the stdevs 52 # This measures how structured the images are, compared to "typical" 53 use constant REJECT_MEAN_STDEV => { 54 'bias' => 0, # All images should be equally structured 55 'dark' => 0, # All images should be equally structured 56 'shutter' => 0, # All images should be equally structured 57 'flat' => 0 # All images should be equally structured 58 }; 36 and defined $det_type 37 and defined $camera; 38 59 39 60 40 # Look for programs we need … … 103 83 $meanStdevStats->add_data(@meanStdevs); 104 84 105 # Check the existence of the required rejection levels as a function of detrend type 106 die "Unknown mean rejection level for detrend type $det_type\n" 107 if not exists REJECT_MEAN->{$det_type}; 108 die "Unknown stdev rejection level for detrend type $det_type\n" 109 if not exists REJECT_STDEV->{$det_type}; 110 die "Unknown mean stdev rejection level for detrend type $det_type\n" 111 if not exists REJECT_MEAN_STDEV->{$det_type}; 85 $ipprc->define_camera($camera); 86 # Rejection thresholds 87 my $reject_mean = rejection_limit( 'ENSEMBLE.MEAN', $det_type, $filter ); 88 my $reject_stdev = rejection_limit( 'ENSEMBLE.STDEV', $det_type, $filter ); 89 my $reject_meanstdev = rejection_limit( 'ENSEMBLE.MEANSTDEV', $det_type, $filter ); 112 90 113 91 # rejections based on comparison with ensemble statistics … … 124 102 # Go through again to do rejection, and update the database for each exposure 125 103 my $numChanges = 0; # Number of exposures with changed status 104 my $numReject = 0; # Number of exposures rejected 105 my $command; 126 106 for (my $i = 0; $i < scalar @means; $i++) { 127 107 my $expTag = $expTags[$i]; # Exposure ID 128 my$command = "$dettool -updateresidexp -det_id $det_id -iteration $iter -exp_tag $expTag"; # Command to run108 $command = "$dettool -updateresidexp -det_id $det_id -iteration $iter -exp_tag $expTag"; # Command to run 129 109 my $reject = 0; # Reject this exposure? 130 110 … … 134 114 $reject = 1; 135 115 goto UPDATE; 136 } 137 if ( REJECT_MEAN->{$det_type}&& ($meanStdev > 0)) {116 } 117 if ($reject_mean && ($meanStdev > 0)) { 138 118 my $nSigma = abs($means[$i] - $mean) / $meanStdev; 139 if ($nSigma > REJECT_MEAN->{$det_type}) {119 if ($nSigma > $reject_mean) { 140 120 print "Rejecting $expTag based on outlier mean value: " . 141 "$means[$i] is $nSigma vs " . REJECT_MEAN->{$det_type}. "\n";121 "$means[$i] is $nSigma vs " . $reject_mean . "\n"; 142 122 $reject = 1; 143 123 goto UPDATE; … … 146 126 print "no rejection for exposure mean\n"; 147 127 } 148 if ( REJECT_STDEV->{$det_type}&& ($varStdev > 0)) {128 if ($reject_stdev && ($varStdev > 0)) { 149 129 my $nSigma = abs($variances[$i] - $var) / $varStdev; 150 if ($nSigma > REJECT_STDEV->{$det_type}) {130 if ($nSigma > $reject_stdev) { 151 131 print "Rejecting $expTag based on outlier stdev: " . 152 sqrt($variances[$i]) . " is $nSigma vs " . REJECT_STDEV->{$det_type}. "\n";132 sqrt($variances[$i]) . " is $nSigma vs " . $reject_stdev . "\n"; 153 133 $reject = 1; 154 134 goto UPDATE; … … 161 141 if ($reject) { 162 142 $command .= ' -reject'; 143 $numReject++; 163 144 } 164 145 … … 184 165 $master = 0; 185 166 $stop = 0; 167 } 168 169 # Rejecting everything --- stop before something bad happens! 170 if ($numReject == scalar @means) { 171 $master = 0; 172 $stop = 1; 186 173 } 187 174 … … 217 204 END { system("sync") == 0 or die "failed to execute sync: $!" } 218 205 206 # Retrieve the requested rejection limit, dying if not extant 207 sub rejection_limit 208 { 209 my $name = shift; # Rejection limit to 210 my $type = shift; # Type of exposure 211 my $filter = shift; # Filter 212 213 my $value = $ipprc->rejection( $name, $det_type, $filter ); 214 if (not defined $value) { 215 $filter = "(no filter)" if not defined $filter; 216 die "Unable to determine $name rejection limit for $det_type with $filter.\n"; 217 } 218 219 return $value; 220 } 221 222 219 223 __END__
Note:
See TracChangeset
for help on using the changeset viewer.
