Changeset 17787 for trunk/ippScripts/scripts/diff_skycell.pl
- Timestamp:
- May 23, 2008, 3:06:45 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/diff_skycell.pl (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/diff_skycell.pl
r17671 r17787 31 31 'outroot=s' => \$outroot, # Output root name 32 32 'verbose' => \$verbose, # Print to stdout 33 'no-update' => \$no_update, # Don't update the database?33 'no-update' => \$no_update, # Don't update the database? 34 34 'no-op' => \$no_op, # Don't do any operations? 35 35 ) or pod2usage( 2 ); … … 39 39 -msg => "Required options: --diff_id", 40 40 -exitval => 3, 41 ) unless defined $diff_id41 ) unless defined $diff_id 42 42 and defined $outroot; 43 43 44 my $STATS = 45 [ 44 my $STATS = 45 [ 46 46 # PPSTATS KEYWORD STATISTIC DIFFTOOL FLAG 47 47 { name => "ROBUST_MEDIAN", type => "mean", flag => "-bg", dtype => "float" }, 48 48 { name => "ROBUST_STDEV", type => "rms", flag => "-bg_stdev", dtype => "float" }, 49 # { name => "DT_DIFF", type => "sum", flag => "-dtime_diff", dtype => "float" }, 49 { name => "DT_DIFF", type => "sum", flag => "-dtime_diff", dtype => "float" }, 50 { name => "SUBTRACTION.NUM", type => "mean", flag => "-stamps_num", dtype => "int" }, 51 { name => "SUBTRACTION.RMS", type => "mean", flag => "-stamps_rms", dtype => "float" }, 52 { name => "NUM_SOURCES", type => "sum", flag => "-sources", dtype => "int" }, 50 53 { name => "GOOD_PIXEL_FRAC", type => "mean", flag => "-good_frac", dtype => "float" }, 51 54 ]; … … 56 59 my $difftool = can_run('difftool') or (warn "Can't find difftool" and $missing_tools = 1); 57 60 my $ppSub = can_run('ppSub') or (warn "Can't find ppSub" and $missing_tools = 1); 58 if ($missing_tools) { 61 if ($missing_tools) { 59 62 warn("Can't find required tools."); 60 exit($PS_EXIT_CONFIG_ERROR); 63 exit($PS_EXIT_CONFIG_ERROR); 61 64 } 62 65 63 66 # Get list of components for subtraction 64 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files67 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 65 68 my $files; 66 69 { … … 68 71 $command .= " -dbname $dbname" if defined $dbname; 69 72 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 70 run(command => $command, verbose => $verbose);73 run(command => $command, verbose => $verbose); 71 74 unless ($success) { 72 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);73 &my_die("Unable to perform difftool -inputskyfile: $error_code", $diff_id, $error_code);75 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 76 &my_die("Unable to perform difftool -inputskyfile: $error_code", $diff_id, $error_code); 74 77 } 75 78 76 79 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 77 &my_die("Unable to parse metadata config doc", $diff_id, $PS_EXIT_PROG_ERROR);78 $files = parse_md_list($metadata) or 79 &my_die("Unable to parse metadata list", $diff_id, $PS_EXIT_PROG_ERROR);80 &my_die("Unable to parse metadata config doc", $diff_id, $PS_EXIT_PROG_ERROR); 81 $files = parse_md_list($metadata) or 82 &my_die("Unable to parse metadata list", $diff_id, $PS_EXIT_PROG_ERROR); 80 83 } 81 84 … … 86 89 my ($input, $inputMask, $inputWeight, $inputPath, $inputPSF); # Input files and path 87 90 my ($template, $templateMask, $templateWeight, $templatePath, $templateSources); # Template files and path 88 my $tess_id; # Tesselation identifier89 my $skycell_id; # Skycell identifier90 my $camera; # Camera91 my $tess_id; # Tesselation identifier 92 my $skycell_id; # Skycell identifier 93 my $camera; # Camera 91 94 foreach my $file (@$files) { 92 95 if (defined $file->{template} and $file->{template}) { 93 $template = $file->{uri};94 $templatePath = $file->{path_base};95 if ($file->{warp_id} == 0) {96 $templateMask = "PPSTACK.OUTPUT.MASK";97 $templateWeight = "PPSTACK.OUTPUT.WEIGHT";98 $templateSources = "PSPHOT.OUTPUT";99 } else {100 $templateMask = "PSWARP.OUTPUT.MASK";101 $templateWeight = "PSWARP.OUTPUT.WEIGHT";102 $templateSources = "PSWARP.OUTPUT.SOURCES";103 }104 } else { 105 $input = $file->{uri};106 $inputPath = $file->{path_base};107 if ($file->{warp_id} == 0) {108 $inputMask = "PPSTACK.OUTPUT.MASK";109 $inputWeight = "PPSTACK.OUTPUT.WEIGHT";110 $inputPSF = "PSPHOT.PSF.SAVE";111 } else {112 $inputMask = "PSWARP.OUTPUT.MASK";113 $inputWeight = "PSWARP.OUTPUT.WEIGHT";114 $inputPSF = "PSPHOT.PSF.SAVE";115 }96 $template = $file->{uri}; 97 $templatePath = $file->{path_base}; 98 if ($file->{warp_id} == 0) { 99 $templateMask = "PPSTACK.OUTPUT.MASK"; 100 $templateWeight = "PPSTACK.OUTPUT.WEIGHT"; 101 $templateSources = "PSPHOT.OUTPUT"; 102 } else { 103 $templateMask = "PSWARP.OUTPUT.MASK"; 104 $templateWeight = "PSWARP.OUTPUT.WEIGHT"; 105 $templateSources = "PSWARP.OUTPUT.SOURCES"; 106 } 107 } else { 108 $input = $file->{uri}; 109 $inputPath = $file->{path_base}; 110 if ($file->{warp_id} == 0) { 111 $inputMask = "PPSTACK.OUTPUT.MASK"; 112 $inputWeight = "PPSTACK.OUTPUT.WEIGHT"; 113 $inputPSF = "PSPHOT.PSF.SAVE"; 114 } else { 115 $inputMask = "PSWARP.OUTPUT.MASK"; 116 $inputWeight = "PSWARP.OUTPUT.WEIGHT"; 117 $inputPSF = "PSPHOT.PSF.SAVE"; 118 } 116 119 } 117 120 if (defined $tess_id) { 118 &my_die("Tesselation identifiers don't match", $diff_id, $PS_EXIT_SYS_ERROR) unless119 $file->{tess_id} eq $tess_id;120 } else { 121 $tess_id = $file->{tess_id};121 &my_die("Tesselation identifiers don't match", $diff_id, $PS_EXIT_SYS_ERROR) unless 122 $file->{tess_id} eq $tess_id; 123 } else { 124 $tess_id = $file->{tess_id}; 122 125 } 123 126 if (defined $skycell_id) { 124 &my_die("Skycell identifiers don't match", $diff_id, $PS_EXIT_SYS_ERROR) unless125 $file->{skycell_id} eq $skycell_id;126 } else { 127 $skycell_id = $file->{skycell_id};127 &my_die("Skycell identifiers don't match", $diff_id, $PS_EXIT_SYS_ERROR) unless 128 $file->{skycell_id} eq $skycell_id; 129 } else { 130 $skycell_id = $file->{skycell_id}; 128 131 } 129 132 if (defined $camera) { 130 &my_die("Cameras don't match", $diff_id, $PS_EXIT_SYS_ERROR) unless $file->{camera} eq $camera;131 } else { 132 $camera = $file->{camera};133 &my_die("Cameras don't match", $diff_id, $PS_EXIT_SYS_ERROR) unless $file->{camera} eq $camera; 134 } else { 135 $camera = $file->{camera}; 133 136 } 134 137 … … 181 184 182 185 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 183 run(command => $command, verbose => $verbose);186 run(command => $command, verbose => $verbose); 184 187 unless ($success) { 185 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);186 &my_die("Unable to perform ppSub: $error_code", $diff_id, $error_code);188 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 189 &my_die("Unable to perform ppSub: $error_code", $diff_id, $error_code); 187 190 } 188 191 &my_die("Couldn't find expected output file: $outputName", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputName); … … 195 198 196 199 # Get the statistics on the residual image 197 my $statsFile; # File handle200 my $statsFile; # File handle 198 201 open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $diff_id, $PS_EXIT_SYS_ERROR); 199 202 my @contents = <$statsFile>; # Contents of file 200 203 close $statsFile; 201 204 my $metadata = $mdcParser->parse(join "", @contents) or 202 &my_die("Unable to parse metadata config doc", $diff_id, $PS_EXIT_PROG_ERROR);205 &my_die("Unable to parse metadata config doc", $diff_id, $PS_EXIT_PROG_ERROR); 203 206 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $diff_id, $PS_EXIT_PROG_ERROR); 204 207 } … … 208 211 # Add the subtraction result 209 212 { 210 my $command = "$difftool -adddiffskyfile -diff_id $diff_id -uri $outputName -path_base $outroot";211 $command .= $stats->cmdflags();212 $command .= " -dbname $dbname" if defined $dbname;213 214 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =215 run(command => $command, verbose => $verbose);216 unless ($success) {217 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);218 &my_die("Unable to perform difftool -adddiffskyfile: $error_code", $diff_id, $error_code);219 }213 my $command = "$difftool -adddiffskyfile -diff_id $diff_id -uri $outputName -path_base $outroot"; 214 $command .= $stats->cmdflags(); 215 $command .= " -dbname $dbname" if defined $dbname; 216 217 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 218 run(command => $command, verbose => $verbose); 219 unless ($success) { 220 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 221 &my_die("Unable to perform difftool -adddiffskyfile: $error_code", $diff_id, $error_code); 222 } 220 223 } 221 224 222 225 # Register the run as completed 223 226 { 224 my $command = "$difftool -updaterun -diff_id $diff_id -state stop"; # Command to run difftool225 $command .= " -dbname $dbname" if defined $dbname;226 227 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =228 run(command => $command, verbose => $verbose);229 unless ($success) {230 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);231 warn("Unable to perform difftool -updaterun: $error_code\n");232 exit($error_code);233 }227 my $command = "$difftool -updaterun -diff_id $diff_id -state stop"; # Command to run difftool 228 $command .= " -dbname $dbname" if defined $dbname; 229 230 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 231 run(command => $command, verbose => $verbose); 232 unless ($success) { 233 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 234 warn("Unable to perform difftool -updaterun: $error_code\n"); 235 exit($error_code); 236 } 234 237 } 235 238 } … … 238 241 sub my_die 239 242 { 240 my $msg = shift; # Warning message on die241 my $diff_id = shift; # Diff identifier242 my $exit_code = shift; # Exit code to add243 my $msg = shift; # Warning message on die 244 my $diff_id = shift; # Diff identifier 245 my $exit_code = shift; # Exit code to add 243 246 244 247 warn($msg); 245 248 if (defined $diff_id and not $no_update) { 246 my $command = "$difftool -adddiffskyfile -diff_id $diff_id -code $exit_code";247 $command .= " -dbname $dbname" if defined $dbname;249 my $command = "$difftool -adddiffskyfile -diff_id $diff_id -code $exit_code"; 250 $command .= " -dbname $dbname" if defined $dbname; 248 251 run(command => $command, verbose => $verbose); 249 252 }
Note:
See TracChangeset
for help on using the changeset viewer.
