IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12209


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

Updating to use same manner as other programs.

File:
1 edited

Legend:

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

    r12021 r12209  
    3131    );
    3232
    33 my ($cache, $exptag, $workdir, $dbname, $no_update);
     33my ($cache, $exp_tag, $workdir, $dbname, $no_update);
    3434
    3535GetOptions(
    3636    'caches'        => \$cache,
    37     'exp_tag|e=s'   => \$exptag,
     37    'exp_tag|e=s'   => \$exp_tag,
    3838    'workdir|w=s'   => \$workdir, # Working directory for output files
    3939    'dbname|d=s'    => \$dbname, # Database name   
     
    4545    -msg => "Required options: --exp_tag",
    4646    -exitval => 3,
    47 ) unless defined $exptag;
     47) unless defined $exp_tag;
    4848
    4949# Define setup
     
    103103my $imfiles;
    104104{
    105     my $command = "$regtool -processedimfile -exp_tag $exptag";
     105    my $command = "$regtool -processedimfile -exp_tag $exp_tag";
    106106    $command .= " -dbname $dbname" if defined $dbname;
    107107    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    109109    unless ($success) {
    110110        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    111         warn ("Unable to perform regtool -processedimfile on exposure id $exptag: $error_code");
     111        warn ("Unable to perform regtool -processedimfile on exposure id $exp_tag: $error_code");
    112112        exit ($error_code);
    113113    }
     
    116116    unless ($metadata) {
    117117        warn ("Unable to parse metadata config doc");
    118         &my_die ($exptag, $PS_EXIT_PROG_ERROR);
     118        &my_die ($exp_tag, $PS_EXIT_PROG_ERROR);
    119119    }
    120120    $imfiles = parse_md_list($metadata); # Data for imfiles
     
    138138        if ($values{$constant} ne $value) {
    139139            warn ("Value of $constant for $imfile->{REGISTER_CLASSID} doesn't match previous value");
    140             &my_die ($exptag, $PS_EXIT_PROG_ERROR);
     140            &my_die ($exp_tag, $PS_EXIT_PROG_ERROR);
    141141        }
    142142    }
     
    160160if ($rnd > 0.5) {
    161161    warn ("random failure");
    162     &my_die ($exptag, $PS_EXIT_DATA_ERROR);
     162    &my_die ($exp_tag, $PS_EXIT_DATA_ERROR);
    163163}
    164164}
     
    166166# Output results to the database
    167167unless ($no_update) {
    168     my @command;
    169     push @command, $regtool, '-addprocessedexp', '-exp_tag', $exptag; # Command to execute to update exposure parameters
     168    my $command = "$regtool -addprocessedexp -exp_tag $exp_tag"; # Command to execute
    170169   
    171170    # Add the values of interest
    172171    foreach my $constant (@{CONSTANTS()}) {
    173         push @command, ( '-' . $constant ), $values{$constant};
     172        my $value = $values{$constant};
     173        if ($value =~ /\s/) {
     174            # Quote spaces
     175            $value = "\'$value\'";
     176        }
     177        $command .= " -$constant $value";
    174178    }
    175179    foreach my $variable (@{VARIABLES()}) {
     
    177181        my $stats = Statistics::Descriptive::Sparse->new; # Statistics calculator
    178182        $stats->add_data(@$array);
    179         push @command, ( '-' . $variable ), $stats->mean();
     183
     184        $command .= " -$variable " . $stats->mean();
    180185    }
    181186
    182187    # Add the statistics
    183     {
    184         my $stats = Statistics::Descriptive::Sparse->new; # Statistics calculator
    185         $stats->add_data(@backgrounds);
    186         push @command, ( '-' . REGISTER_BG() ), $stats->mean();
    187         push @command, ( '-' . REGISTER_BG_MEAN_STDEV() ), ( $stats->standard_deviation() || 0 )
    188     }
    189     {
    190         my $stats = Statistics::Descriptive::Sparse->new; # Statistics calculator
    191         $stats->add_data(@variances);
    192         push @command, ( '-' . REGISTER_BG_STDEV() ), sqrt( $stats->mean() );
    193     }
     188    my $meanStats = Statistics::Descriptive::Sparse->new; # Statistics calculator
     189    $meanStats->add_data(@backgrounds);
     190    my $stdevStats = Statistics::Descriptive::Sparse->new; # Statistics calculator
     191    $stdevStats->add_data(@variances);
     192    my $bg = ($meanStats->mean() or 'NAN');
     193    my $bg_stdev = (sqrt($stdevStats->mean()) or 'NAN');
     194    my $bg_mean_stdev = ($meanStats->standard_deviation() or 'NAN');
     195    $command .= " -bg $bg -bg_stdev $bg_stdev -bg_mean_stdev $bg_mean_stdev";
    194196   
    195197    # Add the detrend flag
    196198    foreach my $detrendType (@{DETRENDS()}) {
    197199        if (lc($values{TYPE()}) =~ /$detrendType/) {
    198             push @command, DETREND_FLAG;
     200            $command .= ' ' . DETREND_FLAG;
    199201            last;
    200202        }
    201203    }
    202  
    203     # Quote arguments with whitespace
    204     for (my $i = 0; $i < scalar @command; $i++) {
    205         if ($command[$i] =~ /\s/) {
    206             $command[$i] = "\'$command[$i]\'";
    207         }
    208     }
    209 
    210     push @command, "-dbname", $dbname if defined $dbname;
     204
     205    $command .= " -dbname $dbname" if defined $dbname;
    211206
    212207    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    213         cache_run(command => \@command, verbose => 1);
     208        cache_run(command => $command, verbose => 1);
    214209    unless ($success) {
    215210        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    216         warn ("Unable to run regtool -addprocessedexp for $exptag: $error_code");
     211        warn ("Unable to run regtool -addprocessedexp for $exp_tag: $error_code");
    217212        exit($error_code);
    218213    }
     
    230225    unless (defined $imfile->{$name}) {
    231226        warn ("Couldn't find value of $name for class_id=$source");
    232         &my_die ($exptag, $PS_EXIT_PROG_ERROR);
     227        &my_die ($exp_tag, $PS_EXIT_PROG_ERROR);
    233228    }
    234229    return $imfile->{$name};
Note: See TracChangeset for help on using the changeset viewer.