Changeset 12209
- Timestamp:
- Mar 2, 2007, 4:45:27 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/register_exp.pl (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/register_exp.pl
r12021 r12209 31 31 ); 32 32 33 my ($cache, $exp tag, $workdir, $dbname, $no_update);33 my ($cache, $exp_tag, $workdir, $dbname, $no_update); 34 34 35 35 GetOptions( 36 36 'caches' => \$cache, 37 'exp_tag|e=s' => \$exp tag,37 'exp_tag|e=s' => \$exp_tag, 38 38 'workdir|w=s' => \$workdir, # Working directory for output files 39 39 'dbname|d=s' => \$dbname, # Database name … … 45 45 -msg => "Required options: --exp_tag", 46 46 -exitval => 3, 47 ) unless defined $exp tag;47 ) unless defined $exp_tag; 48 48 49 49 # Define setup … … 103 103 my $imfiles; 104 104 { 105 my $command = "$regtool -processedimfile -exp_tag $exp tag";105 my $command = "$regtool -processedimfile -exp_tag $exp_tag"; 106 106 $command .= " -dbname $dbname" if defined $dbname; 107 107 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 109 109 unless ($success) { 110 110 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 111 warn ("Unable to perform regtool -processedimfile on exposure id $exp tag: $error_code");111 warn ("Unable to perform regtool -processedimfile on exposure id $exp_tag: $error_code"); 112 112 exit ($error_code); 113 113 } … … 116 116 unless ($metadata) { 117 117 warn ("Unable to parse metadata config doc"); 118 &my_die ($exp tag, $PS_EXIT_PROG_ERROR);118 &my_die ($exp_tag, $PS_EXIT_PROG_ERROR); 119 119 } 120 120 $imfiles = parse_md_list($metadata); # Data for imfiles … … 138 138 if ($values{$constant} ne $value) { 139 139 warn ("Value of $constant for $imfile->{REGISTER_CLASSID} doesn't match previous value"); 140 &my_die ($exp tag, $PS_EXIT_PROG_ERROR);140 &my_die ($exp_tag, $PS_EXIT_PROG_ERROR); 141 141 } 142 142 } … … 160 160 if ($rnd > 0.5) { 161 161 warn ("random failure"); 162 &my_die ($exp tag, $PS_EXIT_DATA_ERROR);162 &my_die ($exp_tag, $PS_EXIT_DATA_ERROR); 163 163 } 164 164 } … … 166 166 # Output results to the database 167 167 unless ($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 170 169 171 170 # Add the values of interest 172 171 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"; 174 178 } 175 179 foreach my $variable (@{VARIABLES()}) { … … 177 181 my $stats = Statistics::Descriptive::Sparse->new; # Statistics calculator 178 182 $stats->add_data(@$array); 179 push @command, ( '-' . $variable ), $stats->mean(); 183 184 $command .= " -$variable " . $stats->mean(); 180 185 } 181 186 182 187 # 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"; 194 196 195 197 # Add the detrend flag 196 198 foreach my $detrendType (@{DETRENDS()}) { 197 199 if (lc($values{TYPE()}) =~ /$detrendType/) { 198 push @command,DETREND_FLAG;200 $command .= ' ' . DETREND_FLAG; 199 201 last; 200 202 } 201 203 } 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; 211 206 212 207 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 213 cache_run(command => \@command, verbose => 1);208 cache_run(command => $command, verbose => 1); 214 209 unless ($success) { 215 210 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 216 warn ("Unable to run regtool -addprocessedexp for $exp tag: $error_code");211 warn ("Unable to run regtool -addprocessedexp for $exp_tag: $error_code"); 217 212 exit($error_code); 218 213 } … … 230 225 unless (defined $imfile->{$name}) { 231 226 warn ("Couldn't find value of $name for class_id=$source"); 232 &my_die ($exp tag, $PS_EXIT_PROG_ERROR);227 &my_die ($exp_tag, $PS_EXIT_PROG_ERROR); 233 228 } 234 229 return $imfile->{$name};
Note:
See TracChangeset
for help on using the changeset viewer.
