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_imfile.pl

    r9458 r9505  
    1919use Pod::Usage qw( pod2usage );
    2020
    21 my ($det_id, $iter, $exp_tag, $det_type, $no_update, $reject);
     21my ($det_id, $iter, $exp_tag, $det_type, $camera, $filter, $no_update, $reject);
    2222GetOptions(
    2323           'det_id|d=s'        => \$det_id,
     
    2626           'det_type|t=s'      => \$det_type,
    2727           'no-update'         => \$no_update,
     28           'camera=s'          => \$camera,
     29           'filter=s'          => \$filter,
    2830           'reject'            => \$reject
    2931           ) or pod2usage( 2 );
     
    3133pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    3234pod2usage(
    33           -msg => "Required options: --det_id --iteration --exp_tag --det_type",
     35          -msg => "Required options: --det_id --iteration --exp_tag --det_type --camera",
    3436          -exitval => 3,
    3537          ) unless defined $det_id
    3638    and defined $iter
    3739    and defined $exp_tag
    38     and defined $det_type;
     40    and defined $det_type
     41    and defined $camera;
    3942
    4043use constant RECIPE1 => 'PPIMAGE_J1'; # Recipe to use for ppImage to make JPEGs
    4144use 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 criterion
    45 
    46 # The expected mean, as a function of detrend type
    47 use constant EXPECTED_MEAN => {
    48     'bias' => 0,                # Bias should be zero
    49     'dark' => 0,                # Dark should be zero
    50     '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 mean
    55 # This measures how close it is to what's expected
    56 use constant REJECT_IMFILE_MEAN => {
    57     'bias' => 0,                # Should be fairly flat; some CRs
    58     'dark' => 0,                # Lots of CRs
    59     '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 ADUs
    64 # This measures how much variation there is in each imfile
    65 use constant REJECT_IMFILE_STDEV => {
    66     'bias' => 15,               # Should be fairly flat; some CRs
    67     'dark' => 0,                # Lots of CRs
    68     'shutter' => undef,         # Can be significant structure
    69     'flat' => 0         # Stars and galaxies
    70     };
    71 
    72 # Rejection threshold for the mean of the exposure, in terms of the standard deviation of the exposure
    73 # This measures how close it is to what's expected
    74 use constant REJECT_EXPOSURE_MEAN => {
    75     'bias' => 0,                # Should be little variation between chips
    76     'dark' => 0,                # Could be some glow on some chips
    77     '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 ADUs
    82 # This measures how much variation there is across the imfiles
    83 use constant REJECT_EXPOSURE_STDEV => {
    84     'bias' => 15,               # Should be little variation between chips
    85     'dark' => 0,                # Could be some glow on some chips
    86     'shutter' => undef,         # Can be significant structure
    87     'flat' => 0                 # Could be features on some chips, but all should be about the same
    88     };
    89 
    90 # Rejection threshold for the stdev of the exposure, in ADUs
    91 # This measures how much variation there is across the imfiles
    92 use constant REJECT_EXPOSURE_MEAN_STDEV => {
    93     'bias' => 0,                # Should be little variation between chips
    94     'dark' => 0,                # Could be some glow on some chips
    95     'shutter' => undef,         # Can be significant structure
    96     'flat' => 0                 # Could be features on some chips, but all should be about the same
    97     };
    98 
    9945
    10046# Look for programs we need
     
    13177open my $list2File, '>' . $list2Name;
    13278foreach 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");
    13581    push @means, $file->{bg};
    13682    ## calculate the root-mean-square of the bd_stdevs
     
    160106}
    161107
    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);
     109my $expected = rejection_limit( 'EXPECTED', $det_type, $filter ); # Expected mean
     110# Rejection thresholds
     111my $reject_imfile_mean   = rejection_limit( 'IMFILE.MEAN',   $det_type, $filter );
     112my $reject_imfile_stdev  = rejection_limit( 'IMFILE.STDEV',  $det_type, $filter );
     113my $reject_exp_mean      = rejection_limit( 'EXP.MEAN',      $det_type, $filter );
     114my $reject_exp_stdev     = rejection_limit( 'EXP.STDEV',     $det_type, $filter );
     115my $reject_exp_meanstdev = rejection_limit( 'EXP.MEANSTDEV', $det_type, $filter );
    175116
    176117# Reject based on the stats of the imfiles
     
    179120for (my $i = 0; $i < scalar @means; $i++) {
    180121    my $mean = $means[$i];      # Mean for this imfile
    181     $mean -= EXPECTED_MEAN->{$det_type} if defined EXPECTED_MEAN->{$det_type};
     122    $mean -= $expected;
    182123    my $stdev = sqrt($variances[$i]);   # Stdev for this imfile
    183124
    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) {
    186127            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";
    188129            $reject = 1;
    189130            last;
     
    192133        print "no rejection for imfile mean\n";
    193134    }
    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) {
    196137            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";
    198139            $reject = 1;
    199140            last;
     
    221162## Reject based on the exposure ensemble stats
    222163# reject if the exposure ensemble mean is deviant
    223 if (REJECT_EXPOSURE_MEAN->{$det_type}) {
    224     if (abs($mean) > REJECT_EXPOSURE_MEAN->{$det_type}) {
     164if ($reject_exp_mean) {
     165    if (abs($mean) > $reject_exp_mean) {
    225166        print "Rejecting exposure based on bad mean: " . ($mean / $stdev) . " vs " .
    226             REJECT_EXPOSURE_MEAN->{$det_type} . "\n";
     167            $reject_exp_mean . "\n";
    227168        $reject = 1;
    228169    }
     
    231172}
    232173# reject if the exposure ensemble stdev is deviant
    233 if (REJECT_EXPOSURE_STDEV->{$det_type}) {
    234     if ($stdev > REJECT_EXPOSURE_STDEV->{$det_type}) {
     174if ($reject_exp_stdev) {
     175    if ($stdev > $reject_exp_stdev) {
    235176        print "Rejecting exposure based on bad mean stdev: " . $stdev . " vs " .
    236             REJECT_EXPOSURE_STDEV->{$det_type} . "\n";
     177            $reject_exp_stdev . "\n";
    237178        $reject = 1;
    238179    }
     
    241182}
    242183# 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}) {
     184if ($reject_exp_meanstdev) {
     185    if ($meanStdev > $reject_exp_meanstdev) {
    245186        print "Rejecting exposure based on bad mean stdev: " . $meanStdev . " vs " .
    246             REJECT_EXPOSURE_MEAN_STDEV->{$det_type} . "\n";
     187            $reject_exp_meanstdev . "\n";
    247188        $reject = 1;
    248189    }
     
    268209
    269210END { system("sync") == 0 or die "failed to execute sync: $!" }
     211
     212
     213# Retrieve the requested rejection limit, dying if not extant
     214sub 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
    270231
    271232__END__
Note: See TracChangeset for help on using the changeset viewer.