IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 15, 2007, 2:23:33 PM (19 years ago)
Author:
Paul Price
Message:

Adding --no-op option which turns off processing (so one can track only the database work flow) for everything except the phase 0 scripts (need to have some real data in the database in order to track it).

File:
1 edited

Legend:

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

    r11831 r11837  
    3131
    3232# Parse command-line arguments
    33 my ($detId,                     # Detrend id
     33my ($det_id,                    # Detrend id
    3434    $iter,                      # Iteration
    3535    $detType,                   # Detrend type
    3636    $workdir,                   # Working directory for output files
    3737    $dbname,                    # Database name
    38     $no_update                  # Don't update the database?
     38    $no_update,                 # Don't update the database?
     39    $no_op,                     # Don't do operations
    3940    );
    4041GetOptions(
    41         'det_id|d=s'    => \$detId,
     42        'det_id|d=s'    => \$det_id,
    4243        'iteration|i=s' => \$iter,
    4344        'det_type|t=s'  => \$detType,
    4445        'workdir|w=s'   => \$workdir,
    4546        'dbname|d=s'    => \$dbname,# Database name
    46         'no-update'     => \$no_update
     47        'no-update'     => \$no_update,
     48        'no-op'         => \$no_op,
    4749        ) or pod2usage( 2 );
    4850
     
    5052pod2usage( -msg => "Required options --det_id --iteration --det_type",
    5153           -exitval => 3,
    52            ) unless defined $detId
     54           ) unless defined $det_id
    5355    and defined $iter
    5456    and defined $detType;
     
    8587my @files;                      # The input files
    8688{
    87     my $command = "$dettool -processedimfile -det_id $detId"; # Command to run
     89    my $command = "$dettool -processedimfile -det_id $det_id"; # Command to run
    8890    $command .= " -dbname $dbname" if defined $dbname;
    8991    my @command = split /\s+/, $command;
     
    9193    print "Running [$command]...\n";
    9294    if (not run(\@command, \$stdin, \$stdout, \$stderr)) {
    93         &my_die("Unable to perform dettool -processedimfile on detrend $detId/$iter: $?",
     95        &my_die("Unable to perform dettool -processedimfile on detrend $det_id/$iter: $?",
    9496                $det_id, $iter, $PS_EXIT_SYS_ERROR);
    9597    }
     
    115117
    116118my $norms;                      # MDC with normalisations
    117 if (NORMALIZE()->{lc($detType)}) {
     119if (NORMALIZE()->{lc($detType)} and not $no_op) {
    118120
    119121    my %matrix; # Matrix of statistics as a function of exposures and classes
    120122    foreach my $file (@files) {
    121         my $expTag = $file->{'exp_tag'}; # Exposure ID
    122         my $classId = $file->{'class_id'}; # Class ID
     123        my $exp_tag = $file->{'exp_tag'}; # Exposure ID
     124        my $class_id = $file->{'class_id'}; # Class ID
    123125        my $stat = $file->{STATISTIC()}; # Statistic of interest
    124126       
    125127        # Create matrix elements
    126         $matrix{$expTag} = {} if not defined $matrix{$expTag};
    127         $matrix{$expTag}->{$classId} = $stat;
     128        $matrix{$exp_tag} = {} if not defined $matrix{$exp_tag};
     129        $matrix{$exp_tag}->{$class_id} = $stat;
    128130    }
    129131   
    130132    # Generate the input for ppNormCalc
    131133    my $normData;                       # Normalisation data
    132     foreach my $expTag (keys %matrix) {
    133         $normData .= "$expTag\tMETADATA\n";
    134         foreach my $classId (keys %{$matrix{$expTag}}) {
    135             $normData .= "\t" . $classId . "\tF32\t" . $matrix{$expTag}->{$classId} . "\n";
     134    foreach my $exp_tag (keys %matrix) {
     135        $normData .= "$exp_tag\tMETADATA\n";
     136        foreach my $class_id (keys %{$matrix{$exp_tag}}) {
     137            $normData .= "\t" . $class_id . "\tF32\t" . $matrix{$exp_tag}->{$class_id} . "\n";
    136138        }
    137139        $normData .= "END\n\n";
     
    157159    my %classes;                # List of unique classes
    158160    foreach my $file (@files) {
    159         my $classId = $file->{'class_id'}; # Class Id
    160         $classes{$classId} = 1;
     161        my $class_id = $file->{'class_id'}; # Class Id
     162        $classes{$class_id} = 1;
    161163    }
    162164   
    163     foreach my $classId (keys %classes) {
     165    foreach my $class_id (keys %classes) {
    164166        my %mdValue;    # Metadata value for this class id
    165         $mdValue{name} = $classId;
     167        $mdValue{name} = $class_id;
    166168        $mdValue{value} = 1.0;
    167169        push @$norms, \%mdValue;
     
    176178        my $normalisation = $normItem->{value}; # Normalisation for component
    177179
    178         my $command = "$dettool -addnormalizedstat -det_id $detId -iteration $iter -class_id $className ".
     180        my $command = "$dettool -addnormalizedstat -det_id $det_id -iteration $iter -class_id $className ".
    179181            "-norm $normalisation"; # Command to run
    180182        $command .= " -dbname $dbname" if defined $dbname;
     
    199201
    200202    warn($msg);
    201     if ($det_id and $iter and $class_id and not $no_update) {
     203    if ($det_id and $iter and not $no_update) {
    202204        my $command = "$dettool -addnormalizedstat -det_id $det_id -iteration $iter -code $exit_code";
    203205        $command .= " -dbname $dbname" if defined $dbname;
Note: See TracChangeset for help on using the changeset viewer.