Changeset 20101 for trunk/ippScripts/scripts/warp_skycell.pl
- Timestamp:
- Oct 13, 2008, 11:36:56 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/warp_skycell.pl (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/warp_skycell.pl
r19938 r20101 22 22 use Pod::Usage qw( pod2usage ); 23 23 use PS::IPP::Metadata::Config; 24 use PS::IPP::Metadata::Stats;25 24 use PS::IPP::Metadata::List qw( parse_md_list ); 26 25 use PS::IPP::Config 1.01 qw( :standard ); … … 63 62 $ipprc->redirect_output($logDest) if $redirect; 64 63 65 my $STATS =66 [67 # PPSTATS KEYWORD STATISTIC WARPTOOL FLAG68 { name => "ROBUST_MEDIAN", type => "mean", flag => "-bg", dtype => "float" },69 { name => "ROBUST_STDEV", type => "rms", flag => "-bg_stdev", dtype => "float" },70 { name => "DT_WARP", type => "sum", flag => "-dtime_warp", dtype => "float" },71 { name => "GOOD_PIXEL_FRAC", type => "mean", flag => "-good_frac", dtype => "float" },72 { name => "RANGE.XMIN", type => "mean", flag => "-xmin", dtype => "int" },73 { name => "RANGE.XMAX", type => "mean", flag => "-xmax", dtype => "int" },74 { name => "RANGE.YMIN", type => "mean", flag => "-ymin", dtype => "int" },75 { name => "RANGE.YMAX", type => "mean", flag => "-ymax", dtype => "int" },76 ];77 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser78 79 64 # Look for programs we need 80 65 my $missing_tools; … … 82 67 my $pswarp = can_run('pswarp') or (warn "Can't find pswarp" and $missing_tools = 1); 83 68 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 69 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 84 70 if ($missing_tools) { 85 71 warn("Can't find required tools."); … … 180 166 181 167 # Run pswarp 168 my $cmdflags; 182 169 my $accept = 1; # Accept the skycell? 183 170 my $do_stats; … … 216 203 if ($do_stats) { 217 204 # Check first for the stats file, and if the ACCEPT flag is set. 218 &my_die("Couldn't find expected output file: $outputStats", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStats); 219 # Get the statistics on the warped image 220 my $statsFile; # File handle 221 open $statsFile, $ipprc->file_resolve($outputStats) or die "Can't open statistics file $outputStats: $!\n"; 222 my @contents = <$statsFile>; # Contents of file 223 close $statsFile; 224 my $contents = join "", @contents; 225 226 my $metadata = $mdcParser->parse($contents) 227 or &my_die("Unable to parse metadata config", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_PROG_ERROR); 228 $accept = metadataLookupBool($metadata, "ACCEPT"); 229 230 # $accept is set above based on the fraction of lit pixels 231 # XXX for some files, there may not be enough stars to find a good psf. these should be dropped as well 205 my $outputStatsReal = $ipprc->file_resolve($outputStats); 206 &my_die("Couldn't find expected output file: $outputStats", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless -f $outputStatsReal; 207 208 # measure chip stats 209 $command = "$ppStatsFromMetadata $outputStatsReal - WARP_SKYFILE"; 210 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 211 run(command => $command, verbose => $verbose); 212 unless ($success) { 213 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 214 &my_die("Unable to perform ppStatsFromMetadata: $error_code", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR); 215 } 216 foreach my $line (@$stdout_buf) { 217 $cmdflags .= " $line"; 218 } 219 chomp $cmdflags; 220 221 # the stats includes ACCEPT as a boolean: convert the T/F value to 0/1 222 my $acceptFlag = &value_for_flag ($cmdflags, "-accept"); 223 $accept = ($acceptFlag = "T") ? 1 : 0; 232 224 if ($accept && !$ipprc->file_exists($outputPSF)) { 233 225 $accept = 0; … … 235 227 236 228 if ($accept) { 237 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_PROG_ERROR);238 239 229 &my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputImage); 240 230 &my_die("Couldn't find expected output file: $outputMask", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask); 241 231 &my_die("Couldn't find expected output file: $outputWeight", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight); 242 232 &my_die("Couldn't find expected output file: $outputSources", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources); 243 # &my_die("Couldn't find expected output file: $outputPSF", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputPSF);244 # &my_die("Couldn't find expected output file: $outputBin1", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputBin1);245 # &my_die("Couldn't find expected output file: $outputBin2", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputBin2);246 233 } 247 234 … … 256 243 $command .= " -uri $outputImage" if $accept; 257 244 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 258 $command .= $stats->cmdflags()if $accept;245 $command .= " $cmdflags" if $accept; 259 246 $command .= " -hostname $host" if defined $host; 260 247 $command .= " -dbname $dbname" if defined $dbname; … … 285 272 } 286 273 } 274 } 275 276 sub value_for_flag 277 { 278 my $cmdflags = shift; 279 my $flag = shift; 280 281 my $value = 0.0; 282 if ($cmdflags =~ m|$flag|) { 283 ($value) = $cmdflags =~ m|$flag\s+(\S+)|; 284 } 285 $value; 287 286 } 288 287
Note:
See TracChangeset
for help on using the changeset viewer.
