Changeset 22430 for trunk/ippScripts/scripts/diff_skycell.pl
- Timestamp:
- Feb 24, 2009, 12:00:25 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/diff_skycell.pl (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/diff_skycell.pl
r21395 r22430 27 27 use Pod::Usage qw( pod2usage ); 28 28 29 # Look for programs we need 30 my $missing_tools; 31 my $difftool = can_run('difftool') or (warn "Can't find difftool" and $missing_tools = 1); 32 my $ppSub = can_run('ppSub') or (warn "Can't find ppSub" and $missing_tools = 1); 33 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 34 if ($missing_tools) { 35 warn("Can't find required tools."); 36 exit($PS_EXIT_CONFIG_ERROR); 37 } 38 29 39 my ($diff_id, $dbname, $threads, $outroot, $reduction, $verbose, $no_update, $no_op, $redirect); 30 40 my ($skycell_id, $diff_skyfile_id); 31 41 GetOptions( 32 42 'diff_id=s' => \$diff_id, # Diff identifier 33 'skycell_id=s' => \$skycell_id, # Diffidentifier43 'skycell_id=s' => \$skycell_id, # Skycell identifier 34 44 'diff_skyfile_id=s' => \$diff_skyfile_id, # Diff identifier 35 45 'dbname|d=s' => \$dbname, # Database name … … 52 62 and defined $outroot; 53 63 64 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 65 $SIG{__DIE__} = sub { die @_ if $^S; 66 my_die( $_[0], $diff_id, $skycell_id, $PS_EXIT_UNKNOWN_ERROR ); }; 67 54 68 # XXX camera is not known here; cannot use filerules... 55 69 # my $logDest = $ipprc->filename("LOG.EXP", $outroot); 56 57 70 my $logDest = "$outroot.log"; 58 71 $ipprc->redirect_output($logDest) if $redirect; 59 72 60 73 my $source_id = $ipprc->source_id($dbname, $PS_TABLE_ID_DIFF); 61 62 # Look for programs we need63 my $missing_tools;64 my $difftool = can_run('difftool') or (warn "Can't find difftool" and $missing_tools = 1);65 my $ppSub = can_run('ppSub') or (warn "Can't find ppSub" and $missing_tools = 1);66 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);67 if ($missing_tools) {68 warn("Can't find required tools.");69 exit($PS_EXIT_CONFIG_ERROR);70 }71 74 72 75 # Get list of components for subtraction … … 80 83 unless ($success) { 81 84 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 82 &my_die("Unable to perform difftool -inputskyfile: $error_code", $diff_id, $ error_code);85 &my_die("Unable to perform difftool -inputskyfile: $error_code", $diff_id, $skycell_id, $error_code); 83 86 } 84 87 85 88 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 86 &my_die("Unable to parse metadata config doc", $diff_id, $ PS_EXIT_PROG_ERROR);89 &my_die("Unable to parse metadata config doc", $diff_id, $skycell_id, $PS_EXIT_PROG_ERROR); 87 90 $files = parse_md_list($metadata) or 88 &my_die("Unable to parse metadata list", $diff_id, $PS_EXIT_PROG_ERROR); 89 } 90 91 &my_die("Subtraction list does not contain exactly two elements", $diff_id, $PS_EXIT_SYS_ERROR) unless 92 scalar @$files == 2; 91 &my_die("Unable to parse metadata list", $diff_id, $skycell_id, $PS_EXIT_PROG_ERROR); 92 } 93 94 &my_die("Subtraction list does not contain exactly two elements", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless scalar @$files == 2; 93 95 94 96 # Identify the input and the template … … 123 125 } 124 126 if (defined $tess_id) { 125 &my_die("Tesselation identifiers don't match", $diff_id, $ PS_EXIT_SYS_ERROR) unless127 &my_die("Tesselation identifiers don't match", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless 126 128 $file->{tess_id} eq $tess_id; 127 129 } else { … … 129 131 } 130 132 if (defined $skycell_id) { 131 &my_die("Skycell identifiers don't match", $diff_id, $ PS_EXIT_SYS_ERROR) unless133 &my_die("Skycell identifiers don't match", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless 132 134 $file->{skycell_id} eq $skycell_id; 133 135 } else { … … 135 137 } 136 138 if (defined $camera) { 137 &my_die("Cameras don't match", $diff_id, $ PS_EXIT_SYS_ERROR) unless $file->{camera} eq $camera;139 &my_die("Cameras don't match", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $file->{camera} eq $camera; 138 140 } else { 139 141 $camera = $file->{camera}; … … 142 144 } 143 145 144 &my_die("Unable to identify template", $diff_id, $ PS_EXIT_SYS_ERROR) unless defined $template;145 &my_die("Unable to identify input", $diff_id, $ PS_EXIT_SYS_ERROR) unless defined $input;146 &my_die("Unable to identify camera", $diff_id, $ PS_EXIT_SYS_ERROR) unless defined $camera;146 &my_die("Unable to identify template", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless defined $template; 147 &my_die("Unable to identify input", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless defined $input; 148 &my_die("Unable to identify camera", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless defined $camera; 147 149 $ipprc->define_camera($camera); 148 150 … … 152 154 my $recipe_psphot = $ipprc->reduction($reduction, 'DIFF_PSPHOT'); # Recipe to use for psphot 153 155 unless ($recipe_ppSub and $recipe_psphot) { 154 &my_die("Couldn't find selected reduction for DIFF_PPSUB and DIFF_PSPHOT: $reduction\n", $diff_id, $ PS_EXIT_CONFIG_ERROR);156 &my_die("Couldn't find selected reduction for DIFF_PPSUB and DIFF_PSPHOT: $reduction\n", $diff_id, $skycell_id, $PS_EXIT_CONFIG_ERROR); 155 157 } 156 158 … … 177 179 print "templateSources: $templateSources\n"; 178 180 179 &my_die("Couldn't find input: $template", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($template);180 &my_die("Couldn't find input: $templateMask", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateMask);181 &my_die("Couldn't find input: $templateVariance", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateVariance);182 &my_die("Couldn't find input: $input", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input);183 &my_die("Couldn't find input: $inputMask", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputMask);184 &my_die("Couldn't find input: $inputVariance", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputVariance);185 &my_die("Couldn't find input: $templateSources", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateSources);181 &my_die("Couldn't find input: $template", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($template); 182 &my_die("Couldn't find input: $templateMask", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateMask); 183 &my_die("Couldn't find input: $templateVariance", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateVariance); 184 &my_die("Couldn't find input: $input", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input); 185 &my_die("Couldn't find input: $inputMask", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputMask); 186 &my_die("Couldn't find input: $inputVariance", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputVariance); 187 &my_die("Couldn't find input: $templateSources", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateSources); 186 188 187 189 # Get the output filenames … … 223 225 unless ($success) { 224 226 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 225 &my_die("Unable to perform ppSub: $error_code", $diff_id, $ error_code);226 } 227 &my_die("Couldn't find expected output file: $outputName", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputName);228 &my_die("Couldn't find expected output file: $outputMask", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);229 &my_die("Couldn't find expected output file: $outputVariance", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputVariance);230 # &my_die("Couldn't find expected output file: $outputSources", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources);231 # &my_die("Couldn't find expected output file: $bin1Name", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin1Name);232 # &my_die("Couldn't find expected output file: $bin2Name", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin2Name);227 &my_die("Unable to perform ppSub: $error_code", $diff_id, $skycell_id, $error_code); 228 } 229 &my_die("Couldn't find expected output file: $outputName", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputName); 230 &my_die("Couldn't find expected output file: $outputMask", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask); 231 &my_die("Couldn't find expected output file: $outputVariance", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputVariance); 232 # &my_die("Couldn't find expected output file: $outputSources", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources); 233 # &my_die("Couldn't find expected output file: $bin1Name", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin1Name); 234 # &my_die("Couldn't find expected output file: $bin2Name", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin2Name); 233 235 234 236 my $outputStatsReal = $ipprc->file_resolve($outputStats); 235 &my_die("Couldn't find expected output file: $outputStats", $diff_id, $ PS_EXIT_SYS_ERROR) unless -f $outputStatsReal;237 &my_die("Couldn't find expected output file: $outputStats", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless -f $outputStatsReal; 236 238 237 239 # measure chip stats … … 241 243 unless ($success) { 242 244 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 243 &my_die("Unable to perform ppStatsFromMetadata: $error_code", $diff_id, $ error_code);245 &my_die("Unable to perform ppStatsFromMetadata: $error_code", $diff_id, $skycell_id, $error_code); 244 246 } 245 247 foreach my $line (@$stdout_buf) { … … 263 265 unless ($success) { 264 266 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 265 &my_die("Unable to perform difftool -adddiffskyfile: $error_code", $diff_id, $ error_code);267 &my_die("Unable to perform difftool -adddiffskyfile: $error_code", $diff_id, $skycell_id, $error_code); 266 268 } 267 269 } … … 273 275 my $msg = shift; # Warning message on die 274 276 my $diff_id = shift; # Diff identifier 277 my $skycell_id = shift; # Skycell identifier 275 278 my $exit_code = shift; # Exit code to add 276 279 277 280 warn($msg); 278 if (defined $diff_id and not $no_update) {281 if (defined $diff_id and defined $skycell_id and not $no_update) { 279 282 my $command = "$difftool -adddiffskyfile -diff_id $diff_id -skycell_id $skycell_id -code $exit_code"; 280 283 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400));
Note:
See TracChangeset
for help on using the changeset viewer.
