IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 5, 2008, 11:43:34 AM (18 years ago)
Author:
Paul Price
Message:

Need to know the database name so that concepts (thinking specifically of CHIP.TEMP for GPC1) can be derived from the database.

File:
1 edited

Legend:

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

    r17671 r17941  
    3939    'outroot|w=s'       => \$outroot,   # output file base name
    4040    'dbname|d=s'        => \$dbname, # Database name
    41     'reduction=s'       => \$reduction, # Reduction class
     41    'reduction=s'       => \$reduction, # Reduction class
    4242    'verbose'           => \$verbose,   # Print to stdout
    4343    'no-update'         => \$no_update,
     
    4747pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    4848pod2usage( -msg => "Required options: --det_id --iteration --exp_id --exp_tag --class_id --det_type --camera --input_uri --mode --detrend --outroot (not for 'verify' mode)",
    49            -exitval => 3) unless
    50     defined $det_id    and 
    51     defined $iter      and 
    52     defined $exp_id    and 
    53     defined $exp_tag   and 
    54     defined $class_id  and 
    55     defined $det_type  and 
    56     defined $input_uri and 
    57     defined $camera    and 
    58     defined $mode      and 
    59     defined $outroot   and 
     49           -exitval => 3) unless
     50    defined $det_id    and
     51    defined $iter      and
     52    defined $exp_id    and
     53    defined $exp_tag   and
     54    defined $class_id  and
     55    defined $det_type  and
     56    defined $input_uri and
     57    defined $camera    and
     58    defined $mode      and
     59    defined $outroot   and
    6060    (defined $detrend or lc($mode) eq 'verify');
    6161
     
    6464# Recipes to use as a function of detrend type and mode
    6565$reduction = 'DETREND' unless defined $reduction;
    66 my $recipe;                     # Name of recipe to use
     66my $recipe;                     # Name of recipe to use
    6767if ($mode eq 'master') {
    6868    $recipe = uc($det_type) . '_RESID';
     
    7575
    7676# values to extract from output metadata and the stats to calculate
    77 my $STATS = 
     77my $STATS =
    7878   [
    7979       #          PPSTATS KEYWORD         STATISTIC          CHIPTOOL FLAG
    8080       { name => "ROBUST_MEDIAN",      type => "mean",  flag => "-bg",             dtype => "float" },
    8181       { name => "ROBUST_MEDIAN",      type => "stdev", flag => "-bg_mean_stdev",  dtype => "float" },
    82        { name => "ROBUST_STDEV",       type => "rms",   flag => "-bg_stdev",       dtype => "float" },
     82       { name => "ROBUST_STDEV",       type => "rms",   flag => "-bg_stdev",       dtype => "float" },
    8383       { name => "SAMPLE_SKEWNESS",    type => "mean",  flag => "-bg_skewness",    dtype => "float" },
    8484       { name => "SAMPLE_KURTOSIS",    type => "mean",  flag => "-bg_kurtosis",    dtype => "float" },
    85        { name => "FRINGE_0",           type => "mean",  flag => "-fringe_0",       dtype => "float" },
    86        { name => "FRINGE_ERR_0",       type => "rms",   flag => "-fringe_1",       dtype => "float" },
    87        { name => "FRINGE_0",           type => "stdev", flag => "-fringe_2",       dtype => "float" },
     85       { name => "FRINGE_0",           type => "mean",  flag => "-fringe_0",       dtype => "float" },
     86       { name => "FRINGE_ERR_0",       type => "rms",   flag => "-fringe_1",       dtype => "float" },
     87       { name => "FRINGE_0",           type => "stdev", flag => "-fringe_2",       dtype => "float" },
    8888       { name => "FRINGE_RESID_0",     type => "mean",  flag => "-fringe_resid_0", dtype => "float" },
    8989       { name => "FRINGE_RESID_ERR_0", type => "rms",   flag => "-fringe_resid_1", dtype => "float" },
     
    9292my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser
    9393
    94 my $BINNED_STATS = 
     94my $BINNED_STATS =
    9595   [
    9696       { name => "ROBUST_STDEV",   type => "rms",   flag => "-bin_stdev" },
     
    100100# Flags to specify the particular detrend to use
    101101use constant DETRENDS => {
    102     'bias'     => '-bias',      # Specify the bias frame
    103     'dark'     => '-dark',      # Specify the dark frame
    104     'shutter'  => '-shutter',   # Specify the shutter frame
    105     'flat'     => '-flat',      # Specify the flat frame
    106     'domeflat' => '-flat',      # Specify the flat frame
    107     'skyflat'  => '-flat',      # Specify the flat frame
    108     'fringe'   => '-fringe',    # Specify the fringe frame
    109     'mask'     => '-mask',      # Specify the mask frame
    110     'darkmask' => '-mask',      # Specify the mask frame
    111     'flatmask' => '-mask',      # Specify the mask frame
     102    'bias'     => '-bias',      # Specify the bias frame
     103    'dark'     => '-dark',      # Specify the dark frame
     104    'shutter'  => '-shutter',   # Specify the shutter frame
     105    'flat'     => '-flat',      # Specify the flat frame
     106    'domeflat' => '-flat',      # Specify the flat frame
     107    'skyflat'  => '-flat',      # Specify the flat frame
     108    'fringe'   => '-fringe',    # Specify the fringe frame
     109    'mask'     => '-mask',      # Specify the mask frame
     110    'darkmask' => '-mask',      # Specify the mask frame
     111    'flatmask' => '-mask',      # Specify the mask frame
    112112};
    113113
    114 use constant DELETE_STATS => 0; # Delete the statistics file when done?
     114use constant DELETE_STATS => 0; # Delete the statistics file when done?
    115115
    116116# Look for programs we need
     
    119119my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
    120120my $ppStats = can_run('ppStats') or (warn "Can't find ppStats" and $missing_tools = 1);
    121 if ($missing_tools) { 
     121if ($missing_tools) {
    122122    warn("Can't find required tools.");
    123     exit($PS_EXIT_CONFIG_ERROR); 
     123    exit($PS_EXIT_CONFIG_ERROR);
    124124}
    125125$ppImage .= " -dbname $dbname" if defined $dbname;
     
    147147    $command .= " -stats $outputStats";
    148148    $command .= " -tracedest $traceDest -log $logDest";
     149    $command .= " -dbname $dbname" if defined $dbname;
    149150
    150151    # Detrend to use in processing
    151152    if (lc($mode) ne 'verify') {
    152         my $detFlag = DETRENDS->{lc($det_type)};
    153         &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_PROG_ERROR) unless defined $detFlag;
    154         $command .= " $detFlag $detrend";
     153        my $detFlag = DETRENDS->{lc($det_type)};
     154        &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_PROG_ERROR) unless defined $detFlag;
     155        $command .= " $detFlag $detrend";
    155156    }
    156157
    157158    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    158         run(command => $command, verbose => $verbose);
     159        run(command => $command, verbose => $verbose);
    159160    unless ($success) {
    160         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    161         &my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $exp_id, $class_id, $error_code);
     161        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     162        &my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $exp_id, $class_id, $error_code);
    162163    }
    163164    &my_die("Couldn't find expected output file: $outputName", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputName);
     
    167168
    168169    # Load the raw output stats file
    169     my $statsFile;              # File handle
     170    my $statsFile;              # File handle
    170171    open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_SYS_ERROR);
    171172    my @contents = <$statsFile>; # Contents of file
     
    173174
    174175    # Parse the stats file contents into a metadata
    175     my $mdcParser = PS::IPP::Metadata::Config->new;     # Parser for metadata config files
     176    my $mdcParser = PS::IPP::Metadata::Config->new;     # Parser for metadata config files
    176177    my $metadata = $mdcParser->parse(join "", @contents) or &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_PROG_ERROR);
    177178
     
    182183    $command = "$ppStats -recipe PPSTATS RESIDUAL $bin2Name";
    183184    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    184         run(command => $command, verbose => $verbose);
     185        run(command => $command, verbose => $verbose);
    185186    unless ($success) {
    186         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    187         &my_die("Unable to perform ppStats: $error_code", $det_id, $iter, $exp_id, $class_id, $error_code);
     187        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     188        &my_die("Unable to perform ppStats: $error_code", $det_id, $iter, $exp_id, $class_id, $error_code);
    188189    }
    189190
     
    211212unless ($no_update) {
    212213    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    213         run(command => $command, verbose => $verbose);
     214        run(command => $command, verbose => $verbose);
    214215    unless ($success) {
    215         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    216         warn("Unable to perform dettool -addresidimfile: $error_code\n");
    217         exit($error_code);
     216        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     217        warn("Unable to perform dettool -addresidimfile: $error_code\n");
     218        exit($error_code);
    218219    }
    219220} else {
     
    224225{
    225226    my $msg = shift; # Warning message on die
    226     my $det_id = shift;         # Detrend identifier
    227     my $iter = shift;           # Iteration
     227    my $det_id = shift;         # Detrend identifier
     228    my $iter = shift;           # Iteration
    228229    my $exp_id = shift; # Exposure tag
    229230    my $class_id = shift; # Class identifier
     
    232233    carp($msg);
    233234    if (defined $det_id and defined $iter and defined $exp_id and not $no_update) {
    234         my $command = "$dettool -addresidimfile";
    235         $command .= " -det_id $det_id";
    236         $command .= " -iteration $iter";
    237         $command .= " -exp_id $exp_id";
    238         $command .= " -class_id $class_id";
    239         $command .= " -code $exit_code";
    240         $command .= " -dbname $dbname" if defined $dbname;
     235        my $command = "$dettool -addresidimfile";
     236        $command .= " -det_id $det_id";
     237        $command .= " -iteration $iter";
     238        $command .= " -exp_id $exp_id";
     239        $command .= " -class_id $class_id";
     240        $command .= " -code $exit_code";
     241        $command .= " -dbname $dbname" if defined $dbname;
    241242        system ($command);
    242243    }
Note: See TracChangeset for help on using the changeset viewer.