IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 4, 2007, 10:11:28 AM (19 years ago)
Author:
Paul Price
Message:

Updating script to use ppStack, and new interface (specify inputs via MDC file).

File:
1 edited

Legend:

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

    r13275 r13612  
    1818use PS::IPP::Metadata::List qw( parse_md_list );
    1919use Data::Dumper;
     20use File::Temp qw( tempfile );
    2021
    2122use PS::IPP::Config qw($PS_EXIT_SUCCESS
     
    5152my $missing_tools;
    5253my $stacktool = can_run('stacktool') or (warn "Can't find stacktool" and $missing_tools = 1);
    53 my $ppStac = can_run('ppStac') or (warn "Can't find ppStac" and $missing_tools = 1);
     54my $ppStack = can_run('ppStack') or (warn "Can't find ppStack" and $missing_tools = 1);
    5455if ($missing_tools) {
    5556    warn("Can't find required tools.");
     
    7980    scalar @$files >= 2;
    8081
    81 # Parse the list of input files, and get the skycell identifier
    82 my $inputList;                  # List of input files
     82# Parse the list of input files to get the tesselation, skycell identifiers and camera
    8383my $skycell_id;                 # Skycell identifier
    8484my $tess_id;                    # Tesselation identifier
    8585my $camera;                     # Camera
    8686foreach my $file (@$files) {
    87     $inputList .= $file->{uri} . ' ';
    8887    if (defined $tess_id) {
    8988        &my_die("Tesselation identifiers don't match", $stack_id, $PS_EXIT_SYS_ERROR) unless
     
    107106&my_die("Can't find camera", $stack_id, $PS_EXIT_SYS_ERROR) unless $camera;
    108107$ipprc->define_camera($camera);
     108
     109# Generate MDC file with the inputs
     110my ($listFile, $listName) = tempfile( "$tess_id.$skycell_id.stk$stack_id.list.XXXX", UNLINK => 1 );
     111my $num = 0;
     112foreach my $file (@$files) {
     113    print $listFile "INPUT$num\tMETADATA\n";
     114    $num++;
     115    print $listFile "\tIMAGE\tSTR\t" . $file->{uri} . "\n";
     116
     117    ### XXX NEED TO UPDATE THESE appropriately
     118    print $listFile "\tMASK\tSTR\t" . "NULL" . "\n";
     119    print $listFile "\tSEEING\tF32\t" . 1.0 . "\n";
     120    print $listFile "\tWEIGHT\tF32\t" . 1.0 . "\n";
     121    print $listFile "\tSCALE\tF32\t" . 1.0 . "\n";
     122
     123    print $listFile "END\n\n";
     124}
    109125
    110126# Get the output filenames
     
    119135my $stats = PS::IPP::Metadata::Stats->new(); # Stats parser
    120136unless ($no_op) {
    121     my $command = "$ppStac $outputName $inputList"; # Command to run pois
     137    my $command = "$ppStack $listName $outputName -stat $outputStats"; # Command to run pois
    122138
    123139    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    130146#    &my_die("Couldn't find expected output file: $bin1Name",    $stack_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin1Name);
    131147#    &my_die("Couldn't find expected output file: $bin2Name",    $stack_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin2Name);
    132 #    &my_die("Couldn't find expected output file: $outputStats", $stack_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats);
    133 
    134     # Get the statistics on the residual image
    135     if (0) { ### Disabled because ppStac doesn't output stats yet
    136         my $statsFile;          # File handle
    137         open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $stack_id, $PS_EXIT_SYS_ERROR);
    138         my @contents = <$statsFile>; # Contents of file
    139         close $statsFile;
    140         my $metadata = $mdcParser->parse(join "", @contents) or
    141             &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR);
    142         $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $stack_id, $PS_EXIT_PROG_ERROR);
    143     }
     148    &my_die("Couldn't find expected output file: $outputStats", $stack_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats);
     149
     150    # Get the statistics on the stacked image
     151    my $statsFile;              # File handle
     152    open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $stack_id, $PS_EXIT_SYS_ERROR);
     153    my @contents = <$statsFile>; # Contents of file
     154    close $statsFile;
     155    my $metadata = $mdcParser->parse(join "", @contents) or
     156        &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR);
     157    $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $stack_id, $PS_EXIT_PROG_ERROR);
    144158}
    145159
Note: See TracChangeset for help on using the changeset viewer.