Changeset 9454
- Timestamp:
- Oct 9, 2006, 10:20:43 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_reject_imfile.pl (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_reject_imfile.pl
r9453 r9454 41 41 use constant RECIPE2 => 'PPIMAGE_J2'; # Recipe to use for ppImage to make JPEGs 42 42 43 #### XXXXX these values must come from the config system, and may depend on filter!!! 43 44 # The expected mean, as a function of detrend type 44 45 use constant EXPECTED_MEAN => { … … 46 47 'dark' => 0, # Dark should be zero 47 48 'shutter' => undef, # Shutter could be anything (depends on exposure level) 48 'flat' => 0 # Flat could be anything (depends on exposure level)49 'flat' => 0 # Flat could be anything (depends on exposure level) 49 50 }; 50 51 51 52 # Rejection threshold for the mean, in terms of the standard deviation 52 53 # This measures how close it is to what's expected 53 use constant REJECT_INDIVIDUAL_MEAN => { 54 # XXX it is valid to reject on more than one criterion 55 use constant REJECT_COMPONENT_MEAN => { 54 56 'bias' => 0, # Should be fairly flat; some CRs 55 57 'dark' => 0, # Lots of CRs … … 59 61 60 62 # Rejection threshold for the standard deviation, in ADUs 61 # This measures how much variation there is in each component62 use constant REJECT_ INDIVIDUAL_STDEV => {63 # This measures how much variation there is in each imfile component 64 use constant REJECT_COMPONENT_STDEV => { 63 65 'bias' => 0, # Should be fairly flat; some CRs 64 66 'dark' => 0, # Lots of CRs … … 77 79 78 80 # Rejection threshold for the stdev of the sample, in ADUs 79 # This measures how much variation there is across the components81 # This measures how much variation there is across the imfile components 80 82 use constant REJECT_SAMPLE_STDEV => { 83 'bias' => 0, # Should be little variation between chips 84 'dark' => 0, # Could be some glow on some chips 85 'shutter' => undef, # Can be significant structure 86 'flat' => 0 # Could be features on some chips, but all should be about the same 87 }; 88 89 # Rejection threshold for the stdev of the sample, in ADUs 90 # This measures how much variation there is across the imfile components 91 use constant REJECT_SAMPLE_MEAN_STDEV => { 81 92 'bias' => 0, # Should be little variation between chips 82 93 'dark' => 0, # Could be some glow on some chips … … 151 162 die "Unknown expected mean for detrend type $det_type\n" 152 163 if not exists EXPECTED_MEAN->{$det_type}; 153 die "Unknown individualmean rejection level for detrend type $det_type\n"154 if not exists REJECT_ INDIVIDUAL_MEAN->{$det_type};155 die "Unknown individualstdev rejection level for detrend type $det_type\n"156 if not exists REJECT_ INDIVIDUAL_STDEV->{$det_type};164 die "Unknown component mean rejection level for detrend type $det_type\n" 165 if not exists REJECT_COMPONENT_MEAN->{$det_type}; 166 die "Unknown component stdev rejection level for detrend type $det_type\n" 167 if not exists REJECT_COMPONENT_STDEV->{$det_type}; 157 168 die "Unknown sample mean rejection level for detrend type $det_type\n" 158 169 if not exists REJECT_SAMPLE_MEAN->{$det_type}; … … 160 171 if not exists REJECT_SAMPLE_STDEV->{$det_type}; 161 172 162 # Reject based on the individual stats173 # Reject based on the stats of the component imfile 163 174 die "Number of means and number of stdevs differ!\n" if scalar @means != scalar @stdevs; 164 175 for (my $i = 0; $i < scalar @means; $i++) { 165 176 my $mean = $means[$i]; # Mean for this component 166 177 $mean -= EXPECTED_MEAN->{$det_type} if defined EXPECTED_MEAN->{$det_type}; 167 my $stdev = $stdevs[$i]; # Stdev for this component 168 my $not_reject; 169 170 if (defined REJECT_INDIVIDUAL_MEAN->{$det_type} 171 and $stdev > 0 and 172 $mean / $stdev > REJECT_INDIVIDUAL_MEAN->{$det_type}) { 173 print "Rejecting exposure based on bad individual mean for component $i: " . 174 ($mean / $stdev) . " vs " . REJECT_INDIVIDUAL_MEAN->{$det_type} . "\n"; 175 $not_reject = 1; 176 last; 177 } elsif (defined REJECT_INDIVIDUAL_STDEV->{$det_type} and 178 $stdev > REJECT_INDIVIDUAL_STDEV->{$det_type}) { 179 print "Rejecting exposure based on bad individual stdev for component $i: " . 180 $stdev . " vs " . REJECT_INDIVIDUAL_STDEV->{$det_type} . "\n"; 181 $not_reject = 1; 182 last; 178 my $stdev = sqrt($stdevs[$i]); # Stdev for this component 179 180 ## IT IS VALID to reject on more than one criterion 181 if (REJECT_COMPONENT_MEAN->{$det_type} && ($stdev > 0) ) { 182 if ($mean / $stdev > REJECT_COMPONENT_MEAN->{$det_type}) { 183 print "Rejecting exposure based on bad component mean for component $i: " . 184 ($mean / $stdev) . " vs " . REJECT_COMPONENT_MEAN->{$det_type} . "\n"; 185 $reject = 1; 186 last; 187 } 188 } 189 if (REJECT_COMPONENT_STDEV->{$det_type}) { 190 if ($stdev > REJECT_COMPONENT_STDEV->{$det_type}) { 191 print "Rejecting exposure based on bad component stdev for component $i: " . 192 $stdev . " vs " . REJECT_COMPONENT_STDEV->{$det_type} . "\n"; 193 $reject = 1; 194 last; 195 } 183 196 } 184 197 } 185 198 186 # Reject based on the sample stats199 # calculate the imfile ensemble statistics 187 200 my $meanStats = Statistics::Descriptive::Sparse->new(); # Statistics calculator for means 188 201 $meanStats->add_data(@means); … … 190 203 $stdevStats->add_data(@stdevs); 191 204 my $mean = $meanStats->mean(); # Mean of the sample of means 192 my $ stdev = $meanStats->standard_deviation(); # Stdev of the sample of means205 my $meanStdev = $meanStats->standard_deviation(); # Stdev of the sample of means 193 206 if (not defined $stdev) { 194 207 $stdev = 0; 195 208 } 196 my $meanStdev = sqrt($stdevStats->mean()); # Root-Mean-Square of the sample of stdevs 197 my $not_reject; 209 my $stdev = sqrt($stdevStats->mean()); # Root-Mean-Square of the sample of stdevs 198 210 print "calculating root-mean-square of the sample stdevs: $meanStdev\n"; 199 if (defined REJECT_SAMPLE_MEAN->{$det_type} and 200 $stdev != 0 and 201 $mean / $stdev > REJECT_SAMPLE_MEAN->{$det_type}) { 202 print "Rejecting exposure based on bad mean: " . ($mean / $stdev) . " vs " . 203 REJECT_SAMPLE_MEAN->{$det_type} . "\n"; 204 $not_reject = 1; 205 } elsif (defined REJECT_SAMPLE_STDEV->{$det_type} and 206 $meanStdev > REJECT_SAMPLE_STDEV->{$det_type}) { 207 print "Rejecting exposure based on bad mean stdev: " . $meanStdev . " vs " . 208 REJECT_SAMPLE_STDEV->{$det_type} . "\n"; 209 $not_reject = 1; 211 212 ## Reject based on the imfile ensemble stats 213 # reject if the imfile ensemble 214 if (REJECT_SAMPLE_MEAN->{$det_type} && ($stdev > 0)) { 215 if ($mean / $stdev > REJECT_SAMPLE_MEAN->{$det_type}) { 216 print "Rejecting exposure based on bad mean: " . ($mean / $stdev) . " vs " . 217 REJECT_SAMPLE_MEAN->{$det_type} . "\n"; 218 $reject = 1; 219 } 220 } 221 if (REJECT_SAMPLE_STDEV->{$det_type}) { 222 if ($stdev > REJECT_SAMPLE_STDEV->{$det_type}) { 223 print "Rejecting exposure based on bad mean stdev: " . $stdev . " vs " . 224 REJECT_SAMPLE_STDEV->{$det_type} . "\n"; 225 $reject = 1; 226 } 227 } 228 if (REJECT_SAMPLE_MEAN_STDEV->{$det_type}) { 229 if ($meanStdev > REJECT_SAMPLE_MEAN_STDEV->{$det_type}) { 230 print "Rejecting exposure based on bad mean stdev: " . $meanStdev . " vs " . 231 REJECT_SAMPLE_MEAN_STDEV->{$det_type} . "\n"; 232 $reject = 1; 233 } 210 234 } 211 235 … … 229 253 230 254 __END__ 255 256 #### 257 258 ## this function is not well though out. it loads a collection of 259 ## values (background mean and stdev) for a collection of imfile 260 ## subcomponents. it then measures the mean background, the 261 ## background stdev (rms of ensemble stdevs), and the background mean 262 ## stdev (rms of the means). it then tries to reject based on the 263 ## following criteria: 264 ## (background / stdev > limit) for a single component 265 ## ---> this will ACCEPT for a poor images (large stdev) 266 ## (stdev > limit) 267 ## (mean background / stdev > limit) same problem 268 ## (mean stdev > limit) 269 270 ### I would suggest the following: 271 ## 1) calculate the ensemble mean and stdev 272 ## 2) for each component, is the (back - mean) / mean stdev > limit? 273 ## (ie, is it an outlier?) 274 ## 3) is the component stdev > limit? (absolute test) 275 ## 4) calculate the background stdev for the ensemble (excluding rejects) 276 ## 5) is the mean stdev > limit (poor images) 277 ## 6) calculate the ensemble stdev (rms) of remaining (excluding rejects) 278 ## 7) is the ensemble stdev > limit 279 280 ## for flats, the value used for stdev should be the fractional stdev 281 ## (stdev/mean) and no rejection should be performed on the basis of 282 ## the mean value, but could still be done on the mean stdev 283 284 ## the same logical cuts above can be applied to components in an 285 ## imfile, imfiles in an exposure, and exposures in a stack
Note:
See TracChangeset
for help on using the changeset viewer.
