IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 23, 2008, 5:10:21 PM (18 years ago)
Author:
Paul Price
Message:

Adding hostname to database values.

File:
1 edited

Legend:

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

    r17671 r17803  
    3232    'outroot=s'         => \$outroot, # Output root name
    3333    'verbose'           => \$verbose,   # Print to stdout
    34     'no-update'         => \$no_update, # Don't update the database?
     34    'no-update'         => \$no_update, # Don't update the database?
    3535    'no-op'             => \$no_op, # Don't do any operations?
    3636    'save-temps'        => \$save_temps, # Save temporary files?
     
    4141    -msg => "Required options: --stack_id --outroot",
    4242    -exitval => 3,
    43           ) unless defined $stack_id
     43          ) unless defined $stack_id
    4444    and defined $outroot;
    4545
    46 my $STATS = 
    47    [   
     46my $STATS =
     47   [
    4848       #          PPSTATS KEYWORD         STATISTIC          STACKTOOL FLAG
    4949       { name => "ROBUST_MEDIAN",   type => "mean", flag => "-bg",          dtype => "float" },
     
    5858my $stacktool = can_run('stacktool') or (warn "Can't find stacktool" and $missing_tools = 1);
    5959my $ppStack = can_run('ppStack') or (warn "Can't find ppStack" and $missing_tools = 1);
    60 if ($missing_tools) { 
     60if ($missing_tools) {
    6161    warn("Can't find required tools.");
    62     exit($PS_EXIT_CONFIG_ERROR); 
     62    exit($PS_EXIT_CONFIG_ERROR);
    6363}
    6464
    6565# Get list of components for stacking
    66 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
     66my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    6767my $files;
    6868{
     
    7070    $command .= " -dbname $dbname" if defined $dbname;
    7171    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    72         run(command => $command, verbose => $verbose);
     72        run(command => $command, verbose => $verbose);
    7373    unless ($success) {
    74         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    75         &my_die("Unable to perform stacktool -inputskyfile: $error_code", $stack_id, $error_code);
     74        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     75        &my_die("Unable to perform stacktool -inputskyfile: $error_code", $stack_id, $error_code);
    7676    }
    7777
    7878    my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
    79         &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR);
    80     $files = parse_md_list($metadata) or 
    81         &my_die("Unable to parse metadata list", $stack_id, $PS_EXIT_PROG_ERROR);
     79        &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR);
     80    $files = parse_md_list($metadata) or
     81        &my_die("Unable to parse metadata list", $stack_id, $PS_EXIT_PROG_ERROR);
    8282}
    8383
     
    8686
    8787# Parse the list of input files to get the tesselation, skycell identifiers and camera
    88 my $skycell_id;                 # Skycell identifier
    89 my $tess_id;                    # Tesselation identifier
    90 my $camera;                     # Camera
     88my $skycell_id;                 # Skycell identifier
     89my $tess_id;                    # Tesselation identifier
     90my $camera;                     # Camera
    9191foreach my $file (@$files) {
    9292    # skip warps which are speicified as 'ignored'
    9393    if ($file->{ignored}) { next; }
    9494    if (defined $tess_id) {
    95         &my_die("Tesselation identifiers don't match", $stack_id, $PS_EXIT_SYS_ERROR) unless
    96             $file->{tess_id} eq $tess_id;
     95        &my_die("Tesselation identifiers don't match", $stack_id, $PS_EXIT_SYS_ERROR) unless
     96            $file->{tess_id} eq $tess_id;
    9797    } else {
    98         $tess_id = $file->{tess_id};
     98        $tess_id = $file->{tess_id};
    9999    }
    100100    if (defined $skycell_id) {
    101         &my_die("Skycell identifiers don't match", $stack_id, $PS_EXIT_SYS_ERROR) unless
    102             $file->{skycell_id} eq $skycell_id;
     101        &my_die("Skycell identifiers don't match", $stack_id, $PS_EXIT_SYS_ERROR) unless
     102            $file->{skycell_id} eq $skycell_id;
    103103    } else {
    104         $skycell_id = $file->{skycell_id};
     104        $skycell_id = $file->{skycell_id};
    105105    }
    106106    if (defined $camera) {
    107         &my_die("Cameras don't match", $stack_id, $PS_EXIT_SYS_ERROR) unless $file->{camera} eq $camera;
     107        &my_die("Cameras don't match", $stack_id, $PS_EXIT_SYS_ERROR) unless $file->{camera} eq $camera;
    108108    } else {
    109         $camera = $file->{camera};
     109        $camera = $file->{camera};
    110110    }
    111111}
     
    116116# Generate MDC file with the inputs
    117117my ($listFile, $listName) = tempfile( "$tess_id.$skycell_id.stk$stack_id.list.XXXX",
    118                                       UNLINK => !$save_temps );
     118                                      UNLINK => !$save_temps );
    119119my $num = 0;
    120 my $inputSources;               # Sources to use as stamps
     120my $inputSources;               # Sources to use as stamps
    121121foreach my $file (@$files) {
    122122    if ($file->{ignored}) { next; }
     
    125125    $num++;
    126126
    127     my $image = $file->{uri};   # Image name
     127    my $image = $file->{uri};   # Image name
    128128    my $mask = $ipprc->filename( "PSWARP.OUTPUT.MASK", $file->{path_base} ); # Mask name
    129129    my $weight = $ipprc->filename( "PSWARP.OUTPUT.WEIGHT", $file->{path_base} ); # Weight name
     
    134134    &my_die("Weight $weight does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $weight );
    135135    &my_die("PSF $psf does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $psf );
    136    
     136
    137137    print $listFile "\tIMAGE\tSTR\t" . $image . "\n";
    138     print $listFile "\tMASK\tSTR\t" . $mask . "\n"; 
    139     print $listFile "\tWEIGHT\tSTR\t" . $weight . "\n"; 
     138    print $listFile "\tMASK\tSTR\t" . $mask . "\n";
     139    print $listFile "\tWEIGHT\tSTR\t" . $weight . "\n";
    140140    print $listFile "\tPSF\tSTR\t" . $psf . "\n";
    141141
     
    147147    # XXX details about supplying sources, etc, need to be specified in the libraries
    148148    unless (defined $inputSources) {
    149         $inputSources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $file->{path_base});
    150         &my_die("Source file $inputSources does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $inputSources );
    151     }
    152        
     149        $inputSources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $file->{path_base});
     150        &my_die("Source file $inputSources does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $inputSources );
     151    }
     152
    153153}
    154154
     
    175175
    176176    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    177         run(command => $command, verbose => $verbose);
     177        run(command => $command, verbose => $verbose);
    178178    unless ($success) {
    179         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    180         &my_die("Unable to perform ppStack: $error_code", $stack_id, $error_code);
     179        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     180        &my_die("Unable to perform ppStack: $error_code", $stack_id, $error_code);
    181181    }
    182182    &my_die("Couldn't find expected output file: $outputName", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputName);
     
    189189
    190190    # Get the statistics on the stacked image
    191     my $statsFile;              # File handle
     191    my $statsFile;              # File handle
    192192    open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $stack_id, $PS_EXIT_SYS_ERROR);
    193193    my @contents = <$statsFile>; # Contents of file
    194194    close $statsFile;
    195195    my $metadata = $mdcParser->parse(join "", @contents) or
    196         &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR);
     196        &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR);
    197197    $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $stack_id, $PS_EXIT_PROG_ERROR);
    198198}
     
    202202    # Add the stack result
    203203    {
    204         my $command = "$stacktool -addsumskyfile -stack_id $stack_id -uri $outputName -path_base $outroot";
    205         $command .= $stats->cmdflags();
    206         $command .= " -dbname $dbname" if defined $dbname;
    207        
    208         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    209             run(command => $command, verbose => $verbose);
    210         unless ($success) {
    211             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    212             &my_die("Unable to perform stacktool -addsumskyfile: $error_code", $stack_id, $error_code);
    213         }
     204        my $command = "$stacktool -addsumskyfile -stack_id $stack_id -uri $outputName -path_base $outroot";
     205        $command .= $stats->cmdflags();
     206        $command .= " -hostname $host" if defined $host;
     207        $command .= " -dbname $dbname" if defined $dbname;
     208
     209        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     210            run(command => $command, verbose => $verbose);
     211        unless ($success) {
     212            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     213            &my_die("Unable to perform stacktool -addsumskyfile: $error_code", $stack_id, $error_code);
     214        }
    214215    }
    215216
    216217    # Register the run as completed
    217218    {
    218         my $command = "$stacktool -updaterun -stack_id $stack_id -state stop"; # Command to run stacktool
    219         $command .= " -dbname $dbname" if defined $dbname;
    220 
    221         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    222             run(command => $command, verbose => $verbose);
    223         unless ($success) {
    224             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    225             warn("Unable to perform stacktool -updaterun: $error_code\n");
    226             exit($error_code);
    227         }
     219        my $command = "$stacktool -updaterun -stack_id $stack_id -state stop"; # Command to run stacktool
     220        $command .= " -dbname $dbname" if defined $dbname;
     221
     222        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     223            run(command => $command, verbose => $verbose);
     224        unless ($success) {
     225            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     226            warn("Unable to perform stacktool -updaterun: $error_code\n");
     227            exit($error_code);
     228        }
    228229    }
    229230}
     
    232233sub my_die
    233234{
    234     my $msg = shift;            # Warning message on die
    235     my $stack_id = shift;       # Stack identifier
    236     my $exit_code = shift;      # Exit code to add
     235    my $msg = shift;            # Warning message on die
     236    my $stack_id = shift;       # Stack identifier
     237    my $exit_code = shift;      # Exit code to add
    237238
    238239    warn($msg);
    239240    if (defined $stack_id and not $no_update) {
    240         my $command = "$stacktool -addsumskyfile -stack_id $stack_id -code $exit_code";
    241         $command .= " -dbname $dbname" if defined $dbname;
     241        my $command = "$stacktool -addsumskyfile -stack_id $stack_id -code $exit_code";
     242        $command .= " -hostname $host" if defined $host;
     243        $command .= " -dbname $dbname" if defined $dbname;
    242244        system ($command);
    243245    }
Note: See TracChangeset for help on using the changeset viewer.