IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 4, 2007, 1:53:22 PM (19 years ago)
Author:
eugene
Message:

extensive changes to use new stats calculation tools; general cleanups

File:
1 edited

Legend:

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

    r13732 r14009  
    1111print "Starting script $0 on $host\n\n";
    1212
     13use vars qw( $VERSION );
     14$VERSION = '0.01';
     15
    1316use IPC::Cmd 0.36 qw( can_run );
    14 use IPC::Run qw ( run );
     17use IPC::Run 0.36 qw( run );
    1518use PS::IPP::Metadata::Config;
    1619use PS::IPP::Metadata::List qw( parse_md_list );
    17 use Data::Dumper;
    18 
    19 use PS::IPP::Config qw(
    20     $PS_EXIT_SUCCESS
    21     $PS_EXIT_UNKNOWN_ERROR
    22     $PS_EXIT_SYS_ERROR
    23     $PS_EXIT_CONFIG_ERROR
    24     $PS_EXIT_PROG_ERROR
    25     $PS_EXIT_DATA_ERROR
    26     $PS_EXIT_TIMEOUT_ERROR
    27     );
     20
     21use PS::IPP::Config qw($PS_EXIT_SUCCESS
     22                       $PS_EXIT_UNKNOWN_ERROR
     23                       $PS_EXIT_SYS_ERROR
     24                       $PS_EXIT_CONFIG_ERROR
     25                       $PS_EXIT_PROG_ERROR
     26                       $PS_EXIT_DATA_ERROR
     27                       $PS_EXIT_TIMEOUT_ERROR
     28                       );
    2829
    2930use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    3031use Pod::Usage qw( pod2usage );
    3132
    32 
    3333# Parse command-line arguments
    34 my ($det_id,                    # Detrend id
    35     $iter,                      # Iteration
    36     $detType,                   # Detrend type
    37     $workdir,                   # Working directory for output files
    38     $dbname,                    # Database name
    39     $no_update,                 # Don't update the database?
    40     $no_op,                     # Don't do operations
    41     );
     34my ($det_id, $iter, $detType, $workdir, $dbname, $no_update, $no_op);
    4235GetOptions(
    43         'det_id|d=s'    => \$det_id,
    44         'iteration|i=s' => \$iter,
    45         'det_type|t=s'  => \$detType,
    46         'workdir|w=s'   => \$workdir,
    47         'dbname|d=s'    => \$dbname,# Database name
    48         'no-update'     => \$no_update,
    49         'no-op'         => \$no_op,
     36        'det_id|d=s'    => \$det_id,    # Detrend id                         
     37        'iteration|i=s' => \$iter,      # Iteration                         
     38        'det_type|t=s'  => \$detType,   # Detrend type                       
     39        'workdir|w=s'   => \$workdir,   # Working directory for output files
     40        'dbname|d=s'    => \$dbname,    # Database name                     
     41        'no-update'     => \$no_update, # Don't update the database?         
     42        'no-op'         => \$no_op,     # Don't do operations               
    5043        ) or pod2usage( 2 );
    5144
     
    5346pod2usage( -msg => "Required options --det_id --iteration --det_type",
    5447           -exitval => 3,
    55            ) unless defined $det_id
     48           )
     49    unless defined $det_id
    5650    and defined $iter
    5751    and defined $detType;
    5852
    59 
    6053use constant STATISTIC => 'bg'; # Background statistic to use from the database
     54
    6155# Define which detrend types we normalise
    6256use constant NORMALIZE => {
     
    7064    };
    7165
    72 
    7366# Look for programs we need
    7467my $missing_tools;
     
    8073}
    8174
    82 &my_die("Unrecognised detrend type: $detType", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless
    83     exists NORMALIZE()->{lc($detType)};
     75&my_die("Unrecognised detrend type: $detType", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless exists NORMALIZE()->{lc($detType)};
    8476
    8577my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
     
    172164}
    173165
     166my $commandBase = "$dettool -addnormalizedstat";
     167$commandBase .= " -det_id $det_id";
     168$commandBase .= " -iteration $iter";
     169$commandBase .= " -dbname $dbname" if defined $dbname;
    174170
    175171# Process output normalisations
    176172unless ($no_update) {
    177173    foreach my $normItem (@$norms) {
     174
    178175        my $className = $normItem->{name}; # Name of component
    179176        my $normalisation = $normItem->{value}; # Normalisation for component
    180177
    181         my $command = "$dettool -addnormalizedstat -det_id $det_id -iteration $iter -class_id $className ".
    182             "-norm $normalisation"; # Command to run
    183         $command .= " -dbname $dbname" if defined $dbname;
     178        my $command = $commandBase;
     179        $command .= " -class_id $className";
     180        $command .= " -norm $normalisation";
     181
    184182        my @command = split /\s+/, $command;
    185183
     
    192190        print $stdout . "\n";
    193191    }
     192} else {
     193    print "skipping command: $commandBase\n";
    194194}
    195195
     
    203203    carp($msg);
    204204    if ($det_id and $iter and not $no_update) {
    205         my $command = "$dettool -addnormalizedstat -det_id $det_id -iteration $iter -code $exit_code";
     205        my $command = "$dettool -addnormalizedstat";
     206        $command .= " -det_id $det_id";
     207        $command .= " -iteration $iter";
     208        $command .= " -code $exit_code";
    206209        $command .= " -dbname $dbname" if defined $dbname;
    207210###        system ($command);
Note: See TracChangeset for help on using the changeset viewer.