- Timestamp:
- Dec 3, 2010, 2:35:32 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20101103/ippScripts/scripts/camera_exp.pl
r28043 r29906 70 70 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $cam_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 71 71 72 my $logDest = $ipprc->filename("LOG.EXP", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR);73 74 72 if (not defined $run_state) { $run_state = 'new'; } 75 if ($run_state eq 'update') { 76 $logDest .= '.update'; 73 74 my_die ("$run_state is an invalid value for run-state", $cam_id, $PS_EXIT_PROG_ERROR) unless ($run_state eq 'new' or $run_state eq 'update'); 75 76 77 my $replicateOutputs = 1; 78 79 my $logDest; 80 my $traceDest; 81 if ($run_state eq 'new') { 82 $logDest = prepare_output("LOG.EXP", $outroot, undef, 0); 83 $traceDest = prepare_output("TRACE.EXP", $outroot, undef, 0); 84 } else { 85 $logDest = prepare_output("LOG.EXP.UPDATE", $outroot, undef, 0); 86 $traceDest = prepare_output("TRACE.EXP.UPDATE", $outroot, undef, 0); 77 87 } 78 88 … … 188 198 print $list4File ($chipMask . "\n"); 189 199 190 push @outMasks, $ipprc->filename("PSASTRO.OUTPUT.MASK", $outroot, $class_id) if $produceMasks;200 push @outMasks, prepare_output("PSASTRO.OUTPUT.MASK", $outroot, $class_id, 1) if $produceMasks; 191 201 } 192 202 close $list1File; … … 199 209 200 210 # the camera configurations should define the psastro output to be a single file (MEF), regardless of the inputs 201 my $jpeg1 = $ipprc->filename("PPIMAGE.JPEG1", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR); 202 my $jpeg2 = $ipprc->filename("PPIMAGE.JPEG2", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR); 203 my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR); 204 my $fpaStats = $ipprc->filename("PSASTRO.STATS", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR); 205 my $traceDest = $ipprc->filename("TRACE.EXP", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR); 206 my $configuration = $ipprc->filename("PSASTRO.CONFIG", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR); 207 208 if ($run_state eq 'update') { 209 $traceDest .= '.update'; 210 $fpaStats .= '.update'; 211 } 212 213 # convert supplied DVO database name to UNIX filename 214 my $dvodbReal; 215 if (defined $dvodb) { 216 $dvodbReal = $ipprc->dvo_catdir( $dvodb ); # catdir for DVO 217 $dvodbReal = $ipprc->convert_filename_absolute( $dvodbReal ); 218 } 219 220 #my $dtime_addstar = 0; 211 my $jpeg1 = prepare_output("PPIMAGE.JPEG1", $outroot, undef, 1); 212 my $jpeg2 = prepare_output("PPIMAGE.JPEG2", $outroot, undef, 1); 213 my $fpaObjects = prepare_output("PSASTRO.OUTPUT", $outroot, undef, 1); 214 my $configuration = prepare_output("PSASTRO.CONFIG", $outroot, undef, 1); 215 216 my $do_stats; 217 my $fpaStats; 218 if ($run_state eq 'new') { 219 $do_stats = 1; 220 $fpaStats = prepare_output("PSASTRO.STATS", $outroot, undef, 1); 221 } else { 222 $do_stats = 0; 223 } 221 224 222 225 unless ($no_op) { … … 236 239 &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code); 237 240 } 238 &my_die("Unable to find expected output file: $jpeg1", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($jpeg1);241 check_output($jpeg1, $replicateOutputs); 239 242 } 240 243 … … 251 254 &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code); 252 255 } 253 &my_die("Unable to find expected output file: $jpeg2", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($jpeg2);256 check_output($jpeg2, $replicateOutputs); 254 257 } 255 258 … … 265 268 $command .= " -dbname $dbname" if defined $dbname; 266 269 267 my $do_stats;268 270 if ($run_state eq 'new') { 269 $command .= " -stats $fpaStats -recipe PPSTATS CAMSTATS";270 271 $command .= " -dumpconfig $configuration"; 271 $do_stats = 1;272 272 } elsif ($run_state eq 'update') { 273 273 $command .= " -ipprc $configuration"; … … 275 275 &my_die("invalid value for run-state: $run_state", $cam_id, $PS_EXIT_CONFIG_ERROR); 276 276 } 277 $command .= " -stats $fpaStats -recipe PPSTATS CAMSTATS" if $do_stats; 277 278 278 279 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 286 287 my $quality; # Quality flag 287 288 if ($do_stats) { 289 check_output($fpaStats, $replicateOutputs); 290 288 291 my $fpaStatsReal = $ipprc->file_resolve($fpaStats); 289 &my_die("Couldn't find expected output file: $fpaStats", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $fpaStatsReal );290 292 291 293 # parse stats from metadata … … 306 308 307 309 if (!$quality) { 308 &my_die("Unable to find expected output file: $fpaObjects", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($fpaObjects);310 check_output($fpaObjects, $replicateOutputs); 309 311 310 312 foreach my $outMask (@outMasks) { 311 &my_die("Unable to find expected output file: $outMask", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outMask);313 check_output($outMask, $replicateOutputs); 312 314 } 313 315 314 316 if ($run_state eq 'new') { 315 &my_die("Couldn't find expected output file: $configuration", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($configuration);317 check_output($configuration, $replicateOutputs); 316 318 } 317 319 } 318 319 # run addstar on the output fpaObjects (if a DVO database is defined)320 # if (defined $dvodbReal and ($run_state eq 'new')) {321 322 # ## XXX the camera analysis can either save the full set of323 # ## detections, or just the image metadata, in the dvodb324 325 # ## get the addstar recipe for this camera and CAMERA reduction326 # $command = "$ppConfigDump -camera $camera -recipe ADDSTAR $recipe_addstar -dump-recipe ADDSTAR -";327 # ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =328 # run(command => $command, verbose => $verbose);329 # unless ($success) {330 # $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);331 # &my_die("Unable to perform ppConfigDump: $error_code", $cam_id, $PS_EXIT_SYS_ERROR);332 # }333 # my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or334 # &my_die("Unable to parse metadata config doc", $cam_id, $PS_EXIT_SYS_ERROR);335 336 # ## allow the dvodb to save only images, or the full detection set337 # my $imagesOnly = metadataLookupBool($recipeData, 'IMAGES.ONLY');338 339 # # XXX this construct requires the user to have a valid .ptolemyrc340 # # XXX which in turn points at ippconfig/dvo.site341 # # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default)342 # # XXX this needs to be converted to addstar_client...343 344 # my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar345 # my $command;346 # $command = "$addstar -D CAMERA $camdir -update";347 # $command .= " -image" if $imagesOnly;348 # $command .= " -D CATDIR $dvodbReal";349 350 # my $realFile = $ipprc->file_resolve($fpaObjects);351 # $command .= " $realFile";352 353 # my $mjd_addstar_start = DateTime->now->mjd; # MJD of starting script354 355 # my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =356 # run(command => $command, verbose => $verbose);357 # unless ($success) {358 # $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);359 # &my_die("Unable to perform addstar: $error_code", $cam_id, $error_code);360 # }361 # $dtime_addstar = 86400.0*(DateTime->now->mjd - $mjd_addstar_start); # MJD of starting script362 # }363 320 } 364 321 } … … 374 331 $fpaCommand .= " -hostname $host" if defined $host; 375 332 $fpaCommand .= " -dtime_script $dtime_script"; 376 # $fpaCommand .= " -dtime_addstar $dtime_addstar";377 333 } else { 378 334 $fpaCommand .= " -updaterun -set_state full"; … … 393 349 } 394 350 351 exit 0; 352 353 sub prepare_output 354 { 355 my $filerule = shift; 356 my $outroot = shift; 357 my $class_id = shift; 358 my $delete = shift; 359 $delete = 0 if !defined $delete; 360 361 my $error; 362 my $output = $ipprc->prepare_output($filerule, $outroot, $class_id, $delete, \$error) 363 or &my_die("failed to prepare output file for: $filerule", $cam_id, $error); 364 365 return $output; 366 } 367 368 sub check_output 369 { 370 my $file = shift; 371 my $replicate = shift; 372 373 if (!defined $file) { 374 return; 375 } 376 377 &my_die("Couldn't find expected output file: $file", $cam_id, $PS_EXIT_SYS_ERROR) unless 378 $ipprc->file_exists($file); 379 380 if ($replicate and (file_scheme($file) eq 'neb')) { 381 $ipprc->replicate_file($file) or &my_die("failed to replicate: $file\n", $cam_id, $PS_EXIT_SYS_ERROR); 382 } 383 } 395 384 396 385 sub my_die
Note:
See TracChangeset
for help on using the changeset viewer.
