IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 27, 2008, 2:20:17 PM (18 years ago)
Author:
Paul Price
Message:

Changing script to correspond with interface to new and improved ppMerge.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/pap_branch_080320/ippScripts/scripts/detrend_stack.pl

    r16563 r17156  
    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,
     
    7981my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser
    8082
     83# The output file rule name depends on the detrend type
     84my %FILERULES = { 'FLATMASK' => 'PPMERGE.OUTPUT.MASK',
     85                  'DARKMASK' => 'PPMERGE.OUTPUT.MASK',
     86                  'MASK'     => 'PPMERGE.OUTPUT.MASK',
     87                  'BIAS'     => 'PPMERGE.OUTPUT.BIAS',
     88                  'DARK'     => 'PPMERGE.OUTPUT.DARK',
     89                  'SHUTTER'  => 'PPMERGE.OUTPUT.SHUTTER',
     90                  'FLAT'     => 'PPMERGE.OUTPUT.FLAT',
     91                  'DOMEFLAT' => 'PPMERGE.OUTPUT.FLAT',
     92                  'SKYFLAT'  => 'PPMERGE.OUTPUT.FLAT',
     93                  'FRINGE'   => 'PPMERGE.OUTPUT.FRINGE',
     94              };
     95my $output_filerule = $FILERULES{$det_type}; # File rule for output
     96&my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless defined $output_filerule;
     97
    8198# Look for programs we need
    8299my $missing_tools;
     
    110127}
    111128
     129# Generate MDC file with the inputs
     130my ($listFile, $listName) = tempfile( "$outroot.$class_id.list.XXXX", UNLINK => !$save_temps );
     131my $num = 0;
     132foreach my $file (@$files) {
     133    if ($file->{ignored}) { next; }
     134
     135    print $listFile "INPUT$num\tMETADATA\n";
     136    $num++;
     137
     138    my $image = $file->{uri};   # Image name
     139    my $mask = $ipprc->filename( "PPIMAGE.OUTPUT.MASK", $file->{path_base} ); # Mask name
     140    my $weight = $ipprc->filename( "PPIMAGE.OUTPUT.WEIGHT", $file->{path_base} ); # Weight name
     141
     142    &my_die("Image $image does not exist", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $image );
     143    print $listFile "\tIMAGE\tSTR\t" . $image . "\n";
     144
     145    if ($ipprc->file_exists( $mask )) {
     146        print $listFile "\tMASK\tSTR\t" . $mask . "\n";
     147    }
     148    if ($ipprc->file_exists( $weight )) {
     149        print $listFile "\tWEIGHT\tSTR\t" . $weight . "\n";
     150    }
     151
     152    print $listFile "END\n\n";
     153}
     154close $listFile;
     155
     156
    112157# outroot examples (HOST components must be set)
    113158# file://data/ipp004.0/gpc1/20080130
     
    118163$ipprc->outroot_prepare($outroot);
    119164
    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
     165my $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
     166my $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
     167my $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
    121168my $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
    122169my $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
    123170my $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
    124171
    125 
    126 $command = "$ppMerge $outputStack"; # Command to run
    127 foreach my $file (@$files) {
    128     $command .= ' ' . $file->{uri};
    129 }
     172$command = "$ppMerge $listName $outputStack"; # Command to run
    130173$command .= " -recipe PPMERGE $recipe";
    131174$command .= ' -type ' . uc($det_type); # Type of stacking to perform
     
    144187    }
    145188    &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);
     189    &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);
     190    &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);
    146191    &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);
    147192
Note: See TracChangeset for help on using the changeset viewer.