IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 28, 2008, 5:21:54 PM (18 years ago)
Author:
Paul Price
Message:

Merging in pap_branch_080328 --- modernised ppMerge.

File:
1 edited

Legend:

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

    r16563 r17231  
    1818use PS::IPP::Metadata::Stats;
    1919use PS::IPP::Metadata::List qw( parse_md_list );
     20use File::Temp qw( tempfile );
    2021
    2122use PS::IPP::Config qw($PS_EXIT_SUCCESS
     
    3334use Pod::Usage qw( pod2usage );
    3435
    35 my ( $det_id, $iter, $class_id, $det_type, $camera, $outroot, $dbname, $reduction, $verbose, $no_update,
    36      $no_op );
     36my ( $det_id, $iter, $class_id, $det_type, $camera, $outroot, $dbname, $reduction, $verbose, $save_temps,
     37     $no_update, $no_op );
    3738GetOptions(
    3839    'det_id|d=s'        => \$det_id,
     
    4546    'reduction=s'       => \$reduction, # Reduction class for processing
    4647    'verbose'           => \$verbose,   # Print to stdout
     48    'save-temps'        => \$save_temps, # Save temporary files?
    4749    'no-update'         => \$no_update,
    4850    'no-op'             => \$no_op,
     
    7274   [   
    7375       #          KEYWORD                 STATISTIC          CHIPTOOL FLAG
    74        { name => "bg",             type => "mean",  flag => "-bg",             dtype => "float" },
    75        { name => "bg",             type => "stdev", flag => "-bg_mean_stdev",  dtype => "float" },
    76        { name => "bg_stdev",       type => "rms",   flag => "-bg_stdev",       dtype => "float" },
    77        # { name => "bg_mean_stdev",  type => "rms",   flag => "-bg_mean_stdev" },
     76       { name => "ROBUST_MEDIAN",  type => "mean",  flag => "-bg",             dtype => "float" },
     77       { name => "ROBUST_MEDIAN",  type => "stdev", flag => "-bg_mean_stdev",  dtype => "float" },
     78       { name => "ROBUST_STDEV",   type => "rms",   flag => "-bg_stdev",       dtype => "float" },
    7879   ];
    7980my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser
     81
     82# The output file rule name depends on the detrend type
     83my $FILERULES = { 'FLATMASK' => 'PPMERGE.OUTPUT.MASK',
     84                  'DARKMASK' => 'PPMERGE.OUTPUT.MASK',
     85                  'MASK'     => 'PPMERGE.OUTPUT.MASK',
     86                  'BIAS'     => 'PPMERGE.OUTPUT.BIAS',
     87                  'DARK'     => 'PPMERGE.OUTPUT.DARK',
     88                  'SHUTTER'  => 'PPMERGE.OUTPUT.SHUTTER',
     89                  'FLAT'     => 'PPMERGE.OUTPUT.FLAT',
     90                  'DOMEFLAT' => 'PPMERGE.OUTPUT.FLAT',
     91                  'SKYFLAT'  => 'PPMERGE.OUTPUT.FLAT',
     92                  'FRINGE'   => 'PPMERGE.OUTPUT.FRINGE',
     93              };
     94my $output_filerule = $FILERULES->{$det_type}; # File rule for output
     95&my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless defined $output_filerule;
    8096
    8197# Look for programs we need
     
    110126}
    111127
     128# Generate MDC file with the inputs
     129my ($listFile, $listName) = tempfile( $ipprc->file_resolve("$outroot.$class_id.list.XXXX"), UNLINK => !$save_temps );
     130my $num = 0;
     131foreach my $file (@$files) {
     132    if ($file->{ignored}) { next; }
     133
     134    print $listFile "INPUT$num\tMETADATA\n";
     135    $num++;
     136
     137    my $image = $file->{uri};   # Image name
     138    my $mask = $ipprc->filename( "PPIMAGE.OUTPUT.MASK", $file->{path_base} ); # Mask name
     139    my $weight = $ipprc->filename( "PPIMAGE.OUTPUT.WEIGHT", $file->{path_base} ); # Weight name
     140
     141    &my_die("Image $image does not exist", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $image );
     142    print $listFile "\tIMAGE\tSTR\t" . $image . "\n";
     143
     144    if ($ipprc->file_exists( $mask )) {
     145        print $listFile "\tMASK\tSTR\t" . $mask . "\n";
     146    }
     147    if ($ipprc->file_exists( $weight )) {
     148        print $listFile "\tWEIGHT\tSTR\t" . $weight . "\n";
     149    }
     150
     151    print $listFile "END\n\n";
     152}
     153close $listFile;
     154
     155
    112156# outroot examples (HOST components must be set)
    113157# file://data/ipp004.0/gpc1/20080130
     
    118162$ipprc->outroot_prepare($outroot);
    119163
    120 my $outputStack = $ipprc->filename("PPMERGE.OUTPUT", $outroot, $class_id) or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); # Output name
     164my $outputStack = $ipprc->filename($output_filerule, $outroot, $class_id) or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); # Output name
     165my $outputCount = $ipprc->filename("PPMERGE.OUTPUT.COUNT", $outroot, $class_id) or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); # Count image
     166my $outputSigma = $ipprc->filename("PPMERGE.OUTPUT.SIGMA", $outroot, $class_id) or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); # Stdev image
    121167my $outputStats = $ipprc->filename("PPIMAGE.STATS",  $outroot, $class_id) or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); # Statistics name
    122168my $traceDest   = $ipprc->filename("TRACE.IMFILE",   $outroot, $class_id) or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); # Trace messages
    123169my $logDest     = $ipprc->filename("LOG.IMFILE",     $outroot, $class_id) or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); # Log messages
    124170
    125 
    126 $command = "$ppMerge $outputStack"; # Command to run
    127 foreach my $file (@$files) {
    128     $command .= ' ' . $file->{uri};
    129 }
     171$command = "$ppMerge $listName $outroot"; # Command to run
    130172$command .= " -recipe PPMERGE $recipe";
    131173$command .= ' -type ' . uc($det_type); # Type of stacking to perform
     
    136178# Stack the files
    137179unless ($no_op) {
    138    
    139     ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     180    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    140181        run(command => $command, verbose => $verbose);
    141182    unless ($success) {
     
    144185    }
    145186    &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);
     187    &my_die("Unable to find expected output file: $outputCount\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputCount);
     188    &my_die("Unable to find expected output file: $outputSigma\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputSigma);
    146189    &my_die("Unable to find expected output file: $outputStats\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats);
    147190
Note: See TracChangeset for help on using the changeset viewer.