Changeset 19942 for trunk/ippScripts/scripts/chip_imfile.pl
- Timestamp:
- Oct 7, 2008, 9:56:11 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/chip_imfile.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/chip_imfile.pl
r19938 r19942 19 19 use IPC::Cmd 0.36 qw( can_run run ); 20 20 use PS::IPP::Metadata::Config; 21 use PS::IPP::Metadata::Stats;22 21 use PS::IPP::Config 1.01 qw( :standard ); 23 22 … … 74 73 } 75 74 76 # values to extract from output metadata and the stats to calculate77 # XXX commented-out entries are not yet defined in the output files78 my $STATS =79 [80 # PPSTATS KEYWORD STATISTIC CHIPTOOL FLAG81 { name => "ROBUST_MEDIAN", type => "mean", flag => "-bg", dtype => "float" },82 { name => "ROBUST_MEDIAN", type => "stdev", flag => "-bg_mean_stdev", dtype => "float" },83 { name => "ROBUST_STDEV", type => "rms", flag => "-bg_stdev", dtype => "float" },84 { name => "OVER_VAL", type => "mean", flag => "-bias", dtype => "float" },85 { name => "OVER_VAL", type => "stdev", flag => "-bias_stdev", dtype => "float" },86 { name => "FRINGE_0", type => "rms", flag => "-fringe_0", dtype => "float" },87 { name => "FRINGE_RESID_0", type => "rms", flag => "-fringe_1", dtype => "float" },88 { name => "FRINGE_ERR_0", type => "rms", flag => "-fringe_2", dtype => "float" },89 { name => "APMIFIT", type => "mean", flag => "-ap_resid", dtype => "float" },90 { name => "DAPMIFIT", type => "rms", flag => "-ap_resid_stdev", dtype => "float" },91 { name => "FWHM_X", type => "mean", flag => "-fwhm_major", dtype => "float" },92 { name => "FWHM_Y", type => "mean", flag => "-fwhm_minor", dtype => "float" },93 { name => "DT_DET", type => "sum", flag => "-dtime_detrend", dtype => "float" },94 { name => "DT_PHOT", type => "sum", flag => "-dtime_photom", dtype => "float" },95 { name => "DT_TOTAL", type => "sum", flag => "-dtime_total", dtype => "float" },96 { name => "NSTARS", type => "sum", flag => "-n_stars", dtype => "int" },97 # { name => "?", type => "sum", flag => "-n_extended", dtype => "int" },98 # { name => "?", type => "sum", flag => "-n_cr", dtype => "int" },99 ];100 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser101 102 75 # Look for programs we need 103 76 my $missing_tools; … … 105 78 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 106 79 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 80 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 107 81 if ($missing_tools) { 108 82 warn("Can't find required tools."); … … 137 111 } 138 112 113 my $cmdflags; 114 139 115 # Run ppImage 140 116 unless ($no_op) { 141 ## XXX can we convert ppImage log and trace to use the filerules to generate consistent names142 ## XXX also stats: output should be implied by $outroot143 117 my $command; 144 118 my $do_stats; … … 205 179 &my_die("Couldn't find expected output file: $outputStats\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStats); 206 180 207 # Get the statistics on the processed image 208 my $statsFile; # File handle 209 open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR); 210 my @contents = <$statsFile>; # Contents of file 211 close $statsFile; 212 213 # parse the statistics MDC file 214 my $mdcParser = PS::IPP::Metadata::Config->new(); # Parser for metadata config files 215 my $metadata = $mdcParser->parse(join "", @contents); 216 unless ($metadata) { 217 &my_die("Unable to parse metadata config doc", $exp_id, $chip_id, $class_id, $PS_EXIT_PROG_ERROR); 218 } 219 220 # extract the stats from the metadata 221 unless ($stats->parse($metadata)) { 222 &my_die("Failure extracting metadata from the statistics output file.\n", $exp_id, $chip_id, $class_id, $PS_EXIT_PROG_ERROR); 223 } 181 my $outputStatsReal = $ipprc->file_resolve($outputStats); 182 &my_die("Couldn't find expected output file: $outputStats", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStatsReal; 183 184 # measure chip stats 185 $command = "$ppStatsFromMetadata $outputStatsReal - CHIP_IMFILE"; 186 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 187 run(command => $command, verbose => $verbose); 188 unless ($success) { 189 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 190 &my_die("Unable to perform ppStatsFromMetadata: $error_code", $exp_id, $chip_id, $class_id, $error_code); 191 } 192 foreach my $line (@$stdout_buf) { 193 $cmdflags .= " $line"; 194 } 195 chomp $cmdflags; 224 196 } 225 197 } … … 236 208 $command .= " -hostname $host" if defined $host; 237 209 $command .= " -dbname $dbname" if defined $dbname; 238 $command .= $stats->cmdflags();210 $command .= " $cmdflags"; 239 211 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 240 212 } else {
Note:
See TracChangeset
for help on using the changeset viewer.
