IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12207


Ignore:
Timestamp:
Mar 2, 2007, 4:37:29 PM (19 years ago)
Author:
Paul Price
Message:

Updating, making consistent with other scripts.

File:
1 edited

Legend:

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

    r12021 r12207  
    8888
    8989
    90 # Switches for regtool
    91 use constant REGTOOL_MODE => '-addprocessedimfile'; # Mode for regtool
    92 use constant REGTOOL_EXPTAG => '-exp_tag'; # Switch to specify the exposure id
    93 use constant REGTOOL_CLASSID => '-class_id'; # Switch to specify the class id
    94 use constant REGTOOL_BG_MEAN => '-bg'; # Switch to add the background
    95 use constant REGTOOL_BG_STDEV => '-bg_stdev'; # Switch to add the bg stdev
    96 use constant REGTOOL_BG_MEAN_STDEV => '-bg_mean_stdev'; # Switch to add the bg mean stdev
    97 
    9890# Look for programs we need
    9991my $missing_tools;
     
    158150# Push the results into the database
    159151unless ($no_update) {
    160     my @command;
    161     push @command, $regtool, REGTOOL_MODE(), REGTOOL_EXPTAG(), $exp_tag, REGTOOL_CLASSID(), $class_id; # Command to run regtool
     152    my $command = "$regtool -addprocessedimfile -exp_tag $exp_tag -class_id $class_id"; # Command to run regtool
    162153
    163154    foreach my $constant (keys %{CONSTANTS()}) {
    164         push @command, CONSTANTS->{$constant}, ($stats->data($constant))->{value};
    165 
    166     }
     155        my $value = ($stats->data($constant))->{value};
     156        if ($value =~ /\s/) {
     157            # Quote arguments with whitespace
     158            $value = "\'$value\'";
     159        }
     160        $command .=  ' ' . CONSTANTS->{$constant} . ' ' . $value;
     161    }
     162
    167163    foreach my $variable (keys %{VARIABLES()}) {
    168164        # Just use the mean value
    169         push @command, VARIABLES->{$variable}, ($stats->data($variable))->{mean};
    170     }
    171    
    172     push @command, REGTOOL_BG_MEAN();
    173     if (defined $stats->bg_mean()) {
    174         push @command, $stats->bg_mean();
    175     } else {
    176         push @command, "NAN";
    177     }
    178     push @command, REGTOOL_BG_STDEV();
    179     if (defined($stats->bg_stdev())) {
    180         push @command, $stats->bg_stdev();
    181     } else {
    182         # Will not be defined if there is only a single imfile
    183         push @command, 0;
    184     }
    185     push @command,  REGTOOL_BG_MEAN_STDEV();
    186     if (defined $stats->bg_mean_stdev()) {
    187         push @command, $stats->bg_mean_stdev();
    188     } else {
    189         push @command, "0.0";
    190     }
    191 
    192     # Quote arguments with whitespace
    193     for (my $i = 0; $i < scalar @command; $i++) {
    194         if ($command[$i] =~ /\s/) {
    195             $command[$i] = "\'$command[$i]\'";
    196         }
    197     }
    198 
    199     push @command, "-dbname", $dbname if defined $dbname;
     165        $command .= ' ' . VARIABLES->{$variable} . ' ' . ($stats->data($variable))->{mean};
     166    }
     167
     168    my $bg = ($stats->bg_mean() or 'NAN');
     169    my $bg_stdev = ($stats->bg_stdev() or 'NAN');
     170    my $bg_mean_stdev = ($stats->bg_mean_stdev() or 'NAN');
     171    $command .= " -bg $bg -bg_stdev $bg_stdev -bg_mean_stdev $bg_mean_stdev";
     172
     173    $command .= "-dbname $dbname" if defined $dbname;
    200174
    201175    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    202         run(command => \@command, verbose => 1);
     176        run(command => $command, verbose => 1);
    203177
    204178    unless ($success) {
Note: See TracChangeset for help on using the changeset viewer.