Changeset 27718 for trunk/ippScripts/scripts/flatcorr_proc.pl
- Timestamp:
- Apr 21, 2010, 11:35:15 AM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/flatcorr_proc.pl (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/flatcorr_proc.pl
r25916 r27718 11 11 # dvoMakeCorr -file outgrid.fits -ref ref.fits outcorr 12 12 13 # dettool -register -det_type FLATCORR -filelevel (level) -workdir -inst, etc 14 15 # foreach $imfile () 13 # dettool -register -det_type FLATCORR -filelevel (level) -workdir -inst, etc 14 15 # foreach $imfile () 16 16 # dettool -register_imfile -uri, etc, etc 17 17 … … 23 23 use Sys::Hostname; 24 24 my $host = hostname(); 25 my $date = `date`; 25 26 print "\n\n"; 26 print "Starting script $0 on $host \n\n";27 print "Starting script $0 on $host at $date\n\n"; 27 28 28 29 use vars qw( $VERSION ); … … 74 75 my $addstar = can_run('addstar') or (warn "Can't find addstar" and $missing_tools = 1); 75 76 my $dvoMakeCorr = can_run('dvoMakeCorr') or (warn "Can't find dvoMakeCorr" and $missing_tools = 1); 76 my $detselect = can_run('detselect') or (warn "Can't find detselect" and $missing_tools = 1);77 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);78 my $flatcorr = can_run('flatcorr') or (warn "Can't find flatcorr" and $missing_tools = 1);79 80 if ($missing_tools) { 77 my $detselect = can_run('detselect') or (warn "Can't find detselect" and $missing_tools = 1); 78 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 79 my $flatcorr = can_run('flatcorr') or (warn "Can't find flatcorr" and $missing_tools = 1); 80 81 if ($missing_tools) { 81 82 warn ("Can't find required tools"); 82 exit($PS_EXIT_CONFIG_ERROR); 83 exit($PS_EXIT_CONFIG_ERROR); 83 84 } 84 85 … … 95 96 $ipprc->outroot_prepare($outcorr); 96 97 97 if (not -e "$dvodb/flatcorr") { 98 if (not -e "$dvodb/flatcorr") { 98 99 mkdir "$dvodb/flatcorr" or &my_die ("Unable to make output directory for relphot $dvodb/flatcorr", $corr_id, 3); 99 100 } … … 104 105 my ($DECs, $DECe) = split (",", $coords[1]); 105 106 106 # Run addstar -resort to ensure the db is indexed 107 # Run addstar -resort to ensure the db is indexed 107 108 # XXX addstar should be able to recognize and skip indexed tables 108 109 { 109 my $command = "$addstar -resort"; 110 my $command = "$addstar -resort"; 110 111 $command .= " -D CATDIR $dvodb"; 111 112 $command .= " -region $RAs $RAe $DECs $DECe"; 112 113 113 114 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 114 run(command => $command, verbose => $verbose);115 116 unless ($success) { 117 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);118 &my_die ("Unable to perform addstar -resort for dvodb $dvodb on region $region: $error_code", $corr_id, $error_code);115 run(command => $command, verbose => $verbose); 116 117 unless ($success) { 118 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 119 &my_die ("Unable to perform addstar -resort for dvodb $dvodb on region $region: $error_code", $corr_id, $error_code); 119 120 } 120 121 } … … 135 136 136 137 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 137 run(command => $command, verbose => $verbose);138 139 unless ($success) { 140 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);141 &my_die ("Unable to perform relphot -grid for dvodb $dvodb on region $region: $error_code", $corr_id, $error_code);138 run(command => $command, verbose => $verbose); 139 140 unless ($success) { 141 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 142 &my_die ("Unable to perform relphot -grid for dvodb $dvodb on region $region: $error_code", $corr_id, $error_code); 142 143 } 143 144 } … … 176 177 177 178 # Push the results into the database 178 { 179 { 179 180 my $command = "$flatcorr -addprocess"; 180 181 $command .= " -corr_id $corr_id"; … … 184 185 unless ($no_update) { 185 186 186 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =187 run(command => $command, verbose => $verbose);188 unless ($success) {189 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);190 warn ("Unable to perform regtool -addprocessedimfile: $error_code");191 exit($error_code);192 }187 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 188 run(command => $command, verbose => $verbose); 189 unless ($success) { 190 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 191 warn ("Unable to perform regtool -addprocessedimfile: $error_code"); 192 exit($error_code); 193 } 193 194 } else { 194 print "skipping command: $command\n";195 print "skipping command: $command\n"; 195 196 } 196 197 } … … 218 219 &my_die("Unable to parse metadata list", $corr_id, $PS_EXIT_PROG_ERROR); 219 220 220 # check for existence 221 # check for existence 221 222 my $file = $$files[0]; 222 223 my $chip_id = $file->{chip_id}; … … 228 229 # flatcorr -inputimfile -chip_id $chip_id 229 230 sub get_imfiles { 230 my $chip_id = shift; 231 my $chip_id = shift; 231 232 232 233 my $command = "$flatcorr -inputimfile"; … … 273 274 274 275 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 275 run(command => $command, verbose => $verbose);276 277 unless ($success) { 278 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);279 &my_die ("Unable to register new detrend: $error_code", $corr_id, $PS_EXIT_PROG_ERROR);276 run(command => $command, verbose => $verbose); 277 278 unless ($success) { 279 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 280 &my_die ("Unable to register new detrend: $error_code", $corr_id, $PS_EXIT_PROG_ERROR); 280 281 } 281 282 … … 298 299 299 300 foreach my $file (@$files) { 300 # create the detrend correction for the imfiles based on the input imfiles301 my $reffile = $file->{uri};302 my $class_id = $file->{class_id};303 304 my $uri = $ipprc->filename("DVOCORR.OUTPUT", $outcorr, $class_id);305 unless ($uri) {306 &my_die ("Unable to find DVOCORR.OUTPUT in filerules", $corr_id, $PS_EXIT_PROG_ERROR);307 }308 309 my $command = "$dvoMakeCorr $outcorr";310 $command .= " -file $outgrid.fits";311 $command .= " -ref $reffile";312 313 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =314 run(command => $command, verbose => $verbose);315 316 unless ($success) { 317 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);318 &my_die ("Unable to perform dvoMakeCorr: $error_code", $corr_id, $PS_EXIT_PROG_ERROR);319 }320 321 # register the detrend correction imfile322 $command = "$dettool -register_detrend_imfile";323 $command .= " -det_id $det_id";324 $command .= " -class_id $class_id";325 $command .= " -uri $uri";326 $command .= " -dbname $dbname" if defined $dbname;327 328 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =329 run(command => $command, verbose => $verbose);330 331 unless ($success) { 332 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);333 &my_die ("Unable to register new detrend: $error_code", $corr_id, $PS_EXIT_PROG_ERROR);334 }301 # create the detrend correction for the imfiles based on the input imfiles 302 my $reffile = $file->{uri}; 303 my $class_id = $file->{class_id}; 304 305 my $uri = $ipprc->filename("DVOCORR.OUTPUT", $outcorr, $class_id); 306 unless ($uri) { 307 &my_die ("Unable to find DVOCORR.OUTPUT in filerules", $corr_id, $PS_EXIT_PROG_ERROR); 308 } 309 310 my $command = "$dvoMakeCorr $outcorr"; 311 $command .= " -file $outgrid.fits"; 312 $command .= " -ref $reffile"; 313 314 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 315 run(command => $command, verbose => $verbose); 316 317 unless ($success) { 318 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 319 &my_die ("Unable to perform dvoMakeCorr: $error_code", $corr_id, $PS_EXIT_PROG_ERROR); 320 } 321 322 # register the detrend correction imfile 323 $command = "$dettool -register_detrend_imfile"; 324 $command .= " -det_id $det_id"; 325 $command .= " -class_id $class_id"; 326 $command .= " -uri $uri"; 327 $command .= " -dbname $dbname" if defined $dbname; 328 329 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 330 run(command => $command, verbose => $verbose); 331 332 unless ($success) { 333 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 334 &my_die ("Unable to register new detrend: $error_code", $corr_id, $PS_EXIT_PROG_ERROR); 335 } 335 336 } 336 337 } … … 345 346 if (not $no_update) { 346 347 my $command = "$flatcorr -addprocess"; 347 $command .= " -corr_id $corr_id";348 $command .= " -corr_id $corr_id"; 348 349 $command .= " -fault $exit_code"; 349 350 $command .= " -hostname $host" if defined $host;
Note:
See TracChangeset
for help on using the changeset viewer.
