Changeset 27301 for trunk/ippScripts/scripts/magic_destreak_cleanup.pl
- Timestamp:
- Mar 16, 2010, 12:39:45 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/magic_destreak_cleanup.pl
r27256 r27301 30 30 my $missing_tools; 31 31 my $magicdstool = can_run('magicdstool') or (warn "Can't find magicdstool" 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 , $force);39 my ($magic_ds_id, $camera); 39 40 my ($dbname, $save_temps, $verbose, $no_update, $no_op, $logfile); 40 41 … … 42 43 'magic_ds_id=s' => \$magic_ds_id,# Magic destreak run identifier 43 44 'camera=s' => \$camera, # camera for evaluating file rules 44 'force' => \$force, # force deletion45 45 'save-temps' => \$save_temps, # Save temporary files? 46 46 'dbname=s' => \$dbname, # Database name … … 87 87 my $dbh = DBI->connect($dsn, $dbuser, $dbpassword) or die "Cannot connect to mysql server\n"; 88 88 89 my $q1 = "SELECT magicDSRun.*, camera, camProcessedExp.path_base AS cam_path_base, magicRun.inverse"90 . " FROM magicDSRun JOIN magicRun USING(magic_id) JOIN rawExp USING(exp_id) LEFT JOIN camProcessedExp USING(cam_id) "89 my $q1 = "SELECT magicDSRun.*, camera, camProcessedExp.path_base AS cam_path_base, camRun.reduction AS cam_reduction, magicRun.inverse" 90 . " FROM magicDSRun JOIN magicRun USING(magic_id) JOIN rawExp USING(exp_id) LEFT JOIN camProcessedExp USING(cam_id) LEFT JOIN camRun USING(cam_id)" 91 91 . " WHERE magic_ds_id = $magic_ds_id"; 92 92 my $q2 = "SELECT * from magicDSFile where magic_ds_id = $magic_ds_id"; 93 94 # my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files95 93 96 94 my $stmt1 = $dbh->prepare($q1); … … 104 102 my $stage_id = $run->{stage_id}; 105 103 my $cam_path_base = $run->{cam_path_base}; 104 my $cam_reduction = $run->{cam_reduction}; 106 105 my $inverse = $run->{inverse}; 107 my $replace = $run->{re_place};108 106 109 107 110 108 &my_die("unexpected run state found: $state", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) if $state ne "goto_cleaned"; 111 &my_die("clean not allowed for raw stage, use goto_restore", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) if ($stage eq "raw"); # XXX: add this once we implement and $replace; 109 &my_die("clean not allowed for raw stage, use goto_restore", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) if $stage eq "raw"; 110 111 my $recipe_psastro = $ipprc->reduction($cam_reduction, 'PSASTRO'); # Recipe to use 112 &my_die("Unrecognised PSASTRO recipe", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_psastro; 112 113 113 114 … … 126 127 127 128 if ($stage eq "chip") { 128 # we use the mask output from the camera stage for input and replace 129 # the output of the chip stage with that mask as well. 130 my $cammask = $cam_path_base ? $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $component) : undef; 129 # Check to see if we're using dynamic masks 130 my $dynamicMasks; # Use dynamic masks? 131 { 132 # Get the PSASTRO recipe 133 my $command = "$ppConfigDump -camera $camera -recipe PSASTRO $recipe_psastro -dump-recipe PSASTRO -"; 134 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 135 run(command => $command, verbose => $verbose); 136 unless ($success) { 137 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 138 &my_die("Unable to perform ppConfigDump: $error_code", $magic_ds_id, $component, 139 $PS_EXIT_CONFIG_ERROR); 140 } 141 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 142 my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or 143 &my_die("Unable to parse metadata config doc", $magic_ds_id, $component, 144 $PS_EXIT_CONFIG_ERROR); 145 146 $dynamicMasks = metadataLookupBool($recipeData, 'REFSTAR_MASK'); 147 } 131 148 132 149 if ($backup_path_base) { 133 150 $bimage = $ipprc->filename("PPIMAGE.CHIP", $backup_path_base, $component); 134 $bch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $backup_path_base, $component); 151 152 if ($dynamicMasks) { 153 my $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $component); 154 # This is kludgey but correct 155 $bmask = dirname($backup_path_base) . "/SR_" . basename($mask); 156 $bch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $backup_path_base, $component); 157 } else { 158 $bmask = $ipprc->filename("PPIMAGE.CHIP.MASK", $backup_path_base, $component); 159 } 135 160 $bweight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $backup_path_base, $component); 136 # This is kludgey but correct 137 138 my $prefix; 139 if ($backup_path_base =~ /\.SR/) { 140 $prefix = ""; 161 } 162 if ($recovery_path_base) { 163 $rimage = $ipprc->filename("PPIMAGE.CHIP", $recovery_path_base, $component); 164 165 if ($dynamicMasks) { 166 my $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $component); 167 # This is kludgey but correct 168 $rmask = dirname($recovery_path_base) . "/" . basename($mask); 169 $rch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $recovery_path_base, $component); 141 170 } else { 142 $prefix = "SR_"; 143 } 144 145 $bmask = dirname($backup_path_base) . "/" . $prefix . basename($cammask) if $cammask; 146 } 147 if ($recovery_path_base) { 148 $rimage = $ipprc->filename("PPIMAGE.CHIP", $recovery_path_base, $component); 149 $rch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $recovery_path_base, $component); 171 $rmask = $ipprc->filename("PPIMAGE.CHIP.MASK", $recovery_path_base, $component); 172 } 150 173 $rweight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $recovery_path_base, $component); 151 # This is kludgey but correct152 $rmask = dirname($recovery_path_base) . "/" . basename($cammask) if $cammask;;153 174 } 154 175 } elsif ($stage eq "camera") { … … 162 183 $bweight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $backup_path_base); 163 184 $bsources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $backup_path_base); 164 } 185 } 165 186 if ($recovery_path_base) { 166 187 $rimage = $ipprc->filename("PSWARP.OUTPUT", $recovery_path_base); … … 168 189 $rweight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $recovery_path_base); 169 190 $rsources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $recovery_path_base); 170 } 191 } 171 192 } elsif ($stage eq "diff") { 172 193 my $name = "PPSUB.OUTPUT"; … … 228 249 if (!$no_update) { 229 250 print STDERR "deleting $file\n" if $verbose; 230 $ipprc->file_delete($file, $force) or my_die("Failed to delete $file", $magic_ds_id, $PS_EXIT_UNKNOWN_ERROR);231 } else {251 $ipprc->file_delete($file, 1) or my_die("Failed to delete $file", $magic_ds_id, $PS_EXIT_UNKNOWN_ERROR); 252 } else { 232 253 print STDERR "skipping delete $file\n"; 233 254 }
Note:
See TracChangeset
for help on using the changeset viewer.
