Changeset 35715 for trunk/ippScripts/scripts/camera_exp.pl
- Timestamp:
- Jun 26, 2013, 4:44:14 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/camera_exp.pl (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/camera_exp.pl
r35367 r35715 53 53 'skip-binned' => \$skip_binned, # override recipe - don't create binned images 54 54 'skip-refmask' => \$skip_masks, # override recipe - don't create refmask 55 'bkg-only' => \$bkg_only, # override recipe - only do background continuity55 # 'bkg-only' => \$bkg_only, # override recipe - only do background continuity 56 56 'verbose' => \$verbose, # Print to stdout 57 57 'no-update' => \$no_update, # Update the database? … … 79 79 80 80 my $replicateOutputs = 1; 81 82 $ipprc->outroot_prepare($outroot); 81 83 82 84 my $logDest; … … 193 195 194 196 195 my $ produceMasks; # Produce masks?197 my $do_masks; # Produce masks? 196 198 if (!$skip_masks) { 197 199 # Get the PSASTRO recipe … … 206 208 &my_die("Unable to parse metadata config doc", $cam_id, $PS_EXIT_CONFIG_ERROR); 207 209 208 $ produceMasks = metadataLookupBool($recipeData, 'REFSTAR_MASK');210 $do_masks = metadataLookupBool($recipeData, 'REFSTAR_MASK'); 209 211 } 210 212 … … 220 222 my ($list5File, $list5Name) = tempfile( "/tmp/$exp_tag.cm.$cam_id.b5.list.XXXX", UNLINK => !$save_temps ); # For background models 221 223 222 # XXX we perform astrometry iff photometry output exists 224 225 my $do_stats; 226 my $do_bkg; 227 my $do_jpegs; 228 my $fpaStats; 229 my $psastroInputArg; 230 if ($run_state eq 'new') { 231 $do_stats = 1; 232 $do_bkg = 1; 233 $do_jpegs = !$skip_binned; 234 $fpaStats = prepare_output("PSASTRO.STATS", $outroot, undef, 1); 235 $psastroInputArg = " -list $list3Name"; 236 } else { 237 # for $run_state eq 'update' we onlly rebuild the masks using psastro 238 $do_stats = 0; 239 $do_jpegs = 0; 240 $do_bkg = 1; # we could skip this step if camProcessedExp.backgroun_model is non zero 241 242 if (!$do_masks) { 243 &my_die("run_state is update but do_masks is F. I have nothing to do!!", $cam_id, $PS_EXIT_UNKNOWN_ERROR) 244 } 245 246 # the input to psastro is the original PSASTRO.OUTPUT 247 248 # Check for file with rule PSASTRO.OUTPUT.ORGINAL 249 # This file will exist if we attempted to update this camRun before but faulted 250 # XXX: make sure cleanup deals with these files 251 my $inputObjects = $ipprc->filename("PSASTRO.OUTPUT.ORIGINAL", $outroot, undef); 252 if (!$ipprc->file_exists($inputObjects)) { 253 # not found so original file should still be in place. 254 # Rename it. 255 my $originalObjects = $ipprc->filename("PSASTRO.OUTPUT", $outroot, undef); 256 if ($ipprc->file_exists($originalObjects)) { 257 258 unless ($ipprc->file_rename($originalObjects, $inputObjects)) { 259 &my_die("failed to rename $originalObjects to $inputObjects", $cam_id, $PS_EXIT_UNKNOWN_ERROR); 260 } 261 262 # ok ready to go 263 } else { 264 print STDERR "failed to find input objects to update\n"; 265 print STDERR "Original file name: $originalObjects\n"; 266 print STDERR "Saved file name: $inputObjects\n"; 267 268 &my_die("Cannot proceed.", $cam_id, $PS_EXIT_DATA_ERROR); 269 270 # XXX: actually we could use the chip stage cmfs as inputs and turn on astrometry 271 # ... except that somebody (me) got the bright idea to save space and 272 # changed chip stage cleanup to remove them. So we're kind of stuck. 273 } 274 } 275 $psastroInputArg = " -file $inputObjects -skipastro"; 276 } 277 278 223 279 my @outMasks; # Names of output masks 224 280 my @bkg_models; # Names of output background models 225 281 foreach my $file (@$files) { 282 # we perform astrometry iff photometry output exists 226 283 next if $file->{quality} != 0; 284 227 285 # use the path_base as OUTPUT root and convert the filenames with ipprc->filename: 228 286 my $class_id = $file->{class_id}; … … 239 297 print $list5File ($ipprc->filename("PSPHOT.BACKMDL", $file->{path_base}, $class_id) . "\n"); 240 298 241 push @outMasks, prepare_output("PSASTRO.OUTPUT.MASK", $outroot, $class_id, 1) if $ produceMasks;242 push @bkg_models, prepare_output("PPIMAGE.BACKMDL", $outroot, $class_id, 1) ;299 push @outMasks, prepare_output("PSASTRO.OUTPUT.MASK", $outroot, $class_id, 1) if $do_masks; 300 push @bkg_models, prepare_output("PPIMAGE.BACKMDL", $outroot, $class_id, 1) if $do_bkg; 243 301 } 244 302 close $list1File; … … 247 305 close $list4File; 248 306 close $list5File; 249 # Output products 250 $ipprc->outroot_prepare($outroot); 307 308 # Prepare the Output products 251 309 252 310 # the camera configurations should define the psastro output to be a single file (MEF), regardless of the inputs 253 my $jpeg1 = prepare_output("PPIMAGE.JPEG1", $outroot, undef, 1); 254 my $jpeg2 = prepare_output("PPIMAGE.JPEG2", $outroot, undef, 1); 255 my $fpaObjects = prepare_output("PSASTRO.OUTPUT", $outroot, undef, 1); 256 my $configuration = prepare_output("PSASTRO.CONFIG", $outroot, undef, 1); 257 258 my $do_stats; 259 my $fpaStats; 311 my $jpeg1 = prepare_output("PPIMAGE.JPEG1", $outroot, undef, 1) if $do_jpegs; 312 my $jpeg2 = prepare_output("PPIMAGE.JPEG2", $outroot, undef, 1) if $do_jpegs; 313 my $fpaObjects = prepare_output("PSASTRO.OUTPUT", $outroot, undef, 1) if !$bkg_only; 314 315 my $configuration; 260 316 if ($run_state eq 'new') { 261 $do_stats = 1; 262 $fpaStats = prepare_output("PSASTRO.STATS", $outroot, undef, 1); 317 $configuration = prepare_output("PSASTRO.CONFIG", $outroot, undef, 1); 263 318 } else { 264 $do_stats = 0; 265 } 319 # Do not use the original recipes because they might contain the 320 # recipe values that caused the masks to get fouled up in the first place 321 # $configuration = $ipprc->filename("PSASTRO.CONFIG", $outroot, undef); 322 } 323 266 324 267 325 unless ($no_op) { … … 269 327 ## build the output JPEG images first so we get them even if the astrometry fails 270 328 271 # Make the jpeg for binning 1272 if (!$skip_binned and ($run_state eq 'new')) {329 if ($do_jpegs) { 330 # Make the jpeg for binning 1 273 331 my $command = "$ppImage -list $list1Name $outroot"; # Command to run 274 332 $command .= " -recipe PPIMAGE $recipe1"; … … 282 340 } 283 341 check_output($jpeg1, $replicateOutputs); 284 } 285 286 # Make the jpeg for binning 2 287 if (!$skip_binned and ($run_state eq 'new')) { 288 my $command = "$ppImage -list $list2Name $outroot"; # Command to run 342 343 # Make the jpeg for binning 2 344 345 $command = "$ppImage -list $list2Name $outroot"; # Command to run 289 346 $command .= " -recipe PPIMAGE $recipe2"; 290 347 $command .= " -dbname $dbname" if defined $dbname; 291 348 292 my( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =349 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 293 350 run(command => $command, verbose => $verbose); 294 351 unless ($success) { … … 302 359 # run psastro on the chipObjects, producing fpaObjects 303 360 my $command; 304 $command = "$psastro";305 $command .= " -list $list3Name";306 $command .= " -masklist $list4Name" if $ produceMasks;361 $command = $psastro; 362 $command .= " $psastroInputArg"; 363 $command .= " -masklist $list4Name" if $do_masks; 307 364 $command .= " $outroot"; 308 365 $command .= " -recipe PSASTRO $recipe_psastro"; 309 $command .= " -Db PSASTRO:REFSTAR_MASK F" if $skip_masks;366 $command .= " -Db PSASTRO:REFSTAR_MASK F" if !$do_masks; 310 367 $command .= " -tracedest $traceDest -log $logDest"; 311 368 $command .= " -dbname $dbname" if defined $dbname; … … 314 371 $command .= " -dumpconfig $configuration"; 315 372 } elsif ($run_state eq 'update') { 316 $command .= " -ipprc $configuration" ;373 $command .= " -ipprc $configuration" if $configuration; 317 374 } else { 318 375 &my_die("invalid value for run-state: $run_state", $cam_id, $PS_EXIT_CONFIG_ERROR); … … 362 419 } 363 420 } 421 364 422 # Construct FPA continuity corrected background images 365 423 if ($camera =~ /ISP/) { 366 424 print "Skipping FPA continuity corrected background images for ISP\n"; 367 } els e{425 } elsif ($do_bkg) { 368 426 my $command; 369 427 $command = "$ppImage"; … … 381 439 check_output($bkgModel, $replicateOutputs); 382 440 } 383 $cmdflags = $cmdflags . " -background_model 1 "; 441 if ($run_state eq 'new') { 442 $cmdflags .= " -background_model 1 "; 443 } else { 444 my $command = "camtool -updateprocessedexp -set_background_model 1 -fault 0 -cam_id $cam_id"; 445 $command .= " -dbname $dbname" if $dbname; 446 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 447 run(command => $command, verbose => $verbose); 448 unless ($success) { 449 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 450 &my_die("Unable to updateprocessedexp to set background_model: $error_code", $cam_id, $error_code); 451 } 452 } 384 453 } 385 454 }
Note:
See TracChangeset
for help on using the changeset viewer.
