Changeset 14048 for trunk/ippScripts/scripts/detrend_process_exp.pl
- Timestamp:
- Jul 6, 2007, 3:44:38 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_process_exp.pl (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_process_exp.pl
r14009 r14048 16 16 use IPC::Cmd 0.36 qw( can_run run ); 17 17 use PS::IPP::Metadata::Config; 18 use PS::IPP::Metadata::Stats; 19 18 20 use PS::IPP::Metadata::List qw( parse_md_list ); 19 21 use File::Temp qw( tempfile ); … … 33 35 use Pod::Usage qw( pod2usage ); 34 36 35 my ($det_id, $ det_type, $exp_tag, $camera, $dbname, $workdir, $no_update, $no_op);37 my ($det_id, $exp_id, $det_type, $exp_tag, $camera, $dbname, $workdir, $reduction, $no_update, $no_op); 36 38 GetOptions( 37 39 'det_id|d=s' => \$det_id, 38 40 'det_type|t=s' => \$det_type, 39 'exp_tag|e=s' => \$exp_tag, 41 'exp_id|d=s' => \$exp_id, 42 'exp_tag|=s' => \$exp_tag, 40 43 'camera|c=s' => \$camera, 41 44 'dbname|d=s' => \$dbname, # Database name 42 45 'workdir|w=s' => \$workdir, # Working directory, for output files 46 'reduction|=s' => \$reduction, 43 47 'no-update' => \$no_update, 44 48 'no-op' => \$no_op, … … 46 50 47 51 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 48 pod2usage( -msg => "Required options: --det_id --det_type --exp_ tag --camera",52 pod2usage( -msg => "Required options: --det_id --det_type --exp_id --exp_tag --camera", 49 53 -exitval => 3) 50 54 unless defined $det_id 51 55 and defined $det_type 56 and defined $exp_id 52 57 and defined $exp_tag 53 58 and defined $camera; … … 58 63 $reduction = 'DETREND' unless defined $reduction; 59 64 60 my $recipe1 = $ipprc->reduction($reduction, 'JPEG_BIN1_IMAGE ' . uc($det_type); # Recipe to use61 &my_die("Unrecognised detrend type: $det_type", $det_id, $ iter, $PS_EXIT_PROG_ERROR) unless defined $recipe1;62 63 my $recipe2 = $ipprc->reduction($reduction, 'JPEG_BIN2_IMAGE ' . uc($det_type); # Recipe to use64 &my_die("Unrecognised detrend type: $det_type", $det_id, $ iter, $PS_EXIT_PROG_ERROR) unless defined $recipe2;65 my $recipe1 = $ipprc->reduction($reduction, 'JPEG_BIN1_IMAGE_' . uc($det_type)); # Recipe to use 66 &my_die("Unrecognised detrend type: $det_type", $det_id, $exp_id, $PS_EXIT_PROG_ERROR) unless defined $recipe1; 67 68 my $recipe2 = $ipprc->reduction($reduction, 'JPEG_BIN2_IMAGE_' . uc($det_type)); # Recipe to use 69 &my_die("Unrecognised detrend type: $det_type", $det_id, $exp_id, $PS_EXIT_PROG_ERROR) unless defined $recipe2; 65 70 66 71 # values to extract from output metadata and the stats to calculate … … 87 92 88 93 # Get list of component files 89 my $files; # Array of component files94 my ($files, $command, $success, $error_code, $full_buf, $stdout_buf, $stderr_buf); 90 95 { 91 my $command = "$dettool -processedimfile -det_id $det_id -exp_tag $exp_tag"; # Command to run96 $command = "$dettool -processedimfile -det_id $det_id -exp_id $exp_id"; # Command to run 92 97 $command .= " -dbname $dbname" if defined $dbname; 93 my( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =94 run(command => $command, verbose => 1); 95 unless ($success) { 96 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 97 &my_die("Unable to perform dettool -processedimfile: $error_code", $det_id, $exp_ tag, $error_code);98 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 99 run(command => $command, verbose => 1); 100 unless ($success) { 101 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 102 &my_die("Unable to perform dettool -processedimfile: $error_code", $det_id, $exp_id, $error_code); 98 103 } 99 104 … … 101 106 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 102 107 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 103 &my_die("Unable to parse metadata config doc", $det_id, $exp_ tag, $PS_EXIT_PROG_ERROR);108 &my_die("Unable to parse metadata config doc", $det_id, $exp_id, $PS_EXIT_PROG_ERROR); 104 109 105 110 # parse the file info in the metadata 106 111 $files = parse_md_list($metadata) or 107 &my_die("Unable to parse metadata list", $det_id, $exp_ tag, $PS_EXIT_PROG_ERROR);112 &my_die("Unable to parse metadata list", $det_id, $exp_id, $PS_EXIT_PROG_ERROR); 108 113 109 114 # parse the stats in the metadata 110 115 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser 111 116 unless ($stats->parse($metadata)) { 112 &my_die("Unable to find all values in statistics output.\n", $ chip_id, $class_id, $PS_EXIT_PROG_ERROR);117 &my_die("Unable to find all values in statistics output.\n", $det_id, $exp_id, $PS_EXIT_PROG_ERROR); 113 118 } 114 119 } … … 132 137 unless ($no_op) { 133 138 # Make the jpeg for binning 1 134 { 135 my $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE $recipe1"; # Command to run 136 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 137 run(command => $command, verbose => 1); 138 unless ($success) { 139 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 140 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $error_code); 141 } 142 &my_die("Unable to find expected output file: $jpeg1", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1); 143 } 139 $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE $recipe1"; # Command to run 140 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 141 run(command => $command, verbose => 1); 142 unless ($success) { 143 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 144 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_id, $error_code); 145 } 146 &my_die("Unable to find expected output file: $jpeg1", $det_id, $exp_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1); 144 147 145 148 # Make the jpeg for binning 2 146 { 147 my $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE $recipe2"; # Command to run 148 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 149 run(command => $command, verbose => 1); 150 unless ($success) { 151 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 152 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $error_code); 153 } 154 &my_die("Unable to find expected output file: $jpeg2", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2); 155 } 149 $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE $recipe2"; # Command to run 150 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 151 run(command => $command, verbose => 1); 152 unless ($success) { 153 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 154 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_id, $error_code); 155 } 156 &my_die("Unable to find expected output file: $jpeg2", $det_id, $exp_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2); 156 157 } 157 158 158 159 # Command to update the database 159 my $command= "$dettool -addprocessedexp";160 $command = "$dettool -addprocessedexp"; 160 161 $command .= " -det_id $det_id"; 161 $command .= " -exp_ tag $exp_tag";162 $command .= " -exp_id $exp_id"; 162 163 $command .= " -recip $recipe1,$recipe2 -path_base $outputRoot"; 163 164 $command .= " -dbname $dbname" if defined $dbname; … … 172 173 # Add the processed file to the database 173 174 unless ($no_update) { 174 my( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =175 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 175 176 run(command => $command, verbose => 1); 176 177 unless ($success) { … … 187 188 my $msg = shift; # Warning message on die 188 189 my $det_id = shift; # Detrend identifier 189 my $exp_ tag= shift; # Exposure tag190 my $exp_id = shift; # Exposure tag 190 191 my $exit_code = shift; # Exit code to add 191 192 192 193 carp($msg); 193 if ($det_id and $exp_ tagand not $no_update) {194 if ($det_id and $exp_id and not $no_update) { 194 195 my $command = "$dettool -addprocessedexp"; 195 196 $command .= " -det_id $det_id"; 196 $command .= " -exp_ tag $exp_tag";197 $command .= " -exp_id $exp_id"; 197 198 $command .= " -code $exit_code"; 198 199 $command .= " -dbname $dbname" if defined $dbname;
Note:
See TracChangeset
for help on using the changeset viewer.
