IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8614


Ignore:
Timestamp:
Aug 25, 2006, 3:35:55 PM (20 years ago)
Author:
Paul Price
Message:

Working.

File:
1 edited

Legend:

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

    r8510 r8614  
    1313# This measures how close it is to what's expected
    1414use constant REJECT_MEAN => {
    15     'bias' => 0.01,             # Should be fairly flat; some CRs
    16     'dark' => 0.05,             # Lots of CRs
     15    'bias' => 10,               # Should be fairly flat; some CRs
     16    'dark' => 100,              # Lots of CRs
    1717    'flat' => undef             # Can't define expected value (depends on exposure level)
    1818    };
     
    2121# This measures how much variation there is within the components of an exposure, compared to "typical"
    2222use constant REJECT_STDEV => {
    23     'bias' => 3,                # Components should have the same degree of variation
    24     'dark' => 3,                # Components should have the same degree of variation
    25     'flat' => 3                 # Components should have the same degree of variation
     23    'bias' => 10, # Components should have the same degree of variation
     24    'dark' => 10, # Components should have the same degree of variation
     25    'flat' => 10 # Components should have the same degree of variation
    2626    };
    2727
     
    2929# This measures how structured the images are, compared to "typical"
    3030use constant REJECT_MEAN_STDEV => {
    31     'bias' => 3,                # All images should be equally structured
    32     'dark' => 3,                # All images should be equally structured
    33     'flat' => 3                 # All images should be equally structured
     31    'bias' => 5,                # All images should be equally structured
     32    'dark' => 5,                # All images should be equally structured
     33    'flat' => 5                 # All images should be equally structured
    3434    };
    3535
     
    5151my $exposures;                  # Array of exposures
    5252{
    53     my $command = "$dettool -residexp -det_id $detId -iter $iter"; # Command to run
     53    my $command = "$dettool -residexp -det_id $detId -iteration $iter"; # Command to run
    5454    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    5555        run(command => $command, verbose => 1);
     
    6666    die "Unable to find exposure id.\n" if not defined $exposure->{exp_id};
    6767    die "Unable to find mean.\n" if not defined $exposure->{bg};
    68     die "Unable to find stdev.\n" if not defined $exposure->{stdev};
     68    die "Unable to find stdev.\n" if not defined $exposure->{bg_stdev};
    6969    die "Unable to find mean stdev.\n" if not defined $exposure->{bg_mean_stdev};
    7070    push @expIds, $exposure->{exp_id};
     
    9292for (my $i = 0; $i < scalar @means; $i++) {
    9393    my $expId = $expIds[$i];    # Exposure ID
    94     my $command = "$dettool -updateresidexp -det_id $detId -iter $iter -exp_id $expId"; # Command to run
    95     if ((defined REJECT_MEAN->{$detType} and
    96          ($means[$i] - $meanStats->mean()) / $meanStats->standard_deviation() > REJECT_MEAN->{$detType})
    97         or
    98         (defined REJECT_STDEV->{$detType} and
    99          ($stdevs[$i] - $stdevStats->mean()) / $stdevStats->standard_deviation() > REJECT_STDEV->{$detType})
    100         or
    101         (defined REJECT_MEAN_STDEV->{$detType} and
    102          ($meanStdevs[$i] - $meanStdevStats->mean()) / $meanStdevStats->standard_deviation >
    103          REJECT_MEAN_STDEV->{$detType})) {
    104         $expId .= ' -reject';
     94    my $command = "$dettool -updateresidexp -det_id $detId -iteration $iter -exp_id $expId"; # Command to run
     95    my $reject = 0;             # Reject this exposure?
     96    if (defined REJECT_MEAN->{$detType} and
     97        defined $meanStats->standard_deviation() and
     98        $meanStats->standard_deviation() > 0 and
     99        ($means[$i] - $meanStats->mean()) / $meanStats->standard_deviation() > REJECT_MEAN->{$detType}) {
     100        print "Rejecting $expId based on bad mean: " .
     101            (($means[$i] - $meanStats->mean()) / $meanStats->standard_deviation()) .
     102            " vs " . REJECT_MEAN->{$detType} . "\n";
     103        $reject = 1;
     104    } elsif (defined REJECT_STDEV->{$detType} and
     105             defined $stdevStats->standard_deviation() and
     106             $stdevStats->standard_deviation() > 0 and
     107             ($stdevs[$i] - $stdevStats->mean()) / $stdevStats->standard_deviation() >
     108             REJECT_STDEV->{$detType}) {
     109        print "Rejecting $expId based on bad stdev: " .
     110            (($stdevs[$i] - $stdevStats->mean()) / $stdevStats->standard_deviation()) .
     111            " vs " . REJECT_STDEV->{$detType} . "\n";
     112        $reject = 1;
     113    } elsif (defined REJECT_MEAN_STDEV->{$detType} and
     114             defined $meanStdevStats->standard_deviation() and
     115             $meanStdevStats->standard_deviation() > 0 and
     116             ($meanStdevs[$i] - $meanStdevStats->mean()) / $meanStdevStats->standard_deviation() >
     117             REJECT_MEAN_STDEV->{$detType}) {
     118        print "Rejecting $expId based on bad stdev: " .
     119            (($meanStdevs[$i] - $meanStdevStats->mean()) / $meanStdevStats->standard_deviation()) .
     120            " vs " . REJECT_MEAN_STDEV->{$detType} . "\n";
     121        $reject = 1;
     122    }
    105123
     124    if ($reject) {
     125        $command .= ' -reject';
    106126        ### XXX: Need some way to know whether the exposure has already been rejected.
    107127        ### rejection flag in $exposures?
     
    126146# Put the result into the database
    127147{
    128     my $command = "$dettool -adddetrunsummary -det_id $detId -iter $iter " .
     148    my $command = "$dettool -adddetrunsummary -det_id $detId -iteration $iter " .
    129149        "-bg " . $meanStats->mean() . " -bg_stdev " . $stdevStats->mean() .
    130150        " -bg_mean_stdev " . $meanStdevStats->mean();
    131151    $command .= " -reject" if not $master;
     152
    132153    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    133154        run(command => $command, verbose => 1);
     
    136157
    137158# Re-run processing if required
    138 if (not $stop) {
    139     my $command = "$dettool -updatedetrun -det_id $detId -iter $iter";
     159{
     160    my $command = "$dettool -updatedetrun -det_id $detId";
    140161    if ($stop) {
    141162        $command .= ' -stop';
    142163    } else {
    143         $command .= ' -go';
     164        $command .= ' -again';
    144165    }
     166   
    145167    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    146168        run(command => $command, verbose => 1);
    147169    die "Unable to perform dettool -updatedetrun: $error_code\n" if not $success;
    148170}
    149 
    150171__END__
Note: See TracChangeset for help on using the changeset viewer.