Changeset 9505 for trunk/ippScripts/scripts/detrend_reject_imfile.pl
- Timestamp:
- Oct 12, 2006, 10:14:50 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_reject_imfile.pl
r9458 r9505 19 19 use Pod::Usage qw( pod2usage ); 20 20 21 my ($det_id, $iter, $exp_tag, $det_type, $ no_update, $reject);21 my ($det_id, $iter, $exp_tag, $det_type, $camera, $filter, $no_update, $reject); 22 22 GetOptions( 23 23 'det_id|d=s' => \$det_id, … … 26 26 'det_type|t=s' => \$det_type, 27 27 'no-update' => \$no_update, 28 'camera=s' => \$camera, 29 'filter=s' => \$filter, 28 30 'reject' => \$reject 29 31 ) or pod2usage( 2 ); … … 31 33 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 32 34 pod2usage( 33 -msg => "Required options: --det_id --iteration --exp_tag --det_type ",35 -msg => "Required options: --det_id --iteration --exp_tag --det_type --camera", 34 36 -exitval => 3, 35 37 ) unless defined $det_id 36 38 and defined $iter 37 39 and defined $exp_tag 38 and defined $det_type; 40 and defined $det_type 41 and defined $camera; 39 42 40 43 use constant RECIPE1 => 'PPIMAGE_J1'; # Recipe to use for ppImage to make JPEGs 41 44 use constant RECIPE2 => 'PPIMAGE_J2'; # Recipe to use for ppImage to make JPEGs 42 43 #### XXXXX these values must come from the config system, and may depend on filter!!!44 # XXX it is valid to reject on more than one criterion45 46 # The expected mean, as a function of detrend type47 use constant EXPECTED_MEAN => {48 'bias' => 0, # Bias should be zero49 'dark' => 0, # Dark should be zero50 'shutter' => undef, # Shutter could be anything (depends on exposure level)51 'flat' => 0 # Flat could be anything (depends on exposure level)52 };53 54 # Rejection threshold for the mean55 # This measures how close it is to what's expected56 use constant REJECT_IMFILE_MEAN => {57 'bias' => 0, # Should be fairly flat; some CRs58 'dark' => 0, # Lots of CRs59 'shutter' => undef, # Can't define expected value (depends on exposure level)60 'flat' => 0 # Can't define expected value (depends on exposure level)61 };62 63 # Rejection threshold for the standard deviation, in ADUs64 # This measures how much variation there is in each imfile65 use constant REJECT_IMFILE_STDEV => {66 'bias' => 15, # Should be fairly flat; some CRs67 'dark' => 0, # Lots of CRs68 'shutter' => undef, # Can be significant structure69 'flat' => 0 # Stars and galaxies70 };71 72 # Rejection threshold for the mean of the exposure, in terms of the standard deviation of the exposure73 # This measures how close it is to what's expected74 use constant REJECT_EXPOSURE_MEAN => {75 'bias' => 0, # Should be little variation between chips76 'dark' => 0, # Could be some glow on some chips77 'shutter' => undef, # Can't define expected value (depends on exposure level)78 'flat' => 0 # Can't define expected value (depends on exposure level)79 };80 81 # Rejection threshold for the stdev of the exposure, in ADUs82 # This measures how much variation there is across the imfiles83 use constant REJECT_EXPOSURE_STDEV => {84 'bias' => 15, # Should be little variation between chips85 'dark' => 0, # Could be some glow on some chips86 'shutter' => undef, # Can be significant structure87 'flat' => 0 # Could be features on some chips, but all should be about the same88 };89 90 # Rejection threshold for the stdev of the exposure, in ADUs91 # This measures how much variation there is across the imfiles92 use constant REJECT_EXPOSURE_MEAN_STDEV => {93 'bias' => 0, # Should be little variation between chips94 'dark' => 0, # Could be some glow on some chips95 'shutter' => undef, # Can be significant structure96 'flat' => 0 # Could be features on some chips, but all should be about the same97 };98 99 45 100 46 # Look for programs we need … … 131 77 open my $list2File, '>' . $list2Name; 132 78 foreach my $file (@$files) { 133 print $list1File File::Spec->rel2abs( $file->{b1_uri}, $ipprc->workdir() ) . "\n";134 print $list2File File::Spec->rel2abs( $file->{b2_uri}, $ipprc->workdir() ) . "\n";79 print $list1File (File::Spec->rel2abs( $file->{b1_uri}, $ipprc->workdir() ) . "\n"); 80 print $list2File (File::Spec->rel2abs( $file->{b2_uri}, $ipprc->workdir() ) . "\n"); 135 81 push @means, $file->{bg}; 136 82 ## calculate the root-mean-square of the bd_stdevs … … 160 106 } 161 107 162 # Check the existence of the required rejection levels as a function of detrend type 163 die "Unknown expected mean for detrend type $det_type\n" 164 if not exists EXPECTED_MEAN->{$det_type}; 165 die "Unknown imfile mean rejection level for detrend type $det_type\n" 166 if not exists REJECT_IMFILE_MEAN->{$det_type}; 167 die "Unknown imfile stdev rejection level for detrend type $det_type\n" 168 if not exists REJECT_IMFILE_STDEV->{$det_type}; 169 die "Unknown exposure mean rejection level for detrend type $det_type\n" 170 if not exists REJECT_EXPOSURE_MEAN->{$det_type}; 171 die "Unknown exposure stdev rejection level for detrend type $det_type\n" 172 if not exists REJECT_EXPOSURE_STDEV->{$det_type}; 173 die "Unknown exposure mean stdev rejection level for detrend type $det_type\n" 174 if not exists REJECT_EXPOSURE_MEAN_STDEV->{$det_type}; 108 $ipprc->define_camera( $camera); 109 my $expected = rejection_limit( 'EXPECTED', $det_type, $filter ); # Expected mean 110 # Rejection thresholds 111 my $reject_imfile_mean = rejection_limit( 'IMFILE.MEAN', $det_type, $filter ); 112 my $reject_imfile_stdev = rejection_limit( 'IMFILE.STDEV', $det_type, $filter ); 113 my $reject_exp_mean = rejection_limit( 'EXP.MEAN', $det_type, $filter ); 114 my $reject_exp_stdev = rejection_limit( 'EXP.STDEV', $det_type, $filter ); 115 my $reject_exp_meanstdev = rejection_limit( 'EXP.MEANSTDEV', $det_type, $filter ); 175 116 176 117 # Reject based on the stats of the imfiles … … 179 120 for (my $i = 0; $i < scalar @means; $i++) { 180 121 my $mean = $means[$i]; # Mean for this imfile 181 $mean -= EXPECTED_MEAN->{$det_type} if defined EXPECTED_MEAN->{$det_type};122 $mean -= $expected; 182 123 my $stdev = sqrt($variances[$i]); # Stdev for this imfile 183 124 184 if ( REJECT_IMFILE_MEAN->{$det_type}) {185 if (abs($mean) > REJECT_IMFILE_MEAN->{$det_type}) {125 if ($reject_imfile_mean) { 126 if (abs($mean) > $reject_imfile_mean) { 186 127 print "Rejecting exposure based on bad imfile mean for imfile $i: " . 187 $mean . " vs " . REJECT_IMFILE_MEAN->{$det_type}. "\n";128 $mean . " vs " . $reject_imfile_mean . "\n"; 188 129 $reject = 1; 189 130 last; … … 192 133 print "no rejection for imfile mean\n"; 193 134 } 194 if ( REJECT_IMFILE_STDEV->{$det_type}) {195 if ($stdev > REJECT_IMFILE_STDEV->{$det_type}) {135 if ($reject_imfile_stdev) { 136 if ($stdev > $reject_imfile_stdev) { 196 137 print "Rejecting exposure based on bad imfile stdev for imfile $i: " . 197 $stdev . " vs " . REJECT_IMFILE_STDEV->{$det_type}. "\n";138 $stdev . " vs " . $reject_imfile_stdev . "\n"; 198 139 $reject = 1; 199 140 last; … … 221 162 ## Reject based on the exposure ensemble stats 222 163 # reject if the exposure ensemble mean is deviant 223 if ( REJECT_EXPOSURE_MEAN->{$det_type}) {224 if (abs($mean) > REJECT_EXPOSURE_MEAN->{$det_type}) {164 if ($reject_exp_mean) { 165 if (abs($mean) > $reject_exp_mean) { 225 166 print "Rejecting exposure based on bad mean: " . ($mean / $stdev) . " vs " . 226 REJECT_EXPOSURE_MEAN->{$det_type}. "\n";167 $reject_exp_mean . "\n"; 227 168 $reject = 1; 228 169 } … … 231 172 } 232 173 # reject if the exposure ensemble stdev is deviant 233 if ( REJECT_EXPOSURE_STDEV->{$det_type}) {234 if ($stdev > REJECT_EXPOSURE_STDEV->{$det_type}) {174 if ($reject_exp_stdev) { 175 if ($stdev > $reject_exp_stdev) { 235 176 print "Rejecting exposure based on bad mean stdev: " . $stdev . " vs " . 236 REJECT_EXPOSURE_STDEV->{$det_type}. "\n";177 $reject_exp_stdev . "\n"; 237 178 $reject = 1; 238 179 } … … 241 182 } 242 183 # reject if the exposure ensemble mean stdev is deviant 243 if ( REJECT_EXPOSURE_MEAN_STDEV->{$det_type}) {244 if ($meanStdev > REJECT_EXPOSURE_MEAN_STDEV->{$det_type}) {184 if ($reject_exp_meanstdev) { 185 if ($meanStdev > $reject_exp_meanstdev) { 245 186 print "Rejecting exposure based on bad mean stdev: " . $meanStdev . " vs " . 246 REJECT_EXPOSURE_MEAN_STDEV->{$det_type}. "\n";187 $reject_exp_meanstdev . "\n"; 247 188 $reject = 1; 248 189 } … … 268 209 269 210 END { system("sync") == 0 or die "failed to execute sync: $!" } 211 212 213 # Retrieve the requested rejection limit, dying if not extant 214 sub rejection_limit 215 { 216 my $name = shift; # Rejection limit to 217 my $type = shift; # Type of exposure 218 my $filter = shift; # Filter 219 220 my $value = $ipprc->rejection( $name, $det_type, $filter ); 221 if (not defined $value) { 222 $filter = "(no filter)" if not defined $filter; 223 die "Unable to determine $name rejection limit for $det_type with $filter.\n"; 224 } 225 226 return $value; 227 } 228 229 230 270 231 271 232 __END__
Note:
See TracChangeset
for help on using the changeset viewer.
