IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 21, 2010, 11:35:15 AM (16 years ago)
Author:
Paul Price
Message:

Add date of processing to output log.

File:
1 edited

Legend:

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

    r17671 r27718  
    77use Sys::Hostname;
    88my $host = hostname();
     9my $date = `date`;
    910print "\n\n";
    10 print "Starting script $0 on $host\n\n";
     11print "Starting script $0 on $host at $date\n\n";
    1112
    1213use vars qw( $VERSION );
     
    3233    $workdir, $dbname, $no_update);
    3334GetOptions(
    34            'det_type=s'    => \$det_type, # Detrend type for new detrend
    35            'filelevel=s'   => \$filelevel, # File level for new detrend
    36            'inst=s'        => \$inst, # Instrument for new detrend
    37            'telescope=s'   => \$telescope, # Telescope for new detrend
    38            'filter=s'      => \$filter, # Filter name for new detrend
    39            'det_id1=s'     => \$det_id1, # Detrend id for detrend 1
    40            'iteration1=s'  => \$iter1, # Iteration for detrend 1
    41            'det_id2=s'     => \$det_id2, # Detrend id for detrend 2
    42            'iteration2=s'  => \$iter2, # Iteration for detrend 2
    43            'operation=s'   => \$operation, # Operation to perform on files
    44            'mask'          => \$mask, # Operation is on a mask
    45            'workdir=s'     => \$workdir, # Working directory for output files
    46            'dbname=s'      => \$dbname, # Database name
    47            'no-update'     => \$no_update, # Don't update the database
    48            ) or pod2usage( 2 );
     35           'det_type=s'    => \$det_type, # Detrend type for new detrend
     36           'filelevel=s'   => \$filelevel, # File level for new detrend
     37           'inst=s'        => \$inst, # Instrument for new detrend
     38           'telescope=s'   => \$telescope, # Telescope for new detrend
     39           'filter=s'      => \$filter, # Filter name for new detrend
     40           'det_id1=s'     => \$det_id1, # Detrend id for detrend 1
     41           'iteration1=s'  => \$iter1, # Iteration for detrend 1
     42           'det_id2=s'     => \$det_id2, # Detrend id for detrend 2
     43           'iteration2=s'  => \$iter2, # Iteration for detrend 2
     44           'operation=s'   => \$operation, # Operation to perform on files
     45           'mask'          => \$mask, # Operation is on a mask
     46           'workdir=s'     => \$workdir, # Working directory for output files
     47           'dbname=s'      => \$dbname, # Database name
     48           'no-update'     => \$no_update, # Don't update the database
     49           ) or pod2usage( 2 );
    4950
    5051pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    5152pod2usage( -msg => "Required options --det_type --filelevel --inst --telescope --det_id1 --iteration1 --det_id2 --iteration2 --workdir",
    52            -exitval => 3,
    53            )
     53           -exitval => 3,
     54           )
    5455    unless defined $det_type
    5556    and defined $filelevel
     
    6566$ipprc->define_camera($inst);
    6667
    67 my $STATS = 
    68    [   
     68my $STATS =
     69   [
    6970       #          PPSTATS KEYWORD         STATISTIC          CHIPTOOL FLAG
    7071       { name => "ROBUST_MEDIAN",  type => "mean",  flag => "-bg",             dtype => "float" },
     
    9091die("File lists for detrends have differing lengths") unless scalar keys %$files1 == scalar keys %$files2;
    9192
    92 my ($det_id, $iter);          # Detrend identifier for the new detrend
     93my ($det_id, $iter);          # Detrend identifier for the new detrend
    9394unless ($no_update) {
    9495    my $command = "$dettool -register_detrend -det_type $det_type -filelevel $filelevel -workdir $workdir " .
    95         "-inst $inst -telescope $telescope"; # Command to run
     96        "-inst $inst -telescope $telescope"; # Command to run
    9697    $command .= " -filter $filter" if defined $filter;
    9798    $command .= " -dbname $dbname" if defined $dbname;
    9899    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    99         run(command => $command, verbose => 1);
     100        run(command => $command, verbose => 1);
    100101    unless ($success) {
    101         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    102         die("Unable to run dettool -register_detrend: $error_code");
     102        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     103        die("Unable to run dettool -register_detrend: $error_code");
    103104    }
    104105
     
    137138    $command .= " -dbname $dbname" if defined $dbname;
    138139    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    139         run(command => $command, verbose => 1);
     140        run(command => $command, verbose => 1);
    140141    unless ($success) {
    141         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    142         die("Unable to run ppArith: $error_code");
     142        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     143        die("Unable to run ppArith: $error_code");
    143144    }
    144145
     
    149150    my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser
    150151    {
    151         my $statsFile;          # File handle
    152         open $statsFile, $ipprc->file_resolve($outStats) or die("Can't open stats file $outStats: $!");
    153         my @contents = <$statsFile>; # Contents of file
    154         close $statsFile;
    155        
    156         my $metadata = $mdcParser->parse(join "", @contents) or die("Unable to parse metadata config doc");
    157 
    158         unless ($stats->parse($metadata)) {
    159             &my_die("Failure extracting metadata from the statistics output file.\n");
    160         }
     152        my $statsFile;          # File handle
     153        open $statsFile, $ipprc->file_resolve($outStats) or die("Can't open stats file $outStats: $!");
     154        my @contents = <$statsFile>; # Contents of file
     155        close $statsFile;
     156
     157        my $metadata = $mdcParser->parse(join "", @contents) or die("Unable to parse metadata config doc");
     158
     159        unless ($stats->parse($metadata)) {
     160            &my_die("Failure extracting metadata from the statistics output file.\n");
     161        }
    161162    }
    162163
    163164    # Register the imfile
    164165    unless ($no_update) {
    165         my $command = "$dettool -register_detrend_imfile -det_id $det_id "; # Command to run
    166         $command .= " -class_id $class_id -uri $outName -path_base $outRoot";
    167         $command .= $stats->cmdflags();
    168         $command .= " -dbname $dbname" if defined $dbname;
    169         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    170             run(command => $command, verbose => 1);
    171         unless ($success) {
    172             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    173             die("Unable to run dettool -register_detrend_imfile: $error_code");
    174         }
     166        my $command = "$dettool -register_detrend_imfile -det_id $det_id "; # Command to run
     167        $command .= " -class_id $class_id -uri $outName -path_base $outRoot";
     168        $command .= $stats->cmdflags();
     169        $command .= " -dbname $dbname" if defined $dbname;
     170        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     171            run(command => $command, verbose => 1);
     172        unless ($success) {
     173            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     174            die("Unable to run dettool -register_detrend_imfile: $error_code");
     175        }
    175176    }
    176177}
     
    183184sub filelist
    184185{
    185     my $det_id = shift;         # Detrend identifier
    186     my $iter = shift;           # Iteration
     186    my $det_id = shift;         # Detrend identifier
     187    my $iter = shift;           # Iteration
    187188
    188189    my $command = "$detselect -select -det_id $det_id -iteration $iter"; # Command to run
    189190    $command .= " -dbname $dbname" if defined $dbname;
    190191    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    191         run(command => $command, verbose => 1);
     192        run(command => $command, verbose => 1);
    192193    unless ($success) {
    193         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    194         die("Unable to run detselect: $error_code");
     194        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     195        die("Unable to run detselect: $error_code");
    195196    }
    196197
     
    202203
    203204    foreach my $item ( @$list ) {
    204         my $class_id = $item->{class_id};
    205         die("Multiple definitions of class_id=$class_id found for det_id=$det_id, iteration=$iter\n") if
    206             defined $files{$class_id};
    207         $files{$class_id} = parse_md_list($md);
     205        my $class_id = $item->{class_id};
     206        die("Multiple definitions of class_id=$class_id found for det_id=$det_id, iteration=$iter\n") if
     207            defined $files{$class_id};
     208        $files{$class_id} = parse_md_list($md);
    208209    }
    209210
Note: See TracChangeset for help on using the changeset viewer.