Changeset 22430 for trunk/ippScripts/scripts/detrend_correct_imfile.pl
- Timestamp:
- Feb 24, 2009, 12:00:25 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_correct_imfile.pl
r20378 r22430 24 24 use Pod::Usage qw( pod2usage ); 25 25 26 # Look for programs we need 27 my $missing_tools; 28 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 29 my $dvoApplyCorr = can_run('dvoApplyCorr') or (warn "Can't find dvoApplyCorr" and $missing_tools = 1); 30 if ($missing_tools) { 31 warn("Can't find required tools."); 32 exit($PS_EXIT_CONFIG_ERROR); 33 } 34 26 35 my ( $det_id, $class_id, $det_type, $input_uri, $camera, $dbname, 27 36 $verbose, $no_update, $no_op, $outroot, $redirect, $corr_uri ); … … 43 52 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 44 53 pod2usage( -msg => "Required options: --det_id --class_id --det_type --input_uri --camera --outroot", 45 -exitval => 3)54 -exitval => 3) 46 55 unless defined $det_id 47 56 and defined $class_id … … 50 59 and defined $outroot 51 60 and defined $camera; 61 62 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 63 $SIG{__DIE__} = sub { die @_ if $^S; 64 my_die( $_[0], $det_id, $class_id, $PS_EXIT_UNKNOWN_ERROR ); }; 52 65 53 66 # XXX this exits with status = 0 on failure … … 60 73 } 61 74 62 # Recipes to use as a function of detrend type 63 # XXX there are no recipe options for dvoApplyCorr... 75 # Recipes to use as a function of detrend type 76 # XXX there are no recipe options for dvoApplyCorr... 64 77 # XXX in the future, we may define corrections other than the flat-field correction 65 78 # $reduction = "DETREND" unless defined $reduction; … … 69 82 # det_type is type of the CORRECTED (output) file 70 83 if ($det_type ne "FLAT") { warn ("unexpected input detrend type: correcting data of type $det_type"); } 71 72 # Look for programs we need73 my $missing_tools;74 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);75 my $dvoApplyCorr = can_run('dvoApplyCorr') or (warn "Can't find dvoApplyCorr" and $missing_tools = 1);76 if ($missing_tools) {77 warn("Can't find required tools.");78 exit($PS_EXIT_CONFIG_ERROR);79 }80 84 81 85 &my_die("Couldn't find input file: $input_uri\n", $det_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input_uri); … … 91 95 92 96 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 93 run(command => $command, verbose => $verbose);97 run(command => $command, verbose => $verbose); 94 98 unless ($success) { 95 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);96 &my_die("Unable to perform ppImage: $error_code", $det_id, $class_id, $error_code);99 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 100 &my_die("Unable to perform ppImage: $error_code", $det_id, $class_id, $error_code); 97 101 } 98 102 … … 111 115 unless ($no_update) { 112 116 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 113 run(command => $command, verbose => $verbose);117 run(command => $command, verbose => $verbose); 114 118 unless ($success) { 115 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);116 warn("Unable to perform dettool -addcorrectimfile: $error_code\n");117 exit($error_code);119 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 120 warn("Unable to perform dettool -addcorrectimfile: $error_code\n"); 121 exit($error_code); 118 122 } 119 123 } else { … … 124 128 { 125 129 my $msg = shift; # Warning message on die 126 my $det_id = shift; # Detrend identifier130 my $det_id = shift; # Detrend identifier 127 131 my $class_id = shift; # Class identifier 128 132 my $exit_code = shift; # Exit code to add … … 130 134 carp($msg); 131 135 if (defined $det_id and defined $class_id and not $no_update) { 132 my $command = "$dettool -addcorrectimfile";133 $command .= " -det_id $det_id";134 $command .= " -class_id $class_id";135 $command .= " -path_base $outroot";136 $command .= " -code $exit_code";137 $command .= " -dbname $dbname" if defined $dbname;136 my $command = "$dettool -addcorrectimfile"; 137 $command .= " -det_id $det_id"; 138 $command .= " -class_id $class_id"; 139 $command .= " -path_base $outroot"; 140 $command .= " -code $exit_code"; 141 $command .= " -dbname $dbname" if defined $dbname; 138 142 system ($command); 139 143 }
Note:
See TracChangeset
for help on using the changeset viewer.
