Changeset 14009 for trunk/ippScripts/scripts/detrend_norm_calc.pl
- Timestamp:
- Jul 4, 2007, 1:53:22 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_norm_calc.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_norm_calc.pl
r13732 r14009 11 11 print "Starting script $0 on $host\n\n"; 12 12 13 use vars qw( $VERSION ); 14 $VERSION = '0.01'; 15 13 16 use IPC::Cmd 0.36 qw( can_run ); 14 use IPC::Run qw( run );17 use IPC::Run 0.36 qw( run ); 15 18 use PS::IPP::Metadata::Config; 16 19 use 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 21 use 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 ); 28 29 29 30 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 30 31 use Pod::Usage qw( pod2usage ); 31 32 32 33 33 # 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 ); 34 my ($det_id, $iter, $detType, $workdir, $dbname, $no_update, $no_op); 42 35 GetOptions( 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 name48 '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 50 43 ) or pod2usage( 2 ); 51 44 … … 53 46 pod2usage( -msg => "Required options --det_id --iteration --det_type", 54 47 -exitval => 3, 55 ) unless defined $det_id 48 ) 49 unless defined $det_id 56 50 and defined $iter 57 51 and defined $detType; 58 52 59 60 53 use constant STATISTIC => 'bg'; # Background statistic to use from the database 54 61 55 # Define which detrend types we normalise 62 56 use constant NORMALIZE => { … … 70 64 }; 71 65 72 73 66 # Look for programs we need 74 67 my $missing_tools; … … 80 73 } 81 74 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)}; 84 76 85 77 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 172 164 } 173 165 166 my $commandBase = "$dettool -addnormalizedstat"; 167 $commandBase .= " -det_id $det_id"; 168 $commandBase .= " -iteration $iter"; 169 $commandBase .= " -dbname $dbname" if defined $dbname; 174 170 175 171 # Process output normalisations 176 172 unless ($no_update) { 177 173 foreach my $normItem (@$norms) { 174 178 175 my $className = $normItem->{name}; # Name of component 179 176 my $normalisation = $normItem->{value}; # Normalisation for component 180 177 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 184 182 my @command = split /\s+/, $command; 185 183 … … 192 190 print $stdout . "\n"; 193 191 } 192 } else { 193 print "skipping command: $commandBase\n"; 194 194 } 195 195 … … 203 203 carp($msg); 204 204 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"; 206 209 $command .= " -dbname $dbname" if defined $dbname; 207 210 ### system ($command);
Note:
See TracChangeset
for help on using the changeset viewer.
