- Timestamp:
- Mar 29, 2010, 3:55:49 PM (16 years ago)
- Location:
- branches/eam_branches/20100225
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/magic_destreak_revert.pl (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20100225
- Property svn:mergeinfo changed
-
branches/eam_branches/20100225/ippScripts/scripts/magic_destreak_revert.pl
r27015 r27517 30 30 my $magicdstool = can_run('magicdstool') or (warn "Can't find magicdstool" and $missing_tools = 1); 31 31 my $isdestreaked = can_run('isdestreaked') or (warn "Can't find isdestreaked" and $missing_tools = 1); 32 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 32 33 if ($missing_tools) { 33 34 warn("Can't find required tools."); … … 36 37 37 38 # Parse the command-line arguments 38 my ($magic_ds_id, $camera, $streaks, $stage, $stage_id, $component, $uri, $path_base, $bothways, $cam_path_base );39 my ($magic_ds_id, $camera, $streaks, $stage, $stage_id, $component, $uri, $path_base, $bothways, $cam_path_base, $cam_reduction); 39 40 my ($outroot, $recoveryroot, $replace, $release, $bytes, $md5sum); 40 41 my ($dbname, $save_temps, $verbose, $no_update, $no_op, $logfile); … … 48 49 'path_base=s' => \$path_base, # path_base of the input 49 50 'cam_path_base=s'=> \$cam_path_base, # path_base of the associated camera run 51 'cam_reduction=s'=> \$cam_reduction, # reduction class of the associated camera run 50 52 'outroot=s' => \$outroot, # "directory" for temporary images (may be nebulous) 51 53 'recoveryroot=s' => \$recoveryroot,# "directory" for saving the images of excised pixels … … 79 81 $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR ) if $logfile; 80 82 83 $cam_reduction = 'DEFAULT' if !defined $cam_reduction or ($cam_reduction eq "NULL"); 84 my $recipe_psastro = $ipprc->reduction($cam_reduction, 'PSASTRO'); # Recipe to use 85 &my_die("Unrecognised PSASTRO recipe", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_psastro; 86 81 87 my $nebulousServer = metadataLookupStr( $ipprc->{_siteConfig}, 'NEB_SERVER' ); 82 88 &my_die("cannot find NEB_SERVER in site configuration", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) if !$nebulousServer; … … 112 118 } 113 119 114 &my_die("replace not allowed for non-nebulous files", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) 120 &my_die("replace not allowed for non-nebulous files", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) 115 121 if ($replace eq "T") and !$nebulousInput; 116 122 … … 156 162 $bimage = $backup_path_base . ".fits"; 157 163 } elsif ($stage eq "chip") { 164 # Check to see if we're using dynamic masks 165 my $dynamicMasks; # Use dynamic masks? 166 { 167 # Get the PSASTRO recipe 168 my $command = "$ppConfigDump -camera $camera -recipe PSASTRO $recipe_psastro -dump-recipe PSASTRO -"; 169 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 170 run(command => $command, verbose => $verbose); 171 unless ($success) { 172 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 173 &my_die("Unable to perform ppConfigDump: $error_code", $magic_ds_id, $component, 174 $PS_EXIT_CONFIG_ERROR); 175 } 176 my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or 177 &my_die("Unable to parse metadata config doc", $magic_ds_id, $component, 178 $PS_EXIT_CONFIG_ERROR); 179 180 $dynamicMasks = metadataLookupBool($recipeData, 'REFSTAR_MASK'); 181 } 182 158 183 # we use the mask output from the camera stage for input and replace 159 184 # the output of the chip stage with that mask as well. 160 185 $image = $ipprc->filename("PPIMAGE.CHIP", $path_base, $class_id); 161 $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $class_id);162 $ch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $path_base, $class_id);163 186 $weight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $path_base, $class_id); 187 188 if ($dynamicMasks) { 189 $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $class_id); 190 $ch_mask = $ipprc->filename("PPIMAGE.CHIP.MASK", $path_base, $class_id); 191 } else { 192 $mask = $ipprc->filename("PPIMAGE.CHIP.MASK", $path_base, $class_id); 193 } 164 194 165 195 $bimage = $ipprc->filename("PPIMAGE.CHIP", $backup_path_base, $class_id); … … 253 283 if ($mask) { 254 284 if (!revert_file($mask, $bmask)) { 255 if ($stage eq 'chip') { 256 # don't fail if the mask file (from the camera stage) fails to revert. 257 # It probably doesn't exist 258 # XXX: Handle this properly 259 print STDERR "failure to revert mask file, ignored\n"; 260 } else { 261 &my_die("failed to restore mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 262 } 285 &my_die("failed to restore mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 263 286 } 264 287 } … … 268 291 &my_die("failed to restore chip mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 269 292 } 270 } 293 } 271 294 272 295 … … 306 329 my $original = shift; 307 330 my $backup = shift; 331 my $force = 1; # force deletion of backup files in nebulous 308 332 309 333 my $o_path = $ipprc->file_resolve($original); … … 352 376 } 353 377 354 if ($b_path and -e $b_path) {378 if ($b_path) { 355 379 print "ready to delete backup\n" if $verbose; 356 if (! $ipprc->file_delete($backup )) {380 if (! $ipprc->file_delete($backup, $force)) { 357 381 print "failed to delete $backup\n"; 358 382 return 0; … … 363 387 print "original uri: $original is not a destreaked file no need to swap backup_result: $backup_result\n"; 364 388 # delete the 'backup' (destreaked target) file if it exists 365 if ($b_path and -e $b_path) {366 if (! $ipprc->file_delete($backup )) {389 if ($b_path) { 390 if (! $ipprc->file_delete($backup, $force)) { 367 391 print "failed to delete $backup\n"; 368 392 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.
