Changeset 9505
- Timestamp:
- Oct 12, 2006, 10:14:50 AM (20 years ago)
- Location:
- trunk/ippScripts/scripts
- Files:
-
- 2 edited
-
detrend_reject_exp.pl (modified) (8 diffs)
-
detrend_reject_imfile.pl (modified) (11 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__ -
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.
