Changeset 17943 for trunk/ippScripts/scripts/detrend_norm_exp.pl
- Timestamp:
- Jun 5, 2008, 12:09:48 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_norm_exp.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_norm_exp.pl
r17671 r17943 28 28 my ($det_id, $iter, $det_type, $camera, $outroot, $dbname, $reduction, $verbose, $no_update, $no_op, $save_temps); 29 29 GetOptions( 30 'det_id|d=s' => \$det_id,31 'iteration|i=s' => \$iter,32 'camera|c=s' => \$camera,33 'det_type|t=s' => \$det_type,34 'outroot|w=s' => \$outroot, # output file base name35 'dbname|d=s' => \$dbname, # Database name36 'reduction|=s' => \$reduction,30 'det_id|d=s' => \$det_id, 31 'iteration|i=s' => \$iter, 32 'camera|c=s' => \$camera, 33 'det_type|t=s' => \$det_type, 34 'outroot|w=s' => \$outroot, # output file base name 35 'dbname|d=s' => \$dbname, # Database name 36 'reduction|=s' => \$reduction, 37 37 'verbose' => \$verbose, # Print to stdout 38 'no-update' => \$no_update,39 'no-op' => \$no_op,40 'save-temps' => \$save_temps, # Save temporary files?41 ) or pod2usage( 2 );38 'no-update' => \$no_update, 39 'no-op' => \$no_op, 40 'save-temps' => \$save_temps, # Save temporary files? 41 ) or pod2usage( 2 ); 42 42 43 43 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 44 44 pod2usage( -msg => "Required options: --det_id --iteration --camera --det_type --outroot", 45 -exitval => 3) unless 46 defined $det_id and 47 defined $iter and 48 defined $camera and 45 -exitval => 3) unless 46 defined $det_id and 47 defined $iter and 48 defined $camera and 49 49 defined $det_type and 50 50 defined $outroot; … … 65 65 # XXX -bg_mean_stdev should take stdev of bg_mean if bg_mean_stdev == 0 (B) 66 66 # XXX (A) if imfile.Ncomp > 1, (B) if imfile.Ncomp == 1 67 my $STATS = 68 [ 69 # KEYWORD STATISTIC CHIPTOOL FLAG70 { name => "bg", type => "mean", flag => "-bg", dtype => "float" },71 { name => "bg", type => "stdev", flag => "-bg_mean_stdev", dtype => "float" },72 { name => "bg_stdev", type => "rms", flag => "-bg_stdev", dtype => "float" },73 # { name => "bg_mean_stdev", type => "rms", flag => "-bg_mean_stdev" },74 ];67 my $STATS = 68 [ 69 # KEYWORD STATISTIC CHIPTOOL FLAG 70 { name => "bg", type => "mean", flag => "-bg", dtype => "float" }, 71 { name => "bg", type => "stdev", flag => "-bg_mean_stdev", dtype => "float" }, 72 { name => "bg_stdev", type => "rms", flag => "-bg_stdev", dtype => "float" }, 73 # { name => "bg_mean_stdev", type => "rms", flag => "-bg_mean_stdev" }, 74 ]; 75 75 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser 76 76 … … 79 79 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 80 80 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 81 if ($missing_tools) { 81 if ($missing_tools) { 82 82 warn("Can't find required tools."); 83 exit($PS_EXIT_CONFIG_ERROR); 83 exit($PS_EXIT_CONFIG_ERROR); 84 84 } 85 85 … … 90 90 $command .= " -dbname $dbname" if defined $dbname; 91 91 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 92 run(command => $command, verbose => $verbose);92 run(command => $command, verbose => $verbose); 93 93 unless ($success) { 94 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);95 &my_die("Unable to get list of normalized imfiles from dettool: $error_code", $det_id, $iter, $error_code);94 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 95 &my_die("Unable to get list of normalized imfiles from dettool: $error_code", $det_id, $iter, $error_code); 96 96 } 97 97 98 98 # convert stdout to a metadata 99 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files99 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 100 100 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 101 &my_die("Unable to parse metadata config doc", $det_id, $iter, $PS_EXIT_PROG_ERROR);101 &my_die("Unable to parse metadata config doc", $det_id, $iter, $PS_EXIT_PROG_ERROR); 102 102 103 103 # parse the file info in the metadata 104 104 $files = parse_md_list($metadata) or 105 &my_die("Unable to parse metadata list", $det_id, $iter, $PS_EXIT_PROG_ERROR);105 &my_die("Unable to parse metadata list", $det_id, $iter, $PS_EXIT_PROG_ERROR); 106 106 107 107 # parse the stats in the metadata 108 108 unless ($stats->parse($metadata)) { 109 &my_die("Unable to find all values in statistics output.\n", $det_id, $iter, $PS_EXIT_PROG_ERROR);109 &my_die("Unable to find all values in statistics output.\n", $det_id, $iter, $PS_EXIT_PROG_ERROR); 110 110 } 111 111 } … … 134 134 # Make the jpeg for binning 1 135 135 $command = "$ppImage -list $list1Name $outroot -recipe PPIMAGE $recipe1"; # Command to run 136 $command .= " -dbname $dbname" if defined $dbname; 136 137 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 137 run(command => $command, verbose => $verbose);138 run(command => $command, verbose => $verbose); 138 139 &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1Name); 139 140 140 141 # Make the jpeg for binning 2 141 142 $command = "$ppImage -list $list2Name $outroot -recipe PPIMAGE $recipe2"; # Command to run 143 $command .= " -dbname $dbname" if defined $dbname; 142 144 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 143 run(command => $command, verbose => $verbose);145 run(command => $command, verbose => $verbose); 144 146 &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2Name); 145 147 … … 158 160 unless ($no_update) { 159 161 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 160 run(command => $command, verbose => $verbose);162 run(command => $command, verbose => $verbose); 161 163 unless ($success) { 162 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);163 &my_die("Unable to perform dettool -addnormalizedexp: $error_code", $det_id, $iter, $error_code);164 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 165 &my_die("Unable to perform dettool -addnormalizedexp: $error_code", $det_id, $iter, $error_code); 164 166 } 165 167 } else { … … 170 172 { 171 173 my $msg = shift; # Warning message on die 172 my $det_id = shift; # Detrend identifier173 my $iter = shift; # Iteration174 my $det_id = shift; # Detrend identifier 175 my $iter = shift; # Iteration 174 176 my $exit_code = shift; # Exit code to add 175 177 176 178 carp($msg); 177 179 if (defined $det_id and defined $iter and not $no_update) { 178 my $command = "$dettool -addnormalizedexp";179 $command .= " -det_id $det_id";180 $command .= " -iteration $iter";181 $command .= " -code $exit_code";182 $command .= " -dbname $dbname" if defined $dbname;180 my $command = "$dettool -addnormalizedexp"; 181 $command .= " -det_id $det_id"; 182 $command .= " -iteration $iter"; 183 $command .= " -code $exit_code"; 184 $command .= " -dbname $dbname" if defined $dbname; 183 185 system ($command); 184 186 }
Note:
See TracChangeset
for help on using the changeset viewer.
