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

    r17762 r17941  
    3636    'outroot|w=s'       => \$outroot,   # output file base name
    3737    'dbname|d=s'        => \$dbname, # Database name
    38     'reduction=s'       => \$reduction, # Reduction class for processing
     38    'reduction=s'       => \$reduction, # Reduction class for processing
    3939    'verbose'           => \$verbose,   # Print to stdout
    4040    'save-temps'        => \$save_temps, # Save temporary files?
     
    4444
    4545pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    46 pod2usage( -msg => "Required options: --det_id --iteration --class_id --det_type --camera --outroot", 
    47            -exitval => 3) unless
    48     defined $det_id   and 
    49     defined $iter     and 
    50     defined $class_id and 
    51     defined $det_type and 
     46pod2usage( -msg => "Required options: --det_id --iteration --class_id --det_type --camera --outroot",
     47           -exitval => 3) unless
     48    defined $det_id   and
     49    defined $iter     and
     50    defined $class_id and
     51    defined $det_type and
    5252    defined $camera   and
    5353    defined $outroot;
     
    6464# XXX -bg_mean_stdev should take stdev of bg_mean if bg_mean_stdev == 0     (B)
    6565# XXX  (A) if imfile.Ncomp > 1, (B) if imfile.Ncomp == 1
    66 my $STATS = 
    67    [   
     66my $STATS =
     67   [
    6868       #          KEYWORD                 STATISTIC          CHIPTOOL FLAG
    6969       { name => "ROBUST_MEDIAN",  type => "mean",  flag => "-bg",             dtype => "float" },
     
    7777my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
    7878my $ppMerge = can_run('ppMerge') or (warn "Can't find ppMerge" and $missing_tools = 1);
    79 if ($missing_tools) { 
     79if ($missing_tools) {
    8080    warn("Can't find required tools.");
    81     exit($PS_EXIT_CONFIG_ERROR); 
     81    exit($PS_EXIT_CONFIG_ERROR);
    8282}
    8383
    8484# The output file rule name depends on the detrend type
    8585my $FILERULES = { 'FLATMASK' => 'PPMERGE.OUTPUT.MASK',
    86                   'DARKMASK' => 'PPMERGE.OUTPUT.MASK',
    87                   'MASK'     => 'PPMERGE.OUTPUT.MASK',
    88                   'BIAS'     => 'PPMERGE.OUTPUT.BIAS',
    89                   'DARK'     => 'PPMERGE.OUTPUT.DARK',
    90                   'SHUTTER'  => 'PPMERGE.OUTPUT.SHUTTER',
    91                   'FLAT'     => 'PPMERGE.OUTPUT.FLAT',
    92                   'DOMEFLAT' => 'PPMERGE.OUTPUT.FLAT',
    93                   'SKYFLAT'  => 'PPMERGE.OUTPUT.FLAT',
    94                   'FRINGE'   => 'PPMERGE.OUTPUT.FRINGE',
    95               };
     86                  'DARKMASK' => 'PPMERGE.OUTPUT.MASK',
     87                  'MASK'     => 'PPMERGE.OUTPUT.MASK',
     88                  'BIAS'     => 'PPMERGE.OUTPUT.BIAS',
     89                  'DARK'     => 'PPMERGE.OUTPUT.DARK',
     90                  'SHUTTER'  => 'PPMERGE.OUTPUT.SHUTTER',
     91                  'FLAT'     => 'PPMERGE.OUTPUT.FLAT',
     92                  'DOMEFLAT' => 'PPMERGE.OUTPUT.FLAT',
     93                  'SKYFLAT'  => 'PPMERGE.OUTPUT.FLAT',
     94                  'FRINGE'   => 'PPMERGE.OUTPUT.FRINGE',
     95              };
    9696my $output_filerule = $FILERULES->{$det_type}; # File rule for output
    9797&my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless defined $output_filerule;
     
    107107
    108108    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    109         run(command => $command, verbose => $verbose);
     109        run(command => $command, verbose => $verbose);
    110110    unless ($success) {
    111         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    112         &my_die("Unable to perform dettool -processedimfile: $error_code", $det_id, $iter, $class_id, $error_code);
    113     }
    114 
    115     my $mdcParser = PS::IPP::Metadata::Config->new;     # Parser for metadata config files
     111        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     112        &my_die("Unable to perform dettool -processedimfile: $error_code", $det_id, $iter, $class_id, $error_code);
     113    }
     114
     115    my $mdcParser = PS::IPP::Metadata::Config->new;     # Parser for metadata config files
    116116    my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
    117         &my_die("Unable to parse metadata config doc", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR);
    118     $files = parse_md_list($metadata) or 
    119         &my_die("Unable to parse metadata list", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR);
     117        &my_die("Unable to parse metadata config doc", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR);
     118    $files = parse_md_list($metadata) or
     119        &my_die("Unable to parse metadata list", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR);
    120120}
    121121
     
    129129    $num++;
    130130
    131     my $image = $file->{uri};   # Image name
     131    my $image = $file->{uri};   # Image name
    132132    my $mask = $ipprc->filename( "PPIMAGE.OUTPUT.MASK", $file->{path_base}, $class_id ); # Mask name
    133133    my $weight = $ipprc->filename( "PPIMAGE.OUTPUT.WEIGHT", $file->{path_base}, $class_id ); # Weight name
     
    137137
    138138    if ($ipprc->file_exists( $mask )) {
    139         print $listFile "\tMASK\tSTR\t" . $mask . "\n";
     139        print $listFile "\tMASK\tSTR\t" . $mask . "\n";
    140140    }
    141141    if ($ipprc->file_exists( $weight )) {
    142         print $listFile "\tWEIGHT\tSTR\t" . $weight . "\n";
     142        print $listFile "\tWEIGHT\tSTR\t" . $weight . "\n";
    143143    }
    144144
     
    166166$command .= " -recipe PPMERGE $recipe";
    167167$command .= ' -type ' . uc($det_type); # Type of stacking to perform
    168 $command .= " -stats $outputStats";     # Statistics output filename
     168$command .= " -stats $outputStats";     # Statistics output filename
    169169$command .= " -recipe PPSTATS CHIPSTATS";
    170170$command .= " -tracedest $traceDest -log $logDest";
     171$command .= " -dbname $dbname" if defined $dbname;
    171172
    172173# Stack the files
    173174unless ($no_op) {
    174175    my ( $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 perform ppMerge: $error_code", $det_id, $iter, $class_id, $error_code);
     178        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     179        &my_die("Unable to perform ppMerge: $error_code", $det_id, $iter, $class_id, $error_code);
    179180    }
    180181    &my_die("Unable to find expected output file: $outputStack\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStack);
     
    185186    # Get the statistics on the stacked image
    186187    open(my $statsFile, $ipprc->file_resolve("$outputStats")) or
    187         &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR);
     188        &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR);
    188189    my $contents = do { local $/; <$statsFile> }; # Contents of file
    189190    close($statsFile);
    190    
    191     my $mdcParser = PS::IPP::Metadata::Config->new;     # Parser for metadata config files
     191
     192    my $mdcParser = PS::IPP::Metadata::Config->new;     # Parser for metadata config files
    192193    my $metadata = $mdcParser->parse($contents) or
    193         &my_die("Unable to parse metadata config doc", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR);
     194        &my_die("Unable to parse metadata config doc", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR);
    194195
    195196    $stats->parse($metadata)  or
    196         &my_die("Unable to find all values in statistics output.", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR);
     197        &my_die("Unable to find all values in statistics output.", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR);
    197198}
    198199
     
    209210unless ($no_update) {
    210211    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    211         run(command => $command, verbose => $verbose);
     212        run(command => $command, verbose => $verbose);
    212213    unless ($success) {
    213         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    214         warn("Unable to perform dettool -addstacked: $error_code\n");
    215         exit($error_code);
     214        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     215        warn("Unable to perform dettool -addstacked: $error_code\n");
     216        exit($error_code);
    216217    }
    217218} else {
     
    222223{
    223224    my $msg = shift; # Warning message on die
    224     my $det_id = shift;         # Detrend identifier
    225     my $iter = shift;           # Iteration
     225    my $det_id = shift;         # Detrend identifier
     226    my $iter = shift;           # Iteration
    226227    my $class_id = shift; # Class identifier
    227228    my $exit_code = shift; # Exit code to add
     
    229230    carp($msg);
    230231    if (defined $det_id and defined $iter and defined $class_id and not $no_update) {
    231         my $command = "$dettool -addstacked";
    232         $command .= " -det_id $det_id";
    233         $command .= " -iteration $iter";
    234         $command .= " -class_id $class_id";
    235         $command .= " -code $exit_code";
    236         $command .= " -dbname $dbname" if defined $dbname;
    237         system ($command);
     232        my $command = "$dettool -addstacked";
     233        $command .= " -det_id $det_id";
     234        $command .= " -iteration $iter";
     235        $command .= " -class_id $class_id";
     236        $command .= " -code $exit_code";
     237        $command .= " -dbname $dbname" if defined $dbname;
     238        system ($command);
    238239    }
    239240    exit $exit_code;
Note: See TracChangeset for help on using the changeset viewer.