- 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_cleanup.pl (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20100225
- Property svn:mergeinfo changed
-
branches/eam_branches/20100225/ippScripts/scripts/magic_destreak_cleanup.pl
r26555 r27517 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."); … … 86 87 my $dbh = DBI->connect($dsn, $dbuser, $dbpassword) or die "Cannot connect to mysql server\n"; 87 88 88 my $q1 = "SELECT magicDSRun.*, camera, camProcessedExp.path_base AS cam_path_base, magicRun.inverse"89 . " 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)" 90 91 . " WHERE magic_ds_id = $magic_ds_id"; 91 92 my $q2 = "SELECT * from magicDSFile where magic_ds_id = $magic_ds_id"; 92 93 # my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files94 93 95 94 my $stmt1 = $dbh->prepare($q1); … … 103 102 my $stage_id = $run->{stage_id}; 104 103 my $cam_path_base = $run->{cam_path_base}; 104 my $cam_reduction = $run->{cam_reduction}; 105 $cam_reduction = 'DEFAULT' if !$cam_reduction or ($cam_reduction eq 'NULL'); 105 106 my $inverse = $run->{inverse}; 106 107 … … 108 109 &my_die("unexpected run state found: $state", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) if $state ne "goto_cleaned"; 109 110 &my_die("clean not allowed for raw stage, use goto_restore", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) if $stage eq "raw"; 111 112 my $recipe_psastro = $ipprc->reduction($cam_reduction, 'PSASTRO'); # Recipe to use 113 &my_die("Unrecognised PSASTRO recipe", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_psastro; 110 114 111 115 … … 124 128 125 129 if ($stage eq "chip") { 126 # we use the mask output from the camera stage for input and replace 127 # the output of the chip stage with that mask as well. 128 my $cammask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $component); 130 # Check to see if we're using dynamic masks 131 my $dynamicMasks; # Use dynamic masks? 132 { 133 # Get the PSASTRO recipe 134 my $command = "$ppConfigDump -camera $camera -recipe PSASTRO $recipe_psastro -dump-recipe PSASTRO -"; 135 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 136 run(command => $command, verbose => $verbose); 137 unless ($success) { 138 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 139 &my_die("Unable to perform ppConfigDump: $error_code", $magic_ds_id, $component, 140 $PS_EXIT_CONFIG_ERROR); 141 } 142 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 143 my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or 144 &my_die("Unable to parse metadata config doc", $magic_ds_id, $component, 145 $PS_EXIT_CONFIG_ERROR); 146 147 $dynamicMasks = metadataLookupBool($recipeData, 'REFSTAR_MASK'); 148 } 129 149 130 150 if ($backup_path_base) { 131 151 $bimage = $ipprc->filename("PPIMAGE.CHIP", $backup_path_base, $component); 132 $bch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $backup_path_base, $component); 152 153 if ($dynamicMasks) { 154 my $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $component); 155 # This is kludgey but correct 156 $bmask = dirname($backup_path_base) . "/SR_" . basename($mask); 157 $bch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $backup_path_base, $component); 158 } else { 159 $bmask = $ipprc->filename("PPIMAGE.CHIP.MASK", $backup_path_base, $component); 160 } 133 161 $bweight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $backup_path_base, $component); 134 # This is kludgey but correct 135 136 my $prefix; 137 if ($backup_path_base =~ /\.SR/) { 138 $prefix = ""; 162 } 163 if ($recovery_path_base) { 164 $rimage = $ipprc->filename("PPIMAGE.CHIP", $recovery_path_base, $component); 165 166 if ($dynamicMasks) { 167 my $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $component); 168 # This is kludgey but correct 169 $rmask = dirname($recovery_path_base) . "/" . basename($mask); 170 $rch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $recovery_path_base, $component); 139 171 } else { 140 $prefix = "SR_"; 141 } 142 143 $bmask = dirname($backup_path_base) . "/" . $prefix . basename($cammask); 144 } 145 if ($recovery_path_base) { 146 $rimage = $ipprc->filename("PPIMAGE.CHIP", $recovery_path_base, $component); 147 $rch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $recovery_path_base, $component); 172 $rmask = $ipprc->filename("PPIMAGE.CHIP.MASK", $recovery_path_base, $component); 173 } 148 174 $rweight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $recovery_path_base, $component); 149 # This is kludgey but correct150 $rmask = dirname($recovery_path_base) . "/" . basename($cammask);151 175 } 152 176 } elsif ($stage eq "camera") { … … 160 184 $bweight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $backup_path_base); 161 185 $bsources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $backup_path_base); 162 } 186 } 163 187 if ($recovery_path_base) { 164 188 $rimage = $ipprc->filename("PSWARP.OUTPUT", $recovery_path_base); … … 166 190 $rweight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $recovery_path_base); 167 191 $rsources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $recovery_path_base); 168 } 192 } 169 193 } elsif ($stage eq "diff") { 170 194 my $name = "PPSUB.OUTPUT"; … … 226 250 if (!$no_update) { 227 251 print STDERR "deleting $file\n" if $verbose; 228 $ipprc->file_delete($file ) or my_die("Failed to delete $file", $magic_ds_id, $PS_EXIT_UNKNOWN_ERROR);252 $ipprc->file_delete($file, 1) or my_die("Failed to delete $file", $magic_ds_id, $PS_EXIT_UNKNOWN_ERROR); 229 253 } else { 230 254 print STDERR "skipping delete $file\n";
Note:
See TracChangeset
for help on using the changeset viewer.
