Changeset 11316
- Timestamp:
- Jan 25, 2007, 7:10:31 PM (19 years ago)
- Location:
- trunk/ippScripts/scripts
- Files:
-
- 11 edited
-
detrend_norm_apply.pl (modified) (6 diffs)
-
detrend_norm_calc.pl (modified) (7 diffs)
-
detrend_norm_exp.pl (modified) (7 diffs)
-
detrend_process_exp.pl (modified) (7 diffs)
-
detrend_process_imfile.pl (modified) (5 diffs)
-
detrend_reject_exp.pl (modified) (9 diffs)
-
detrend_reject_imfile.pl (modified) (8 diffs)
-
detrend_resid.pl (modified) (6 diffs)
-
detrend_stack.pl (modified) (6 diffs)
-
phase2.pl (modified) (5 diffs)
-
phase3.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_norm_apply.pl
r11298 r11316 8 8 use Data::Dumper; 9 9 10 use PS::IPP::Config; 10 use PS::IPP::Config qw( 11 $PS_EXIT_SUCCESS 12 $PS_EXIT_UNKNOWN_ERROR 13 $PS_EXIT_SYS_ERROR 14 $PS_EXIT_CONFIG_ERROR 15 $PS_EXIT_PROG_ERROR 16 $PS_EXIT_DATA_ERROR 17 $PS_EXIT_TIMEOUT_ERROR 18 ); 11 19 my $ipprc = PS::IPP::Config->new(); # IPP configuration 12 20 use File::Spec; … … 60 68 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 61 69 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 62 die "Can't find required tools.\n" if $missing_tools; 70 71 if ($missing_tools) { 72 warn("Can't find required tools."); 73 exit($PS_EXIT_CONFIG_ERROR); 74 } 63 75 64 76 unless (defined $workdir) { … … 85 97 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 86 98 run(command => $command, verbose => 1); 87 die "Unable to perform ppImage: $error_code\n" if not $success; 88 die "Can't find expected output file: $output\n" if not -e $output; 89 die "Can't find expected output file: $b1name\n" if not -e $b1name; 90 die "Can't find expected output file: $b2name\n" if not -e $b2name; 91 die "Can't find expected output file: $statsName\n" if not -e $statsName; 99 unless ($success) { 100 $error_code >> 8; 101 &my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $class_id, $error_code); 102 } 103 &my_die("Can't find expected output file: $output", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -e $output; 104 &my_die("Can't find expected output file: $b1name", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -e $b2name; 105 &my_die("Can't find expected output file: $b2name", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -e $b1name; 106 &my_die("Can't find expected output file: $statsName", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -e $statsName; 92 107 } 93 108 … … 96 111 { 97 112 my $statsFile; # File handle 98 open $statsFile, $statsName or die "Can't open statistics file $statsName: $!\n";113 open $statsFile, $statsName or &my_die("Can't open statistics file $statsName: $!\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR); 99 114 my @contents = <$statsFile>; # Contents of file 100 115 close $statsFile; 101 116 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 102 117 my $metadata = $mdcParser->parse(join "", @contents) 103 or die "unable to parse metadata config";118 or &my_die("Unable to parse metadata config", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR); 104 119 $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 105 $stats->parse($metadata) or die "Unable to find all values in statistics output.\n";120 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR); 106 121 } 107 122 … … 127 142 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 128 143 run(command => $command, verbose => 1); 129 die "Unable to perform dettool -addnormalizedimfile: $error_code\n" 130 if not $success; 144 unless ($success) { 145 $error_code >> 8; 146 warn("Unable to perform dettool -addnormalizedimfile: $error_code\n"); 147 exit($error_code); 148 } 131 149 132 150 unlink $statsName; 133 151 } 152 153 sub my_die 154 { 155 my $msg = shift; # Warning message on die 156 my $det_id = shift; # Detrend identifier 157 my $iter = shift; # Iteration 158 my $class_id = shift; # Class identifier 159 my $exit_code = shift; # Exit code to add 160 161 warn($msg); 162 if ($det_id and $iter and $class_id) { 163 my $command = "$dettool -addnormalizedimfile -det_id $det_id -iteration $iter -class_id $class_id -code $exit_code"; 164 $command .= " -dbname $dbname" if defined $dbname; 165 system ($command); 166 } 167 exit $exit_code; 168 } 169 134 170 135 171 END { … … 139 175 $? = $status; 140 176 } 177 178 __END__ -
trunk/ippScripts/scripts/detrend_norm_calc.pl
r11298 r11316 9 9 use PS::IPP::Metadata::List qw( parse_md_list ); 10 10 use Data::Dumper; 11 12 use PS::IPP::Config qw( 13 $PS_EXIT_SUCCESS 14 $PS_EXIT_UNKNOWN_ERROR 15 $PS_EXIT_SYS_ERROR 16 $PS_EXIT_CONFIG_ERROR 17 $PS_EXIT_PROG_ERROR 18 $PS_EXIT_DATA_ERROR 19 $PS_EXIT_TIMEOUT_ERROR 20 ); 11 21 12 22 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 54 64 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 55 65 my $ppNormCalc = can_run('ppNormCalc') or (warn "Can't find ppNormCalc" and $missing_tools = 1); 56 die "Can't find required tools.\n" if $missing_tools; 57 58 die "Unrecognised detrend type: $detType\n" unless exists NORMALIZE()->{lc($detType)}; 59 66 if ($missing_tools) { 67 warn("Can't find required tools."); 68 exit($PS_EXIT_CONFIG_ERROR); 69 } 70 71 unless (exists NORMALIZE()->{lc($detType)}) { 72 warn("Unrecognised detrend type: $detType"); 73 exit($PS_EXIT_CONFIG_ERROR); 74 } 60 75 61 76 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 69 84 my ( $stdin, $stdout, $stderr ); # Buffers for running program 70 85 print "Running [$command]...\n"; 71 run \@command, \$stdin, \$stdout, \$stderr or 72 die "Unable to perform dettool -processedimfile on detrend $detId/$iter: $?"; 86 if (not run(\@command, \$stdin, \$stdout, \$stderr)) { 87 warn("Unable to perform dettool -processedimfile on detrend $detId/$iter: $?"); 88 exit($PS_EXIT_SYS_ERROR); 89 } 73 90 # print $stdout . "\n"; 74 91 … … 82 99 push @single, "\n"; 83 100 84 my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) ) or 85 die "Unable to parse output from dettool.\n"; 101 my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) ); 102 unless (defined $list) { 103 warn("Unable to parse output from dettool."); 104 exit($PS_EXIT_PROG_ERROR); 105 } 86 106 push @files, @$list; 87 107 @single = (); … … 119 139 my @command = split /\s+/, $ppNormCalc; 120 140 print "Running [$ppNormCalc]...\n"; 121 run \@command, \$normData, \$stdout, \$stderr or 122 die "Unable to perform ppNormCalc: $?"; 141 if (not run(\@command, \$normData, \$stdout, \$stderr)) { 142 warn("Unable to perform ppNormCalc: $?"); 143 exit($PS_EXIT_SYS_ERROR); 144 } 123 145 print $stdout . "\n"; 124 146 125 147 # Parse the output 126 $norms = $mdcParser->parse($stdout) 127 or die "unable to parse metadata config doc"; 148 $norms = $mdcParser->parse($stdout); 149 unless ($norms) { 150 warn("Unable to parse metadata config doc"); 151 exit($PS_EXIT_PROG_ERROR); 152 } 128 153 } 129 154 … … 158 183 my ( $stdin, $stdout, $stderr ); # Buffers for running program 159 184 print "Running [$command]...\n"; 160 run \@command, \$stdin, \$stdout, \$stderr or 161 die "Unable to perform dettool -addnormstat for $className: $?"; 185 if (not run \@command, \$stdin, \$stdout, \$stderr) { 186 warn("Unable to perform dettool -addnormstat for $className: $?"); 187 exit($PS_EXIT_SYS_ERROR); 188 } 162 189 print $stdout . "\n"; 163 190 } … … 170 197 $? = $status; 171 198 } 199 200 __END__ -
trunk/ippScripts/scripts/detrend_norm_exp.pl
r11298 r11316 8 8 9 9 use IPC::Cmd qw( can_run run ); 10 use PS::IPP::Metadata::Config; 10 use PS::IPP::Metadata::Config qw( 11 $PS_EXIT_SUCCESS 12 $PS_EXIT_UNKNOWN_ERROR 13 $PS_EXIT_SYS_ERROR 14 $PS_EXIT_CONFIG_ERROR 15 $PS_EXIT_PROG_ERROR 16 $PS_EXIT_DATA_ERROR 17 $PS_EXIT_TIMEOUT_ERROR 18 ); 11 19 use PS::IPP::Metadata::List qw( parse_md_list ); 12 20 use Statistics::Descriptive; … … 49 57 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 50 58 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 51 die "Can't find required tools.\n" if $missing_tools; 59 if ($missing_tools) { 60 warn("Can't find required tools."); 61 exit($PS_EXIT_CONFIG_ERROR); 62 } 52 63 53 64 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 60 71 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 61 72 run(command => $command, verbose => 1); 62 die "Unable to perform dettool -normalizedimfile: $error_code\n" if not $success; 63 my $metadata = $mdcParser->parse(join "", @$stdout_buf) 64 or die "unable to parse metadata config doc"; 65 $files = parse_md_list($metadata); 73 unless ($success) { 74 $error_code >> 8; 75 &my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $error_code); 76 } 77 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 78 &my_die("Unable to parse metadata config doc", $det_id, $iter, $PS_EXIT_PROG_ERROR); 79 $files = parse_md_list($metadata) or 80 &my_die("Unable to parse metadata list", $det_id, $iter, $PS_EXIT_PROG_ERROR); 66 81 } 67 82 … … 72 87 my @variances; # Array of variances for each component 73 88 foreach my $file (@$files) { 74 die "Unable to find class id\n"unless defined $file->{class_id};89 &my_die("Unable to find class id", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $file->{class_id}; 75 90 my $class_id = $file->{class_id}; 76 die "Unable to find bg for class_id=$class_id\n"unless defined $file->{bg};77 die "Unable to find bg_mean_stdev for class_id=$class_id\n"unless defined $file->{bg_mean_stdev};91 &my_die("Unable to find bg for class_id=$class_id", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $file->{bg}; 92 &my_die("Unable to find bg_mean_stdev for class_id=$class_id", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $file->{bg_mean_stdev}; 78 93 push @backgrounds, $file->{bg}; 79 94 push @variances, $file->{bg_stdev}**2; … … 127 142 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 128 143 run(command => $command, verbose => 1); 129 die "Unable to find expected output file: $jpeg1Name\n" if not-f $jpeg1Name;144 &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $jpeg1Name; 130 145 } 131 146 … … 135 150 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 136 151 run(command => $command, verbose => 1); 137 die "Unable to find expected output file: $jpeg2Name\n" if not-f $jpeg2Name;152 &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $jpeg2Name; 138 153 } 139 154 … … 148 163 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 149 164 run(command => $command, verbose => 1); 150 die "Unable to perform dettool -addnormalizedexp: $error_code\n" if not $success; 165 unless ($success) { 166 $error_code >> 8; 167 &my_die("Unable to perform dettool -addnormalizedexp: $error_code", $det_id, $iter, $error_code); 168 } 151 169 152 170 unlink $list1Name; 153 171 unlink $list2Name; 172 } 173 174 175 sub my_die 176 { 177 my $msg = shift; # Warning message on die 178 my $det_id = shift; # Detrend identifier 179 my $iter = shift; # Iteration 180 my $exit_code = shift; # Exit code to add 181 182 warn($msg); 183 if ($det_id and $iter) { 184 my $command = "$dettool -addprocessedimfile -det_id $det_id -iter $iter -code $exit_code"; 185 $command .= " -dbname $dbname" if defined $dbname; 186 system ($command); 187 } 188 exit $exit_code; 154 189 } 155 190 -
trunk/ippScripts/scripts/detrend_process_exp.pl
r11298 r11316 12 12 use Statistics::Descriptive; 13 13 14 use PS::IPP::Config; 14 use PS::IPP::Config qw( 15 $PS_EXIT_SUCCESS 16 $PS_EXIT_UNKNOWN_ERROR 17 $PS_EXIT_SYS_ERROR 18 $PS_EXIT_CONFIG_ERROR 19 $PS_EXIT_PROG_ERROR 20 $PS_EXIT_DATA_ERROR 21 $PS_EXIT_TIMEOUT_ERROR 22 ); 15 23 my $ipprc = PS::IPP::Config->new(); # IPP configuration 16 24 use File::Spec; … … 47 55 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 48 56 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 49 die "Can't find required tools.\n" if $missing_tools; 57 if ($missing_tools) { 58 warn("Can't find required tools."); 59 exit($PS_EXIT_CONFIG_ERROR); 60 } 50 61 51 62 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 58 69 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 59 70 run(command => $command, verbose => 1); 60 die "Unable to perform dettool -processedimfile: $error_code\n" if not $success; 61 my $metadata = $mdcParser->parse(join "", @$stdout_buf) 62 or die "unable to parse metadata config doc"; 63 $files = parse_md_list($metadata); 71 unless ($success) { 72 $error_code >> 8; 73 &my_die("Unable to perform dettool -processedimfile: $error_code", $det_id, $exp_tag, $error_code); 74 } 75 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 76 &my_die("Unable to parse metadata config doc", $det_id, $exp_tag, $PS_EXIT_PROG_ERROR); 77 $files = parse_md_list($metadata) or 78 &my_die("Unable to parse metadata list", $det_id, $exp_tag, $PS_EXIT_PROG_ERROR); 64 79 } 65 80 … … 70 85 my @variances; # Array of variances for each component 71 86 foreach my $file (@$files) { 72 die "Unable to find class id\n"unless defined $file->{class_id};87 &my_die("Unable to find class id", $det_id, $exp_tag, $PS_EXIT_SYS_ERRROR) unless defined $file->{class_id}; 73 88 my $class_id = $file->{class_id}; 74 die "Unable to find bg for class_id=$class_id\n"unless defined $file->{bg};75 die "Unable to find bg_mean_stdev for class_id=$class_id\n"unless defined $file->{bg_mean_stdev};89 &my_die("Unable to find bg for class_id=$class_id", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless defined $file->{bg}; 90 &my_die("Unable to find bg_mean_stdev for class_id=$class_id", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless defined $file->{bg_mean_stdev}; 76 91 push @backgrounds, $file->{bg}; 77 92 push @variances, $file->{bg_stdev}**2; … … 125 140 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 126 141 run(command => $command, verbose => 1); 127 die "Unable to find expected output file: $jpeg1\n" if not -f $jpeg1; 142 unless ($success) { 143 $error_code >> 8; 144 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $error_code); 145 } 146 &my_die("Unable to find expected output file: $jpeg1", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg1; 128 147 } 129 148 … … 133 152 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 134 153 run(command => $command, verbose => 1); 135 die "Unable to find expected output file: $jpeg2\n" if not -f $jpeg2; 154 unless ($success) { 155 $error_code >> 8; 156 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $error_code); 157 } 158 &my_die("Unable to find expected output file: $jpeg2", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg2; 136 159 } 137 160 … … 148 171 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 149 172 run(command => $command, verbose => 1); 150 die "Unable to perform dettool -addprocessedexp: $error_code\n" if not $success; 173 unless ($success) { 174 $error_code >> 8; 175 warn("Unable to perform dettool -addprocessedexp: $error_code"); 176 exit($error_code); 177 } 151 178 152 179 unlink $list1Name; 153 180 unlink $list2Name; 181 } 182 183 184 sub my_die 185 { 186 my $msg = shift; # Warning message on die 187 my $det_id = shift; # Detrend identifier 188 my $exp_tag = shift; # Exposure tag 189 my $exit_code = shift; # Exit code to add 190 191 warn($msg); 192 if ($det_id && $exp_tag) { 193 my $command = "$dettool -addprocessedexp -det_id $det_id -exp_tag $exp_tag -code $exit_code"; 194 $command .= " -dbname $dbname" if defined $dbname; 195 system ($command); 196 } 197 exit $exit_code; 154 198 } 155 199 -
trunk/ippScripts/scripts/detrend_process_imfile.pl
r11298 r11316 11 11 use PS::IPP::Metadata::Stats; 12 12 13 use PS::IPP::Config; 13 use PS::IPP::Config qw( 14 $PS_EXIT_SUCCESS 15 $PS_EXIT_UNKNOWN_ERROR 16 $PS_EXIT_SYS_ERROR 17 $PS_EXIT_CONFIG_ERROR 18 $PS_EXIT_PROG_ERROR 19 $PS_EXIT_DATA_ERROR 20 $PS_EXIT_TIMEOUT_ERROR 21 ); 14 22 my $ipprc = PS::IPP::Config->new(); # IPP configuration 15 23 use File::Spec; … … 60 68 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 61 69 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 62 die "Can't find required tools.\n" if $missing_tools; 70 if ($missing_tools) { 71 warn("Can't find required tools."); 72 exit($PS_EXIT_CONFIG_ERROR); 73 } 63 74 64 75 # Recipe to use in processing 65 76 my $recipe = RECIPES->{lc($det_type)}; 66 die "Unrecognised detrend type: $det_type\n" if not defined $recipe; 77 unless (defined $recipe) { 78 warn("Unrecognised detrend type: $det_type"); 79 exit($PS_EXIT_CONFIG_ERROR); 80 } 67 81 68 82 ### Output file name … … 88 102 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 89 103 run(command => $command, verbose => 1); 90 die "Unable to perform ppImage on $input_uri: $error_code\n" if not $success; 91 die "Couldn't find expected output file: $outputImage\n" if not -f $outputImage; 92 die "Couldn't find expected output file: $outputStats\n" if not -f $outputStats; 93 die "Couldn't find expected output file: $outputBin1\n" if not -f $outputBin1; 94 die "Couldn't find expected output file: $outputBin2\n" if not -f $outputBin2; 104 unless ($success) { 105 $error_code >> 8; 106 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $class_id, $error_code); 107 } 108 &my_die("Couldn't find expected output file: $outputImage", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputImage; 109 &my_die("Couldn't find expected output file: $outputStats", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStats; 110 &my_die("Couldn't find expected output file: $outputBin1", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin1; 111 &my_die("Couldn't find expected output file: $outputBin2", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin2; 95 112 } 96 113 … … 104 121 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 105 122 my $metadata = $mdcParser->parse(join "", @contents) 106 or die "unable to parse metadata config";123 or &my_die("Unable to parse metadata config", $det_id, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 107 124 $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 108 $stats->parse($metadata) or die "Unable to find all values in statistics output.\n";125 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 109 126 } 110 127 … … 131 148 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 132 149 run(command => $command, verbose => 1); 133 die "Unable to perform dettool -addprocessedimfile for $det_id/$exp_tag/$class_id: $error_code\n" 134 if not $success; 150 unless ($success) { 151 $error_code >> 8; 152 warn("Unable to perform dettool -addprocessedimfile: $error_code\n"); 153 exit($error_code); 154 } 135 155 136 156 unlink $outputStats; 157 } 158 159 sub my_die 160 { 161 my $msg = shift; # Warning message on die 162 my $det_id = shift; # Detrend identifier 163 my $exp_tag = shift; # Exposure tag 164 my $class_id = shift; # Class identifier 165 my $exit_code = shift; # Exit code to add 166 167 warn($msg); 168 if ($det_id and $exp_tag and $class_id) { 169 my $command = "$dettool -addprocessedimfile -det_id $det_id -exp_tag $exp_tag -class_id $class_id -code $exit_code"; 170 $command .= " -dbname $dbname" if defined $dbname; 171 system ($command); 172 } 173 exit $exit_code; 137 174 } 138 175 -
trunk/ippScripts/scripts/detrend_reject_exp.pl
r11297 r11316 12 12 use Statistics::Descriptive; 13 13 14 use PS::IPP::Config; 14 use PS::IPP::Config qw( 15 $PS_EXIT_SUCCESS 16 $PS_EXIT_UNKNOWN_ERROR 17 $PS_EXIT_SYS_ERROR 18 $PS_EXIT_CONFIG_ERROR 19 $PS_EXIT_PROG_ERROR 20 $PS_EXIT_DATA_ERROR 21 $PS_EXIT_TIMEOUT_ERROR 22 ); 15 23 my $ipprc = PS::IPP::Config->new(); # IPP configuration 16 24 … … 42 50 my $missing_tools; 43 51 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 44 die "Can't find required tools.\n" if $missing_tools; 52 if ($missing_tools) { 53 warn("Can't find required tools."); 54 exit($PS_EXIT_CONFIG_ERROR); 55 } 56 45 57 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 46 58 … … 52 64 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 53 65 run(command => $command, verbose => 1); 54 die "Unable to perform dettool -residexp: $error_code\n" if not $success; 55 my $metadata = $mdcParser->parse(join "", @$stdout_buf) 56 or die "unable to parse metadata config doc"; 57 $exposures = parse_md_list($metadata); 66 unless ($success) { 67 $error_code >> 8; 68 &my_die("Unable to perform dettool -residexp: $error_code", $det_id, $iter, $error_code); 69 } 70 71 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 72 &my_die("Unable to parse metadata config doc", $det_id, $iter, $PS_EXIT_PROG_ERROR); 73 $exposures = parse_md_list($metadata) or 74 &my_die("Unable to parse metadata list", $det_id, $iter, $PS_EXIT_PROG_ERROR); 58 75 } 59 76 … … 66 83 my @include; # Array of include flags 67 84 foreach my $exposure (@$exposures) { 68 die "Unable to find exposure id.\n" if notdefined $exposure->{exp_tag};69 die "Unable to find mean.\n" if notdefined $exposure->{bg};70 die "Unable to find stdev.\n" if notdefined $exposure->{bg_stdev};71 die "Unable to find mean stdev.\n" if notdefined $exposure->{bg_mean_stdev};72 die "Unable to find accept.\n" if notdefined $exposure->{accept};73 die "Unable to find include.\n" if notdefined $exposure->{include};85 &my_die("Unable to find exposure id.\n", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $exposure->{exp_tag}; 86 &my_die("Unable to find mean.\n", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $exposure->{bg}; 87 &my_die("Unable to find stdev.\n", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $exposure->{bg_stdev}; 88 &my_die("Unable to find mean stdev.\n", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $exposure->{bg_mean_stdev}; 89 &my_die("Unable to find accept.\n", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $exposure->{accept}; 90 &my_die("Unable to find include.\n", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $exposure->{include}; 74 91 push @expTags, $exposure->{exp_tag}; 75 92 push @means, $exposure->{bg}; … … 170 187 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 171 188 run(command => $command, verbose => 1); 172 die "Unable to perform dettool -updateresidexp: $error_code\n" if not $success; 189 unless ($success) { 190 $error_code >> 8; 191 &my_die("Unable to perform dettool -updateresidexp: $error_code", $det_id, $iter, $error_code); 192 } 173 193 } 174 194 } … … 205 225 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 206 226 run(command => $command, verbose => 1); 207 die "Unable to perform dettool -adddetrunsummary: $error_code\n" if not $success; 227 unless ($success) { 228 $error_code >> 8; 229 warn("Unable to perform dettool -adddetrunsummary: $error_code"); 230 exit($error_code); 231 } 208 232 } 209 233 … … 221 245 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 222 246 run(command => $command, verbose => 1); 223 die "Unable to perform dettool -updatedetrun: $error_code\n" if not $success; 247 unless ($success) { 248 $error_code >> 8; 249 warn("Unable to perform dettool -updatedetrun: $error_code"); 250 exit($error_code); 251 } 224 252 } 225 253 … … 231 259 } 232 260 233 # Retrieve the requested rejection limit, dying if not extant 261 262 sub my_die 263 { 264 my $msg = shift; # Warning message on die 265 my $det_id = shift; # Detrend identifier 266 my $iter = shift; # Iteration 267 my $exit_code = shift; # Exit code to add 268 269 warn($msg); 270 if ($det_id and $iter) { 271 my $command = "$dettool -adddetrunsummary -det_id $det_id -iteration $iter -code $exit_code"; 272 $command .= " -dbname $dbname" if defined $dbname; 273 system ($command); 274 } 275 exit $exit_code; 276 } 277 278 279 280 # Retrieve the requested rejection limit, dying unless extant 234 281 sub rejection_limit 235 282 { … … 240 287 my $value = $ipprc->rejection( $name, $det_type, $filter ); 241 288 if (not defined $value) { 242 $filter = "(no filter)" if notdefined $filter;289 $filter = "(no filter)" unless defined $filter; 243 290 die "Unable to determine $name rejection limit for $det_type with $filter.\n"; 244 291 } -
trunk/ippScripts/scripts/detrend_reject_imfile.pl
r11298 r11316 12 12 use Statistics::Descriptive; 13 13 14 use PS::IPP::Config; 14 use PS::IPP::Config qw( 15 $PS_EXIT_SUCCESS 16 $PS_EXIT_UNKNOWN_ERROR 17 $PS_EXIT_SYS_ERROR 18 $PS_EXIT_CONFIG_ERROR 19 $PS_EXIT_PROG_ERROR 20 $PS_EXIT_DATA_ERROR 21 $PS_EXIT_TIMEOUT_ERROR 22 ); 15 23 my $ipprc = PS::IPP::Config->new(); # IPP configuration 16 24 use File::Spec; … … 52 60 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 53 61 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 54 die "Can't find required tools.\n" if $missing_tools; 62 if ($missing_tools) { 63 warn("Can't find required tools."); 64 exit($PS_EXIT_CONFIG_ERROR); 65 } 55 66 56 67 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 63 74 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 64 75 run(command => $command, verbose => 1); 65 die "Unable to perform dettool -residimfile: $error_code\n" if not $success; 66 my $metadata = $mdcParser->parse(join "", @$stdout_buf) 67 or die "unable to parse metadata config doc"; 68 $files = parse_md_list($metadata); 76 unless ($success) { 77 $error_code >> 8; 78 warn("Unable to perform dettool -residimfile: $error_code\n"); 79 exit($error_code); 80 } 81 82 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 83 &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_tag, $PS_EXIT_PROG_ERROR); 84 $files = parse_md_list($metadata) or 85 &my_die("Unable to parse metadata list", $det_id, $iter, $exp_tag, $PS_EXIT_PROG_ERROR); 69 86 } 70 87 … … 107 124 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 108 125 run(command => $command, verbose => 1); 109 die "Unable to find expected output file: $jpeg1Name\n" if not -f $jpeg1Name; 126 unless ($success) { 127 $error_code >> 8; 128 &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_tag, $error_code); 129 } 130 &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg1Name; 110 131 } 111 132 … … 115 136 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 116 137 run(command => $command, verbose => 1); 117 die "Unable to find expected output file: $jpeg2Name\n" if not -f $jpeg2Name; 138 unless ($success) { 139 $error_code >> 8; 140 &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_tag, $error_code); 141 } 142 &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg2Name; 118 143 } 119 144 … … 131 156 # Reject based on the stats of the imfiles 132 157 # it is VALID to reject on more than one criterion 133 die "Number of means and number of variances differ!\n" if scalar @means != scalar @variances;158 &my_die("Number of means and number of variances differ!", $det_id, $iter, $exp_tag, $PS_EXIT_PROG_ERROR) unless scalar @means == scalar @variances; 134 159 for (my $i = 0; $i < scalar @means; $i++) { 135 160 my $mean = $means[$i]; # Mean for this imfile … … 248 273 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 249 274 run(command => $command, verbose => 1); 250 die "Unable to perform dettool -addresidexp: $error_code\n" if not $success; 275 unless ($success) { 276 $error_code >> 8; 277 warn("Unable to perform dettool -addresidexp: $error_code\n"); 278 exit($error_code); 279 } 251 280 252 281 unlink $list1Name; … … 259 288 or die "failed to execute sync: $!" ; 260 289 $? = $status; 290 } 291 292 293 sub my_die 294 { 295 my $msg = shift; # Warning message on die 296 my $det_id = shift; # Detrend identifier 297 my $iter = shift; # Iteration 298 my $exp_tag = shift; # Exposure tag 299 my $exit_code = shift; # Exit code to add 300 301 warn($msg); 302 if ($det_id and $iteration and $exp_tag) { 303 my $command = "$dettool -addresidexp -det_id $det_id -iteration $iter -exp_tag $exp_tag -code $exit_code"; 304 $command .= " -dbname $dbname" if defined $dbname; 305 system ($command); 306 } 307 exit $exit_code; 261 308 } 262 309 -
trunk/ippScripts/scripts/detrend_resid.pl
r11298 r11316 12 12 use Data::Dumper; 13 13 14 use PS::IPP::Config; 14 use PS::IPP::Config qw( 15 $PS_EXIT_SUCCESS 16 $PS_EXIT_UNKNOWN_ERROR 17 $PS_EXIT_SYS_ERROR 18 $PS_EXIT_CONFIG_ERROR 19 $PS_EXIT_PROG_ERROR 20 $PS_EXIT_DATA_ERROR 21 $PS_EXIT_TIMEOUT_ERROR 22 ); 15 23 my $ipprc = PS::IPP::Config->new(); # IPP configuration 16 24 use File::Spec; … … 92 100 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 93 101 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 94 die "Can't find required tools.\n" if $missing_tools; 102 if ($missing_tools) { 103 warn("Can't find required tools."); 104 exit($PS_EXIT_CONFIG_ERROR); 105 } 95 106 96 107 # Recipe to use in processing 97 die "Unrecognised mode: $mode\n" if notdefined RECIPES->{$mode};108 &my_die("Unrecognised mode: $mode", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR) unless defined RECIPES->{$mode}; 98 109 my $recipe = RECIPES->{$mode}->{lc($det_type)}; 99 die "Unrecognised detrend type: $det_type\n" if notdefined $recipe;110 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR) unless defined $recipe; 100 111 101 112 ### Output file names --- must match camera configuration! … … 124 135 if (lc($mode) ne 'verify') { 125 136 my $detFlag = DETRENDS->{lc($det_type)}; 126 die "Unrecognised detrend type: $det_type\n" if notdefined $detFlag;137 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR) unless defined $detFlag; 127 138 $command .= "$detFlag $detrend"; 128 139 } … … 130 141 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 131 142 run(command => $command, verbose => 1); 132 die "Unable to perform ppImage on $input_uri: $error_code\n" if not $success; 133 die "Couldn't find expected output file: $outputName\n" if not -f $outputName; 134 die "Couldn't find expected output file: $outputStats\n" if not -f $outputStats; 135 die "Couldn't find expected output file: $bin1Name\n" if not -f $bin1Name; 136 die "Couldn't find expected output file: $bin2Name\n" if not -f $bin2Name; 143 unless ($success) { 144 $error_code >> 8; 145 &my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $exp_tag, $class_id, $error_code); 146 } 147 &my_die("Couldn't find expected output file: $outputName", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputName; 148 &my_die("Couldn't find expected output file: $outputStats", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStats; 149 &my_die("Couldn't find expected output file: $bin1Name", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $bin1Name; 150 &my_die("Couldn't find expected output file: $bin2Name", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $bin2Name; 137 151 } 138 152 … … 141 155 { 142 156 my $statsFile; # File handle 143 open $statsFile, $outputStats or die "Can't open statistics file $outputStats: $!\n";157 open $statsFile, $outputStats or &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR); 144 158 my @contents = <$statsFile>; # Contents of file 145 159 close $statsFile; 146 160 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 147 my $metadata = $mdcParser->parse(join "", @contents) 148 or die "unable to parse metadata config doc";161 my $metadata = $mdcParser->parse(join "", @contents) or 162 &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 149 163 $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 150 $stats->parse($metadata) or die "Unable to find all values in statistics output.\n";164 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 151 165 } 152 166 … … 173 187 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 174 188 run(command => $command, verbose => 1); 175 die "Unable to perform dettool -addprocessed for $det_id/$exp_tag/$class_id: $error_code\n" 176 if not $success; 189 unless ($success) { 190 $error_code >> 8; 191 warn("Unable to perform dettool -addresidimfile: $error_code\n"); 192 exit($error_code); 193 } 177 194 178 195 unlink $outputStats; 196 } 197 198 199 200 sub my_die 201 { 202 my $msg = shift; # Warning message on die 203 my $det_id = shift; # Detrend identifier 204 my $iter = shift; # Iteration 205 my $exp_tag = shift; # Exposure tag 206 my $class_id = shift; # Class identifier 207 my $exit_code = shift; # Exit code to add 208 209 warn($msg); 210 if ($det_id and $iter and $exp_tag) { 211 my $command = "$dettool -addresidimfile -det_id $det_id -iteration $iter -exp_tag $exp_tag -class_id $class_id -code $exit_code"; 212 $command .= " -dbname $dbname" if defined $dbname; 213 system ($command); 214 } 215 exit $exit_code; 179 216 } 180 217 -
trunk/ippScripts/scripts/detrend_stack.pl
r11298 r11316 12 12 use PS::IPP::Metadata::Stats; 13 13 14 use PS::IPP::Config; 14 use PS::IPP::Config qw( 15 $PS_EXIT_SUCCESS 16 $PS_EXIT_UNKNOWN_ERROR 17 $PS_EXIT_SYS_ERROR 18 $PS_EXIT_CONFIG_ERROR 19 $PS_EXIT_PROG_ERROR 20 $PS_EXIT_DATA_ERROR 21 $PS_EXIT_TIMEOUT_ERROR 22 ); 15 23 my $ipprc = PS::IPP::Config->new(); # IPP configuration 16 24 use File::Spec; … … 52 60 }; 53 61 54 my $recipe = RECIPES()->{lc($det_type)}; # Recipe to use in stacking55 die "Unrecognised detrend type: $det_type\n" if not defined $recipe;56 57 62 # Look for programs we need 58 63 my $missing_tools; 59 64 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 60 65 my $ppMerge = can_run('ppMerge') or (warn "Can't find ppMerge" and $missing_tools = 1); 61 die "Can't find required tools.\n" if $missing_tools; 66 if ($missing_tools) { 67 warn("Can't find required tools."); 68 exit($PS_EXIT_CONFIG_ERROR); 69 } 70 71 my $recipe = RECIPES()->{lc($det_type)}; # Recipe to use in stacking 72 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR) unless defined $recipe; 62 73 63 74 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 70 81 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 71 82 run(command => $command, verbose => 1); 72 die "Unable to perform dettool -processedimfile: $error_code\n" if not $success; 73 my $metadata = $mdcParser->parse(join "", @$stdout_buf) 74 or die "unable to parse metadata config doc"; 75 $files = parse_md_list($metadata); 83 unless ($success) { 84 $error_code >> 8; 85 &my_die("Unable to perform dettool -processedimfile: $error_code", $det_id, $iter, $class_id, $error_code); 86 } 87 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 88 &my_die("Unable to parse metadata config doc", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR); 89 $files = parse_md_list($metadata) or 90 &my_die("Unable to parse metadata list", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR); 76 91 } 77 92 … … 101 116 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 102 117 run(command => $command, verbose => 1); 103 die "Unable to perform ppMerge: $error_code\n" if not $success; 104 die "Unable to find expected output file: $outputStack\n" if not -f $outputStack; 105 die "Unable to find expected output file: $outputStats\n" if not -f $outputStats; 118 unless ($success) { 119 $error_code >> 8; 120 &my_die("Unable to perform ppMerge: $error_code", $det_id, $iter, $class_id, $error_code); 121 } 122 &my_die("Unable to find expected output file: $outputStack\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStack; 123 &my_die("Unable to find expected output file: $outputStats\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStats; 106 124 } 107 125 … … 109 127 my $stats; # Statistics from ppImage 110 128 { 111 open(my $statsFile, "$outputStats") 112 or die "Can't open statistics file $outputStats: $!\n";129 open(my $statsFile, "$outputStats") or 130 &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR); 113 131 my $contents = do { local $/; <$statsFile> }; # Contents of file 114 132 close($statsFile); 115 133 116 134 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 117 my $metadata = $mdcParser->parse($contents) 118 or die "unable to parse metadata config doc";135 my $metadata = $mdcParser->parse($contents) or 136 &my_die("Unable to parse metadata config doc", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR); 119 137 $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 120 $stats->parse($metadata) or die "Unable to find all values in statistics output.\n"; 138 $stats->parse($metadata) or 139 &my_die("Unable to find all values in statistics output.", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR); 121 140 } 122 141 … … 137 156 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 138 157 run(command => $command, verbose => 1); 139 die "Unable to perform dettool -addstacked: $error_code\n" if not $success; 158 unless ($success) { 159 $error_code >> 8; 160 warn("Unable to perform dettool -addstacked: $error_code\n"); 161 exit($error_code); 162 } 140 163 141 164 unlink $outputStats; 165 } 166 167 168 sub my_die 169 { 170 my $msg = shift; # Warning message on die 171 my $det_id = shift; # Detrend identifier 172 my $iter = shift; # Iteration 173 my $class_id = shift; # Class identifier 174 my $exit_code = shift; # Exit code to add 175 176 warn($msg); 177 if ($det_id and $iter and $class_id) { 178 my $command = "$dettool -addstacked -det_id $det_id -iteration $iter -class_id $class_id -code $exit_code"; 179 $command .= " -dbname $dbname" if defined $dbname; 180 system ($command); 181 } 182 exit $exit_code; 142 183 } 143 184 -
trunk/ippScripts/scripts/phase2.pl
r11298 r11316 8 8 use PS::IPP::Metadata::Stats; 9 9 use Data::Dumper; 10 use PS::IPP::Config; 10 use PS::IPP::Config qw( 11 $PS_EXIT_SUCCESS 12 $PS_EXIT_UNKNOWN_ERROR 13 $PS_EXIT_SYS_ERROR 14 $PS_EXIT_CONFIG_ERROR 15 $PS_EXIT_PROG_ERROR 16 $PS_EXIT_DATA_ERROR 17 $PS_EXIT_TIMEOUT_ERROR 18 ); 11 19 my $ipprc = PS::IPP::Config->new(); # IPP configuration 12 20 use File::Spec; … … 51 59 my $p2tool = can_run('p2tool') or (warn "Can't find p2tool" and $missing_tools = 1); 52 60 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 53 die "Can't find required tools.\n" if $missing_tools; 61 if ($missing_tools) { 62 warn("Can't find required tools."); 63 exit($PS_EXIT_CONFIG_ERROR); 64 } 54 65 55 66 unless (defined $workdir) { … … 79 90 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 80 91 run(command => $command, verbose => 1); 81 die "Unable to perform ppImage on $input: $error_code\n" if not $success; 82 die "Couldn't find expected output file: $outputImage\n" if not -f $outputImage; 83 die "Couldn't find expected output file: $outputBin1\n" if not -f $outputBin1; 84 die "Couldn't find expected output file: $outputBin2\n" if not -f $outputBin2; 85 die "Couldn't find expected output file: $outputStats\n" if not -f $outputStats; 92 unless ($success) { 93 $error_code >> 8; 94 &my_die("Unable to perform ppImage: $error_code", $exp_tag, $class_id, $error_code); 95 } 96 &my_die("Couldn't find expected output file: $outputImage\n", $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputImage; 97 &my_die("Couldn't find expected output file: $outputBin1\n", $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin1; 98 &my_die("Couldn't find expected output file: $outputBin2\n", $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin2; 99 &my_die("Couldn't find expected output file: $outputStats\n", $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStats; 86 100 } 87 101 … … 90 104 { 91 105 my $statsFile; # File handle 92 open $statsFile, $outputStats or die "Can't open statistics file $outputStats: $!\n";106 open $statsFile, $outputStats or &my_die("Can't open statistics file $outputStats: $!", $exp_tag, $class_id, $PS_EXIT_SYS_ERROR); 93 107 my @contents = <$statsFile>; # Contents of file 94 108 close $statsFile; 95 109 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 96 my $metadata = $mdcParser->parse(join "", @contents) 97 or die "unable to parse metadata config doc";110 my $metadata = $mdcParser->parse(join "", @contents) or 111 &my_die("Unable to parse metadata config doc", $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 98 112 $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 99 $stats->parse($metadata) or die "Unable to find all values in statistics output.\n"; 113 $stats->parse($metadata) or 114 &my_die("Unable to find all values in statistics output.\n", $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 100 115 } 101 116 … … 120 135 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 121 136 run(command => $command, verbose => 1); 122 die "Unable to perform p2tool -addprocessedimfile for $expTag/$classId: $error_code\n" 123 if not $success; 137 unless ($success) { 138 $error_code >> 8; 139 warn("Unable to perform p2tool -addprocessedimfile: $error_code\n"); 140 exit($error_code); 141 } 124 142 125 143 unlink $outputStats; 144 } 145 146 147 sub my_die 148 { 149 my $msg = shift; # Warning message on die 150 my $exp_tag = shift; # Exposure tag 151 my $class_id = shift; # Class identifier 152 my $exit_code = shift; # Exit code to add 153 154 warn($msg); 155 if ($exp_tag and $class_id) { 156 my $command = "$dettool -addprocessedimfile -exp_tag $exp_tag -class_id $class_id -code $exit_code"; 157 $command .= " -dbname $dbname" if defined $dbname; 158 system ($command); 159 } 160 exit $exit_code; 126 161 } 127 162 -
trunk/ippScripts/scripts/phase3.pl
r11298 r11316 12 12 use Statistics::Descriptive; 13 13 14 use PS::IPP::Config; 14 use PS::IPP::Config qw( 15 $PS_EXIT_SUCCESS 16 $PS_EXIT_UNKNOWN_ERROR 17 $PS_EXIT_SYS_ERROR 18 $PS_EXIT_CONFIG_ERROR 19 $PS_EXIT_PROG_ERROR 20 $PS_EXIT_DATA_ERROR 21 $PS_EXIT_TIMEOUT_ERROR 22 ); 15 23 my $ipprc = PS::IPP::Config->new(); # IPP configuration 16 24 use File::Spec; … … 45 53 my $p3tool = can_run('p3tool') or (warn "Can't find p3tool" and $missing_tools = 1); 46 54 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 47 die "Can't find required tools.\n" if $missing_tools; 55 if ($missing_tools) { 56 warn("Can't find required tools."); 57 exit($PS_EXIT_CONFIG_ERROR); 58 } 48 59 49 60 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 56 67 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 57 68 run(command => $command, verbose => 1); 58 die "Unable to perform p3tool -pendingimfile: $error_code\n" if not $success; 59 my $metadata = $mdcParser->parse(join "", @$stdout_buf) 60 or die "unable to parse metadata config doc"; 61 $files = parse_md_list($metadata); 69 unless ($success) { 70 $error_code >> 8; 71 &my_die("Unable to perform p3tool: $error_code", $exp_tag, $error_code); 72 } 73 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 74 &my_die("Unable to parse metadata config doc", $exp_tag, $PS_EXIT_PROG_ERROR); 75 $files = parse_md_list($metadata) or 76 &my_die("Unable to parse metadata list", $exp_tag, $PS_EXIT_PROG_ERROR); 62 77 } 63 78 … … 74 89 # my @zp; # Array of photometric zero points 75 90 foreach my $file (@$files) { 76 die "Unable to find class id\n"unless defined $file->{class_id};91 &my_die("Unable to find class id", $exp_tag, $PS_EXIT_SYS_ERROR) unless defined $file->{class_id}; 77 92 my $class_id = $file->{class_id}; 78 die "Unable to find bg for class_id=$class_id\n"unless defined $file->{bg};79 die "Unable to find bg_mean_stdev for class_id=$class_id\n"unless defined $file->{bg_mean_stdev};80 # die "Unable to find sigma_ra for class_id=$class_id\n"unless defined $file->{sigma_ra};81 # die "Unable to find sigma_dec for class_id=$class_id\n"unless defined $file->{sigma_dec};82 # die "Unable to find zp for class_id=$class_id\n"unless defined $file->{zp};93 &my_die("Unable to find bg for class_id=$class_id", $exp_tag, $PS_EXIT_SYS_ERROR) unless defined $file->{bg}; 94 &my_die("Unable to find bg_mean_stdev for class_id=$class_id", $exp_tag, $PS_EXIT_SYS_ERROR) unless defined $file->{bg_mean_stdev}; 95 # &my_die("Unable to find sigma_ra for class_id=$class_id", $exp_tag, $PS_EXIT_SYS_ERROR) unless defined $file->{sigma_ra}; 96 # &my_die("Unable to find sigma_dec for class_id=$class_id", $exp_tag, $PS_EXIT_SYS_ERROR) unless defined $file->{sigma_dec}; 97 # &my_die("Unable to find zp for class_id=$class_id", $exp_tag, $PS_EXIT_SYS_ERROR) unless defined $file->{zp}; 83 98 push @backgrounds, $file->{bg}; 84 99 push @variances, $file->{bg_stdev}**2; … … 132 147 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 133 148 run(command => $command, verbose => 1); 134 die "Unable to find expected output file: $jpeg1\n" if not -f $jpeg1; 149 unless ($success) { 150 $error_code >> 8; 151 &my_die("Unable to perform ppImage: $error_code", $exp_tag, $error_code); 152 } 153 &my_die("Unable to find expected output file: $jpeg1", $exp_tag, $PS_EXIT_PROG_ERROR) unless -f $jpeg1; 135 154 } 136 155 … … 140 159 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 141 160 run(command => $command, verbose => 1); 142 die "Unable to find expected output file: $jpeg2\n" if not -f $jpeg2; 161 unless ($success) { 162 $error_code >> 8; 163 &my_die("Unable to perform ppImage: $error_code", $exp_tag, $error_code); 164 } 165 &my_die("Unable to find expected output file: $jpeg2", $exp_tag, $PS_EXIT_PROG_ERROR) unless -f $jpeg2; 143 166 } 144 167 … … 156 179 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 157 180 run(command => $command, verbose => 1); 158 die "Unable to perform p3tool -addprocessedexp: $error_code\n" if not $success; 181 unless ($success) { 182 $error_code >> 8; 183 warn("Unable to perform dettool -addprocessedexp: $error_code\n"); 184 exit($error_code); 185 } 159 186 160 187 unlink $list1Name; 161 188 unlink $list2Name; 162 189 } 190 191 192 sub my_die 193 { 194 my $msg = shift; # Warning message on die 195 my $exp_tag = shift; # Exposure tag 196 my $exit_code = shift; # Exit code to add 197 198 warn($msg); 199 if ($exp_tag) { 200 my $command = "$dettool -addprocessedexp -exp_tag $exp_tag -code $exit_code"; 201 $command .= " -dbname $dbname" if defined $dbname; 202 system ($command); 203 } 204 exit $exit_code; 205 } 206 163 207 164 208 END {
Note:
See TracChangeset
for help on using the changeset viewer.
