IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 5, 2008, 12:09:48 PM (18 years ago)
Author:
Paul Price
Message:

Adding -dbname for binaries. Probably not required for all of these, but it can't hurt (much).

File:
1 edited

Legend:

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

    r17671 r17943  
    33# this program has two jobs:
    44# 1: for the given exp_tag, generate the binned & mosaiced JPEG images
    5 # 2: examine the collection of per-imfile statistics and reject.  At the moment, 
     5# 2: examine the collection of per-imfile statistics and reject.  At the moment,
    66#    this program (and the database) only allows rejection at the exposure level,
    7 #    not at the imfile level. 
     7#    not at the imfile level.
    88
    99use Carp;
     
    3232
    3333use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); # option parsing
    34 use Pod::Usage qw( pod2usage ); 
     34use Pod::Usage qw( pod2usage );
    3535
    3636# parse the command-line options
     
    3838     $verbose, $no_update, $no_op, $save_temps );
    3939GetOptions(
    40            'det_id|d=s'        => \$det_id,
    41            'iteration=s'       => \$iter,
    42            'exp_id|e=s'        => \$exp_id,
    43            'exp_tag|=s'        => \$exp_tag,
    44            'det_type|t=s'      => \$det_type,
    45            'camera=s'          => \$camera,
    46            'outroot|w=s'       => \$outroot,   # output file base name
    47            'filter=s'          => \$filter,
    48            'reject'            => \$reject,
    49            'dbname|d=s'        => \$dbname, # Database name
    50            'reduction|=s'      => \$reduction,
    51            'verbose'           => \$verbose,   # Print to stdout
    52            'no-update'         => \$no_update,
    53            'no-op'             => \$no_op,
    54            'save-temps'        => \$save_temps, # Save temporary files?
    55            ) or pod2usage( 2 );
     40           'det_id|d=s'        => \$det_id,
     41           'iteration=s'       => \$iter,
     42           'exp_id|e=s'        => \$exp_id,
     43           'exp_tag|=s'        => \$exp_tag,
     44           'det_type|t=s'      => \$det_type,
     45           'camera=s'          => \$camera,
     46           'outroot|w=s'       => \$outroot,   # output file base name
     47           'filter=s'          => \$filter,
     48           'reject'            => \$reject,
     49           'dbname|d=s'        => \$dbname, # Database name
     50           'reduction|=s'      => \$reduction,
     51           'verbose'           => \$verbose,   # Print to stdout
     52           'no-update'         => \$no_update,
     53           'no-op'             => \$no_op,
     54           'save-temps'        => \$save_temps, # Save temporary files?
     55           ) or pod2usage( 2 );
    5656
    5757pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    5858pod2usage( -msg => "Required options: --det_id --iteration --exp_id --exp_tag --det_type --camera --outroot",
    59            -exitval => 3) unless
    60     defined $det_id   and 
    61     defined $iter     and 
    62     defined $exp_id   and 
    63     defined $exp_tag  and 
    64     defined $det_type and 
     59           -exitval => 3) unless
     60    defined $det_id   and
     61    defined $iter     and
     62    defined $exp_id   and
     63    defined $exp_tag  and
     64    defined $det_type and
    6565    defined $camera   and
    6666    defined $outroot;
     
    8282# XXX -bg_mean_stdev should take stdev of bg_mean if bg_mean_stdev == 0     (B)
    8383# XXX  (A) if imfile.Ncomp > 1, (B) if imfile.Ncomp == 1
    84 my $STATS = 
     84my $STATS =
    8585    [
    86         #          KEYWORD                 STATISTIC          CHIPTOOL FLAG
    87         { name => "bg",             type => "mean",  flag => "-bg",            dtype => "float" },
    88         { name => "bg_mean_stdev",  type => "stdev", flag => "-bg_mean_stdev", dtype => "float" },
    89         { name => "bg_stdev",       type => "rms",   flag => "-bg_stdev",      dtype => "float" }, 
    90         { name => "bg_skewness",    type => "mean",  flag => "-bg_skewness",   dtype => "float" }, 
    91         { name => "bg_kurtosis",    type => "mean",  flag => "-bg_kurtosis",   dtype => "float" }, 
    92         { name => "bin_stdev",      type => "rms",   flag => "-bin_stdev",     dtype => "float" },
    93         { name => "fringe_0",       type => "mean",  flag => "-fringe_0",      dtype => "float" },
    94         { name => "fringe_1",       type => "rms",   flag => "-fringe_1",      dtype => "float" },
    95         { name => "fringe_0",       type => "stdev", flag => "-fringe_2",      dtype => "float" },
    96         { name => "user_1",         type => "mean",  flag => "-user_1",        dtype => "float" }, # fringe residual
    97         { name => "user_2",         type => "rms",   flag => "-user_2",        dtype => "float" }, # fringe residual
    98         { name => "user_1",         type => "stdev", flag => "-user_3",        dtype => "float" }, # fringe residual
    99         ];
     86        #          KEYWORD                 STATISTIC          CHIPTOOL FLAG
     87        { name => "bg",             type => "mean",  flag => "-bg",            dtype => "float" },
     88        { name => "bg_mean_stdev",  type => "stdev", flag => "-bg_mean_stdev", dtype => "float" },
     89        { name => "bg_stdev",       type => "rms",   flag => "-bg_stdev",      dtype => "float" },
     90        { name => "bg_skewness",    type => "mean",  flag => "-bg_skewness",   dtype => "float" },
     91        { name => "bg_kurtosis",    type => "mean",  flag => "-bg_kurtosis",   dtype => "float" },
     92        { name => "bin_stdev",      type => "rms",   flag => "-bin_stdev",     dtype => "float" },
     93        { name => "fringe_0",       type => "mean",  flag => "-fringe_0",      dtype => "float" },
     94        { name => "fringe_1",       type => "rms",   flag => "-fringe_1",      dtype => "float" },
     95        { name => "fringe_0",       type => "stdev", flag => "-fringe_2",      dtype => "float" },
     96        { name => "user_1",         type => "mean",  flag => "-user_1",        dtype => "float" }, # fringe residual
     97        { name => "user_2",         type => "rms",   flag => "-user_2",        dtype => "float" }, # fringe residual
     98        { name => "user_1",         type => "stdev", flag => "-user_3",        dtype => "float" }, # fringe residual
     99        ];
    100100my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser
    101101
     
    104104my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
    105105my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
    106 if ($missing_tools) { 
     106if ($missing_tools) {
    107107    warn("Can't find required tools.");
    108     exit($PS_EXIT_CONFIG_ERROR); 
     108    exit($PS_EXIT_CONFIG_ERROR);
    109109}
    110110
     
    119119    $command .= " -dbname $dbname" if defined $dbname;
    120120    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    121         run(command => $command, verbose => $verbose);
     121        run(command => $command, verbose => $verbose);
    122122    unless ($success) {
    123         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    124         warn("Unable to perform dettool -residimfile: $error_code\n");
    125         exit($error_code);
     123        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     124        warn("Unable to perform dettool -residimfile: $error_code\n");
     125        exit($error_code);
    126126    }
    127127    # XXX report an error message if stdout_buf is empty
    128128
    129129    # Parse the stdout buffer into a metadata
    130     my $mdcParser = PS::IPP::Metadata::Config->new;     
     130    my $mdcParser = PS::IPP::Metadata::Config->new;
    131131    my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
    132         &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR);
     132        &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR);
    133133
    134134    # parse the file info in the metadata
    135135    $files = parse_md_list($metadata) or
    136         &my_die("Unable to parse metadata list", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR);
     136        &my_die("Unable to parse metadata list", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR);
    137137
    138138    # Parse the statistics on the residual image
     
    172172    # Make the jpeg for binning 1
    173173    $command = "$ppImage -list $list1Name $outroot -recipe PPIMAGE $recipe1"; # Command to run
     174    $command .= " -dbname $dbname" if defined $dbname;
    174175    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    175         run(command => $command, verbose => $verbose);
     176        run(command => $command, verbose => $verbose);
    176177    unless ($success) {
    177         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    178         &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_id, $error_code);
     178        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     179        &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_id, $error_code);
    179180    }
    180181    &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $exp_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1Name);
    181    
     182
    182183    # Make the jpeg for binning 2
    183184    $command = "$ppImage -list $list2Name $outroot -recipe PPIMAGE $recipe2"; # Command to run
     185    $command .= " -dbname $dbname" if defined $dbname;
    184186    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    185         run(command => $command, verbose => $verbose);
     187        run(command => $command, verbose => $verbose);
    186188    unless ($success) {
    187         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    188         &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_id, $error_code);
     189        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     190        &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_id, $error_code);
    189191    }
    190192    &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $exp_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2Name);
     
    217219foreach my $file (@$files) {
    218220    my $name      = $file->{class_id};
    219     my $mean      = $file->{bg};        # Mean for this imfile
     221    my $mean      = $file->{bg};        # Mean for this imfile
    220222    my $stdev     = $file->{bg_stdev}; # Stdev for this imfile
    221223    my $skewness  = $file->{bg_skewness}; # Skewness for this imfile
     
    227229    my $flux;
    228230    if ($file->{exp_time} == 0.0) {
    229         $flux = $mean;
    230     } else {
    231         $flux = $mean / $file->{exp_time};
     231        $flux = $mean;
     232    } else {
     233        $flux = $mean / $file->{exp_time};
    232234    }
    233235    push @fluxes, $flux;
     
    243245    # 0.0 for a bias).   in general, use with ADDITIVE components
    244246    if ($reject_imfile_mean > 0) {
    245         if (abs($mean) > $reject_imfile_mean * $stdev) {
    246             print $logFile "Rejecting exposure based on bad imfile mean for $name: ";
    247             $reject = 1;
    248         } else {
    249             print $logFile "Imfile mean for $name meets requirements: ";
    250         }
    251         print $logFile "$mean vs $reject_imfile_mean * $stdev\n";
     247        if (abs($mean) > $reject_imfile_mean * $stdev) {
     248            print $logFile "Rejecting exposure based on bad imfile mean for $name: ";
     249            $reject = 1;
     250        } else {
     251            print $logFile "Imfile mean for $name meets requirements: ";
     252        }
     253        print $logFile "$mean vs $reject_imfile_mean * $stdev\n";
    252254    }  else {
    253         print $logFile "No rejection on imfile mean for $name\n";
     255        print $logFile "No rejection on imfile mean for $name\n";
    254256    }
    255257
     
    260262    # for a bias).  in general, use with ADDITIVE components
    261263    if ($reject_imfile_flux > 0) {
    262         if (abs($flux) > $reject_imfile_flux) {
    263             print $logFile "Rejecting exposure based on bad imfile flux for $name: ";
    264             $reject = 1;
    265         } else {
    266             print $logFile "Imfile flux for $name meets requirements: ";
    267         }
    268         print $logFile "$flux vs $reject_imfile_flux\n";
     264        if (abs($flux) > $reject_imfile_flux) {
     265            print $logFile "Rejecting exposure based on bad imfile flux for $name: ";
     266            $reject = 1;
     267        } else {
     268            print $logFile "Imfile flux for $name meets requirements: ";
     269        }
     270        print $logFile "$flux vs $reject_imfile_flux\n";
    269271    }  else {
    270         print $logFile "No rejection on imfile flux for $name\n";
     272        print $logFile "No rejection on imfile flux for $name\n";
    271273    }
    272274
     
    274276    # larger than the limit
    275277    if ($reject_imfile_stdev > 0) {
    276         if ($stdev > $reject_imfile_stdev) {
    277             print $logFile "Rejecting exposure based on bad imfile stdev for $name: ";
    278             $reject = 1;
    279         } else {
    280             print $logFile "Imfile stdev for $name meets requirements: ";
    281         }
    282         print $logFile "$stdev vs $reject_imfile_stdev\n";
    283 
    284     } else {
    285         print $logFile "No rejection on imfile stdev for $name\n";
     278        if ($stdev > $reject_imfile_stdev) {
     279            print $logFile "Rejecting exposure based on bad imfile stdev for $name: ";
     280            $reject = 1;
     281        } else {
     282            print $logFile "Imfile stdev for $name meets requirements: ";
     283        }
     284        print $logFile "$stdev vs $reject_imfile_stdev\n";
     285
     286    } else {
     287        print $logFile "No rejection on imfile stdev for $name\n";
    286288    }
    287289
     
    289291    # larger than the limit
    290292    if ($reject_imfile_skewness > 0) {
    291         if ($stdev > $reject_imfile_skewness) {
    292             print $logFile "Rejecting exposure based on bad imfile skewness for $name: ";
    293             $reject = 1;
    294         } else {
    295             print $logFile "Imfile skewness for $name meets requirements: ";
    296         }
    297         print $logFile "$skewness vs $reject_imfile_skewness\n";
    298 
    299     } else {
    300         print $logFile "No rejection on imfile skewness for $name\n";
     293        if ($stdev > $reject_imfile_skewness) {
     294            print $logFile "Rejecting exposure based on bad imfile skewness for $name: ";
     295            $reject = 1;
     296        } else {
     297            print $logFile "Imfile skewness for $name meets requirements: ";
     298        }
     299        print $logFile "$skewness vs $reject_imfile_skewness\n";
     300
     301    } else {
     302        print $logFile "No rejection on imfile skewness for $name\n";
    301303    }
    302304
     
    304306    # larger than the limit
    305307    if ($reject_imfile_kurtosis > 0) {
    306         if ($stdev > $reject_imfile_kurtosis) {
    307             print $logFile "Rejecting exposure based on bad imfile kurtosis for $name: ";
    308             $reject = 1;
    309         } else {
    310             print $logFile "Imfile kurtosis for $name meets requirements: ";
    311         }
    312         print $logFile "$kurtosis vs $reject_imfile_kurtosis\n";
    313 
    314     } else {
    315         print $logFile "No rejection on imfile kurtosis for $name\n";
     308        if ($stdev > $reject_imfile_kurtosis) {
     309            print $logFile "Rejecting exposure based on bad imfile kurtosis for $name: ";
     310            $reject = 1;
     311        } else {
     312            print $logFile "Imfile kurtosis for $name meets requirements: ";
     313        }
     314        print $logFile "$kurtosis vs $reject_imfile_kurtosis\n";
     315
     316    } else {
     317        print $logFile "No rejection on imfile kurtosis for $name\n";
    316318    }
    317319
     
    319321    # component means is larger than the limit
    320322    if ($reject_imfile_meanstdev > 0) {
    321         if ($meanStdev > $reject_imfile_meanstdev) {
    322             print $logFile "Rejecting exposure based on bad imfile mean stdev for $name: ";
    323             $reject = 1;
    324         } else {
    325             print $logFile "Imfile mean stdev for $name meets requirements: ";
    326         }
    327         print $logFile "$meanStdev vs $reject_imfile_meanstdev\n";
    328     } else {
    329         print $logFile "No rejection on imfile mean stdev for $name\n";
     323        if ($meanStdev > $reject_imfile_meanstdev) {
     324            print $logFile "Rejecting exposure based on bad imfile mean stdev for $name: ";
     325            $reject = 1;
     326        } else {
     327            print $logFile "Imfile mean stdev for $name meets requirements: ";
     328        }
     329        print $logFile "$meanStdev vs $reject_imfile_meanstdev\n";
     330    } else {
     331        print $logFile "No rejection on imfile mean stdev for $name\n";
    330332    }
    331333
     
    333335    # the mean counts / total pixel variance) of the imfile component
    334336    # means are less than the limit.  this test is sensible for images
    335     # which have finite residual flux such as a flat-field image. 
     337    # which have finite residual flux such as a flat-field image.
    336338    if ($reject_imfile_snr > 0) {
    337         if ($mean < $stdev * $reject_imfile_snr) {
    338             print $logFile "Rejecting exposure based on bad imfile S/N for $name: ";
    339             $reject = 1;
    340         } else {
    341             print $logFile "Imfile S/N for $name meets requirements: ";
    342         }
    343         print $logFile "mean: $mean vs stdev*SNlimit: " . $stdev * $reject_imfile_snr . "\n";
    344     } else {
    345         print $logFile "No rejection on imfile S/N for $name\n";
     339        if ($mean < $stdev * $reject_imfile_snr) {
     340            print $logFile "Rejecting exposure based on bad imfile S/N for $name: ";
     341            $reject = 1;
     342        } else {
     343            print $logFile "Imfile S/N for $name meets requirements: ";
     344        }
     345        print $logFile "mean: $mean vs stdev*SNlimit: " . $stdev * $reject_imfile_snr . "\n";
     346    } else {
     347        print $logFile "No rejection on imfile S/N for $name\n";
    346348    }
    347349
     
    351353    # have finite residual flux such as a flat-field image.
    352354    if ($reject_imfile_bin_stdev > 0) {
    353         if ($binStdev > $reject_imfile_bin_stdev) {
    354             print $logFile "Rejecting exposure based on bad imfile binned stdev for $name: ";
    355             $reject = 1;
    356         } else {
    357             print $logFile "Imfile binned stdev for $name meets requirements: ";
    358         }
    359         print $logFile "$binStdev vs $reject_imfile_bin_stdev\n";
    360     } else {
    361         print $logFile "No rejection on imfile binned stdev for $name\n";
     355        if ($binStdev > $reject_imfile_bin_stdev) {
     356            print $logFile "Rejecting exposure based on bad imfile binned stdev for $name: ";
     357            $reject = 1;
     358        } else {
     359            print $logFile "Imfile binned stdev for $name meets requirements: ";
     360        }
     361        print $logFile "$binStdev vs $reject_imfile_bin_stdev\n";
     362    } else {
     363        print $logFile "No rejection on imfile binned stdev for $name\n";
    362364    }
    363365    if ($reject_imfile_bin_snr > 0) {
    364         if ($mean < $binStdev * $reject_imfile_bin_snr) {
    365             print $logFile "Rejecting exposure based on bad imfile binned S/N for $name: ";
    366             $reject = 1;
    367         } else {
    368             print $logFile "Imfile binned S/N for $name meets requirements: ";
    369         }
    370         print $logFile "mean: $mean vs binStdev*SNlimit: " . $binStdev * $reject_imfile_bin_snr . "\n";
    371     } else {
    372         print $logFile "No rejection on imfile binned S/N for $name\n";
     366        if ($mean < $binStdev * $reject_imfile_bin_snr) {
     367            print $logFile "Rejecting exposure based on bad imfile binned S/N for $name: ";
     368            $reject = 1;
     369        } else {
     370            print $logFile "Imfile binned S/N for $name meets requirements: ";
     371        }
     372        print $logFile "mean: $mean vs binStdev*SNlimit: " . $binStdev * $reject_imfile_bin_snr . "\n";
     373    } else {
     374        print $logFile "No rejection on imfile binned S/N for $name\n";
    373375    }
    374376}
    375377
    376378# basic ensemble stats
    377 my $mean               = $stats->value_for_flag ("-bg");
    378 my $meanStdev          = $stats->value_for_flag ("-bg_mean_stdev");
    379 my $stdev              = $stats->value_for_flag ("-bg_stdev");
    380 my $binStdev           = $stats->value_for_flag ("-bin_stdev");
     379my $mean               = $stats->value_for_flag ("-bg");
     380my $meanStdev          = $stats->value_for_flag ("-bg_mean_stdev");
     381my $stdev              = $stats->value_for_flag ("-bg_stdev");
     382my $binStdev           = $stats->value_for_flag ("-bin_stdev");
    381383my $fringe_mean        = $stats->value_for_flag ("-fringe_0");
    382384my $fringe_err         = $stats->value_for_flag ("-fringe_1");
     
    387389
    388390# other stats (flux depends on bg and exp_time)
    389 my $fluxStats = Statistics::Descriptive::Sparse->new(); # Statistics calculator for means
     391my $fluxStats = Statistics::Descriptive::Sparse->new(); # Statistics calculator for means
    390392$fluxStats->add_data(@fluxes);
    391 my $flux = $fluxStats->mean();  # Mean of the imfile means
     393my $flux = $fluxStats->mean();  # Mean of the imfile means
    392394
    393395# other stats
     
    406408    # for a bias).  in general, use with ADDITIVE components
    407409    if ($reject_exp_mean > 0) {
    408         if (abs($mean) > $reject_exp_mean * $stdev) {
    409             print $logFile "Rejecting exposure based on bad mean counts: ";
    410             $reject = 1;
    411         } else {
    412             print $logFile "Exposure mean counts meets requirements: ";
    413         }
    414         print $logFile "mean: $mean, stdev: $stdev (limit is: " . $reject_exp_mean * $stdev . ") \n";
    415     } else {
    416         print $logFile "No rejection for exp mean\n";
     410        if (abs($mean) > $reject_exp_mean * $stdev) {
     411            print $logFile "Rejecting exposure based on bad mean counts: ";
     412            $reject = 1;
     413        } else {
     414            print $logFile "Exposure mean counts meets requirements: ";
     415        }
     416        print $logFile "mean: $mean, stdev: $stdev (limit is: " . $reject_exp_mean * $stdev . ") \n";
     417    } else {
     418        print $logFile "No rejection for exp mean\n";
    417419    }
    418420
     
    423425    # for a bias).  in general, use with ADDITIVE components
    424426    if ($reject_exp_flux > 0) {
    425         if (abs($flux) > $reject_exp_flux * $stdev) {
    426             print $logFile "Rejecting exposure based on bad mean flux: ";
    427             $reject = 1;
    428         } else {
    429             print $logFile "Exposure mean flux meets requirements: ";
    430         }
    431         print $logFile "flux: $flux, stdev: $stdev (limit is: " . $reject_exp_flux * $stdev . ")\n";
    432     } else {
    433         print $logFile "No rejection for exp mean\n";
     427        if (abs($flux) > $reject_exp_flux * $stdev) {
     428            print $logFile "Rejecting exposure based on bad mean flux: ";
     429            $reject = 1;
     430        } else {
     431            print $logFile "Exposure mean flux meets requirements: ";
     432        }
     433        print $logFile "flux: $flux, stdev: $stdev (limit is: " . $reject_exp_flux * $stdev . ")\n";
     434    } else {
     435        print $logFile "No rejection for exp mean\n";
    434436    }
    435437
     
    437439    # limit
    438440    if ($reject_exp_stdev > 0) {
    439         if ($stdev > $reject_exp_stdev) {
    440             print $logFile "Rejecting exposure based on bad stdev: ";
    441             $reject = 1;
    442         } else {
    443             print $logFile "Exposure stdev meets requirements: ";
    444         }
    445         print $logFile "$stdev vs $reject_exp_stdev\n";
    446     } else {
    447         print $logFile "No rejection for exp stdev\n";
     441        if ($stdev > $reject_exp_stdev) {
     442            print $logFile "Rejecting exposure based on bad stdev: ";
     443            $reject = 1;
     444        } else {
     445            print $logFile "Exposure stdev meets requirements: ";
     446        }
     447        print $logFile "$stdev vs $reject_exp_stdev\n";
     448    } else {
     449        print $logFile "No rejection for exp stdev\n";
    448450    }
    449451
     
    451453    # than the limit
    452454    if ($reject_exp_meanstdev > 0) {
    453         if ($meanStdev > $reject_exp_meanstdev) {
    454             print $logFile "Rejecting exposure based on bad mean stdev: ";
    455             $reject = 1;
    456         } else {
    457             print $logFile "Exposure mean stdev meets requirements: ";
    458         }
    459         print $logFile "$meanStdev vs $reject_exp_meanstdev\n";
    460     } else {
    461         print $logFile "No rejection for exp mean stdev\n";
     455        if ($meanStdev > $reject_exp_meanstdev) {
     456            print $logFile "Rejecting exposure based on bad mean stdev: ";
     457            $reject = 1;
     458        } else {
     459            print $logFile "Exposure mean stdev meets requirements: ";
     460        }
     461        print $logFile "$meanStdev vs $reject_exp_meanstdev\n";
     462    } else {
     463        print $logFile "No rejection for exp mean stdev\n";
    462464    }
    463465
    464466    # reject if the signal-to-noise is insufficient
    465467    if ($reject_exp_snr > 0) {
    466         if (abs($mean) < abs($stdev * $reject_exp_snr)) {
    467             print $logFile "Rejecting exposure based on poor S/N: \n";
    468             $reject = 1;
    469         } else {
    470             print $logFile "Exposure S/N meets requirements: \n";
    471         }
    472         print $logFile "signal: $mean vs noise: $stdev (s/n limit is: $reject_exp_snr)\n";
    473     } else {
    474         print $logFile "No rejection for exp S/N\n";
     468        if (abs($mean) < abs($stdev * $reject_exp_snr)) {
     469            print $logFile "Rejecting exposure based on poor S/N: \n";
     470            $reject = 1;
     471        } else {
     472            print $logFile "Exposure S/N meets requirements: \n";
     473        }
     474        print $logFile "signal: $mean vs noise: $stdev (s/n limit is: $reject_exp_snr)\n";
     475    } else {
     476        print $logFile "No rejection for exp S/N\n";
    475477    }
    476478    # reject if the exposure ensemble stdev is deviant
    477479    if ($reject_exp_bin_stdev > 0) {
    478         if ($binStdev > $reject_exp_bin_stdev) {
    479             print $logFile "Rejecting exposure based on bad binned stdev: ";
    480             $reject = 1;
    481         } else {
    482             print $logFile "Exposure binned stdev meets requirements: ";
    483         }
    484         print $logFile "$stdev vs $reject_exp_bin_stdev\n";
    485     } else {
    486         print $logFile "No rejection for exp binned stdev\n";
     480        if ($binStdev > $reject_exp_bin_stdev) {
     481            print $logFile "Rejecting exposure based on bad binned stdev: ";
     482            $reject = 1;
     483        } else {
     484            print $logFile "Exposure binned stdev meets requirements: ";
     485        }
     486        print $logFile "$stdev vs $reject_exp_bin_stdev\n";
     487    } else {
     488        print $logFile "No rejection for exp binned stdev\n";
    487489    }
    488490    # reject if the signal-to-noise is insufficient
    489491    if ($reject_exp_bin_snr > 0) {
    490         if (abs($mean) < abs($binStdev * $reject_exp_bin_snr)) {
    491             print $logFile "Rejecting exposure based on poor binned S/N: \n";
    492             $reject = 1;
    493         } else {
    494             print $logFile "Exposure binned S/N meets requirements: \n";
    495         }
    496         print $logFile "signal: $mean vs noise: $binStdev (s/n limit is: $reject_exp_bin_snr)\n";
    497     } else {
    498         print $logFile "No rejection for exp binned S/N\n";
     492        if (abs($mean) < abs($binStdev * $reject_exp_bin_snr)) {
     493            print $logFile "Rejecting exposure based on poor binned S/N: \n";
     494            $reject = 1;
     495        } else {
     496            print $logFile "Exposure binned S/N meets requirements: \n";
     497        }
     498        print $logFile "signal: $mean vs noise: $binStdev (s/n limit is: $reject_exp_bin_snr)\n";
     499    } else {
     500        print $logFile "No rejection for exp binned S/N\n";
    499501    }
    500502
     
    510512unless ($no_update) {
    511513    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    512         run(command => $command, verbose => $verbose);
     514        run(command => $command, verbose => $verbose);
    513515    unless ($success) {
    514         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    515         warn("Unable to perform dettool -addresidexp: $error_code\n");
    516         exit($error_code);
     516        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     517        warn("Unable to perform dettool -addresidexp: $error_code\n");
     518        exit($error_code);
    517519    }
    518520} else {
     
    531533{
    532534    my $msg = shift; # Warning message on die
    533     my $det_id = shift;         # Detrend identifier
    534     my $iter = shift;           # Iteration
     535    my $det_id = shift;         # Detrend identifier
     536    my $iter = shift;           # Iteration
    535537    my $exp_id = shift; # Exposure tag
    536538    my $exit_code = shift; # Exit code to add
     
    538540    carp($msg);
    539541    if (defined $det_id and defined $iter and defined $exp_id and not $no_update) {
    540         my $command = "$dettool -addresidexp";
    541         $command .= " -det_id $det_id";
    542         $command .= " -iteration $iter";
    543         $command .= " -exp_id $exp_id";
    544         $command .= " -code $exit_code";
    545         $command .= " -dbname $dbname" if defined $dbname;
     542        my $command = "$dettool -addresidexp";
     543        $command .= " -det_id $det_id";
     544        $command .= " -iteration $iter";
     545        $command .= " -exp_id $exp_id";
     546        $command .= " -code $exit_code";
     547        $command .= " -dbname $dbname" if defined $dbname;
    546548        system ($command);
    547549    }
     
    552554sub rejection_limit
    553555{
    554     my $name = shift;           # Rejection limit to
    555     my $type = shift;           # Type of exposure
    556     my $filter = shift;         # Filter
     556    my $name = shift;           # Rejection limit to
     557    my $type = shift;           # Type of exposure
     558    my $filter = shift;         # Filter
    557559
    558560    my $value = $ipprc->rejection( $name, $det_type, $filter );
    559561    if (not defined $value) {
    560         $filter = "(no filter)" if not defined $filter;
    561         die "Unable to determine $name rejection limit for $det_type with $filter.\n";
     562        $filter = "(no filter)" if not defined $filter;
     563        die "Unable to determine $name rejection limit for $det_type with $filter.\n";
    562564    }
    563565
     
    589591## 5) is the mean stdev > limit (poor images)
    590592## 6) calculate the ensemble stdev (rms) of remaining (excluding rejects)
    591 ## 7) is the ensemble stdev > limit 
     593## 7) is the ensemble stdev > limit
    592594
    593595## for flats, the value used for stdev should be the fractional stdev
Note: See TracChangeset for help on using the changeset viewer.