Changeset 27301 for trunk/ippScripts/scripts/magic_destreak.pl
- Timestamp:
- Mar 16, 2010, 12:39:45 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/magic_destreak.pl (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/magic_destreak.pl
r26554 r27301 32 32 my $camtool = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1); 33 33 my $censorObjects = can_run('censorObjects') or (warn "Can't find censorObjects" and $missing_tools = 1); 34 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 34 35 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 35 36 if ($missing_tools) { … … 39 40 40 41 # Parse the command-line arguments 41 my ($magic_ds_id, $camera, $streaks, $inv_streaks, $exp_id, $stage, $stage_id, $component, $uri, $path_base, $cam_path_base );42 my ($magic_ds_id, $camera, $streaks, $inv_streaks, $exp_id, $stage, $stage_id, $component, $uri, $path_base, $cam_path_base, $cam_reduction); 42 43 my ($outroot, $recoveryroot); 43 44 my ($replace, $release); … … 56 57 'path_base=s' => \$path_base, # path_base of the input 57 58 'cam_path_base=s'=> \$cam_path_base, # path_base from camera stage (for chip and raw) 59 'cam_reduction=s'=> \$cam_reduction, # reduction class from camera stage (for chip and raw) 58 60 'outroot=s' => \$outroot, # "directory" for temporary images (may be nebulous) 59 61 'recoveryroot=s' => \$recoveryroot,# "directory" for saving the images of excised pixels … … 84 86 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 85 87 $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR ) if $logfile; 88 my $recipe_psastro = $ipprc->reduction($cam_reduction, 'PSASTRO'); # Recipe to use 89 &my_die("Unrecognised PSASTRO recipe", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_psastro; 86 90 87 91 my ($skycell_args, $class_id, $skycell_id); … … 97 101 } elsif ($stage ne "camera") { 98 102 &my_die("Invalid value for stage: $stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 99 } 103 } 100 104 $inv_streaks = undef if defined($inv_streaks) and ($inv_streaks eq "NULL"); 101 105 … … 114 118 if ($stage eq 'camera') { 115 119 my $nebulousServer = metadataLookupStr( $ipprc->{_siteConfig}, 'NEB_SERVER' ); 116 &my_die("cannot find NEB_SERVER in site configuration", 117 $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) 120 &my_die("cannot find NEB_SERVER in site configuration", 121 $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) 118 122 if !$ nebulousServer; 119 123 … … 233 237 $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $class_id) if $release ; 234 238 } elsif ($stage eq "chip") { 239 240 # Check to see if we're using dynamic masks 241 my $dynamicMasks; # Use dynamic masks? 242 { 243 # Get the PSASTRO recipe 244 my $command = "$ppConfigDump -camera $camera -recipe PSASTRO $recipe_psastro -dump-recipe PSASTRO -"; 245 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 246 run(command => $command, verbose => $verbose); 247 unless ($success) { 248 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 249 &my_die("Unable to perform ppConfigDump: $error_code", $magic_ds_id, $component, 250 $PS_EXIT_CONFIG_ERROR); 251 } 252 my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or 253 &my_die("Unable to parse metadata config doc", $magic_ds_id, $component, 254 $PS_EXIT_CONFIG_ERROR); 255 256 $dynamicMasks = metadataLookupBool($recipeData, 'REFSTAR_MASK'); 257 } 258 235 259 # we use the mask output from the camera stage for input and replace 236 260 # the output of the chip stage with that mask as well. 237 261 $image = $ipprc->filename("PPIMAGE.CHIP", $path_base, $class_id); 238 $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $class_id);239 $ch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $path_base, $class_id);240 262 $weight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $path_base, $class_id); 241 263 $astrom = $ipprc->filename("PSASTRO.OUTPUT", $cam_path_base); 242 if (!$ipprc->file_exists($mask)) { 243 carp("camera mask file $mask for $component not found. Continuing using mask from chip stage."); 244 $mask = $ch_mask; 245 $ch_mask = undef; 246 } 264 265 if ($dynamicMasks) { 266 $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $class_id); 267 $ch_mask = $ipprc->filename("PPIMAGE.CHIP.MASK", $path_base, $class_id); 268 } else { 269 $mask = $ipprc->filename("PPIMAGE.CHIP.MASK", $path_base, $class_id); 270 } 271 247 272 # XXX: should we censor the sources as well? For now we're leaving them out of the distribution bundles 248 273 # because they confuse people … … 262 287 263 288 if ($inv_streaks) { 264 # create a temporary file containing the contents of the 289 # create a temporary file containing the contents of the 265 290 # two streaks files 266 291 ($allstreaks_fh, $allstreaks_name) = tempfile ("/tmp/all.streaks.XXXX", … … 357 382 my $quality = $file->{quality}; 358 383 if (!$quality) { 359 my $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $path_base, $class_id); 384 my $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $path_base, $class_id); 360 385 if (! $ipprc->file_exists($mask)) { 361 386 # camera mask doesn't exist for this chip. Fall back to the chip mask … … 379 404 &my_die("Unable to perform censorObjects: $error_code", $magic_ds_id, $component, $error_code); 380 405 } 381 my $output = $ipprc->filename("CENSOR.OUTPUT", $backup_path_base); 406 my $output = $ipprc->filename("CENSOR.OUTPUT", $backup_path_base); 382 407 &my_die("expected output file $output not found ", $magic_ds_id, $component, $PS_EXIT_DATA_ERROR) 383 408 unless $ipprc->file_exists($output); … … 481 506 } 482 507 483 close $fout 508 close $fout 484 509 or my_die("failed to close combined streaks file", $magic_ds_id, 485 510 $component, $PS_EXIT_UNKNOWN_ERROR);
Note:
See TracChangeset
for help on using the changeset viewer.
