IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 12, 2006, 10:14:50 AM (20 years ago)
Author:
Paul Price
Message:

Making detrend rejection limits configurable per camera, by placing them in the camera configuration and using PS::IPP::Config to access them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/detrend_reject_exp.pl

    r9458 r9505  
    1212use Statistics::Descriptive;
    1313
     14use PS::IPP::Config;
     15my $ipprc = PS::IPP::Config->new(); # IPP configuration
     16
    1417use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    1518use Pod::Usage qw( pod2usage );
    1619
    17 my ($det_id, $iter, $det_type, $no_update);
     20my ($det_id, $iter, $det_type, $camera, $filter, $no_update);
    1821GetOptions(
    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
    2328) or pod2usage( 2 );
    2429
    2530pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    2631pod2usage(
    27     -msg => "Required options: --det_id --iteration --det_type",
     32    -msg => "Required options: --det_id --iteration --det_type --camera",
    2833    -exitval => 3,
    2934) unless defined $det_id
    3035    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
    5939
    6040# Look for programs we need
     
    10383$meanStdevStats->add_data(@meanStdevs);
    10484
    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
     87my $reject_mean = rejection_limit( 'ENSEMBLE.MEAN', $det_type, $filter );
     88my $reject_stdev = rejection_limit( 'ENSEMBLE.STDEV', $det_type, $filter );
     89my $reject_meanstdev = rejection_limit( 'ENSEMBLE.MEANSTDEV', $det_type, $filter );
    11290
    11391# rejections based on comparison with ensemble statistics
     
    124102# Go through again to do rejection, and update the database for each exposure
    125103my $numChanges = 0;             # Number of exposures with changed status
     104my $numReject = 0;              # Number of exposures rejected
     105my $command;
    126106for (my $i = 0; $i < scalar @means; $i++) {
    127107    my $expTag = $expTags[$i];  # Exposure ID
    128     my $command = "$dettool -updateresidexp -det_id $det_id -iteration $iter -exp_tag $expTag"; # Command to run
     108    $command = "$dettool -updateresidexp -det_id $det_id -iteration $iter -exp_tag $expTag"; # Command to run
    129109    my $reject = 0;             # Reject this exposure?
    130110
     
    134114        $reject = 1;
    135115        goto UPDATE;
    136     } 
    137     if (REJECT_MEAN->{$det_type} && ($meanStdev > 0)) {
     116    }
     117    if ($reject_mean && ($meanStdev > 0)) {
    138118        my $nSigma = abs($means[$i] - $mean) / $meanStdev;
    139         if ($nSigma > REJECT_MEAN->{$det_type}) {
     119        if ($nSigma > $reject_mean) {
    140120            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";
    142122            $reject = 1;
    143123            goto UPDATE;
     
    146126        print "no rejection for exposure mean\n";
    147127    }
    148     if (REJECT_STDEV->{$det_type} && ($varStdev > 0)) {
     128    if ($reject_stdev && ($varStdev > 0)) {
    149129        my $nSigma = abs($variances[$i] - $var) / $varStdev;
    150         if ($nSigma > REJECT_STDEV->{$det_type}) {
     130        if ($nSigma > $reject_stdev) {
    151131            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";
    153133            $reject = 1;
    154134            goto UPDATE;
     
    161141    if ($reject) {
    162142        $command .= ' -reject';
     143        $numReject++;
    163144    }
    164145   
     
    184165    $master = 0;
    185166    $stop = 0;
     167}
     168
     169# Rejecting everything --- stop before something bad happens!
     170if ($numReject == scalar @means) {
     171    $master = 0;
     172    $stop = 1;
    186173}
    187174
     
    217204END { system("sync") == 0 or die "failed to execute sync: $!" }
    218205
     206# Retrieve the requested rejection limit, dying if not extant
     207sub 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
    219223__END__
Note: See TracChangeset for help on using the changeset viewer.