Changeset 19782 for trunk/ippScripts/scripts/detrend_norm_exp.pl
- Timestamp:
- Sep 28, 2008, 11:40:31 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_norm_exp.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_norm_exp.pl
r19660 r19782 16 16 use IPC::Cmd 0.36 qw( can_run run ); 17 17 use PS::IPP::Metadata::Config; 18 use PS::IPP::Metadata::Stats;19 18 use PS::IPP::Config 1.01 qw( :standard ); 20 19 use PS::IPP::Metadata::List qw( parse_md_list ); … … 62 61 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless defined $recipe; 63 62 64 # values to extract from output metadata and the stats to calculate65 # XXX -bg_mean_stdev should take rms of bg_mean_stdev if bg_mean_stdev != 0 (A)66 # XXX -bg_mean_stdev should take stdev of bg_mean if bg_mean_stdev == 0 (B)67 # XXX (A) if imfile.Ncomp > 1, (B) if imfile.Ncomp == 168 my $STATS =69 [70 # KEYWORD STATISTIC CHIPTOOL FLAG71 { name => "bg", type => "mean", flag => "-bg", dtype => "float" },72 { name => "bg", type => "stdev", flag => "-bg_mean_stdev", dtype => "float" },73 { name => "bg_stdev", type => "rms", flag => "-bg_stdev", dtype => "float" },74 # { name => "bg_mean_stdev", type => "rms", flag => "-bg_mean_stdev" },75 ];76 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser77 78 63 # Look for programs we need 79 64 my $missing_tools; 80 65 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 81 66 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 67 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 82 68 if ($missing_tools) { 83 69 warn("Can't find required tools."); … … 86 72 87 73 # Get list of component files 74 my $cmdflags; 88 75 my ($files, $command, $success, $error_code, $full_buf, $stdout_buf, $stderr_buf); 89 76 { … … 98 85 &my_die("Unable to get list of normalized imfiles from dettool: $error_code", $det_id, $iter, $error_code); 99 86 } 87 # XXX report an error message if stdout_buf is empty 100 88 101 89 # convert stdout to a metadata … … 108 96 &my_die("Unable to parse metadata list", $det_id, $iter, $PS_EXIT_PROG_ERROR); 109 97 110 # parse the stats in the metadata 111 unless ($stats->parse($metadata)) { 112 &my_die("Unable to find all values in statistics output.\n", $det_id, $iter, $PS_EXIT_PROG_ERROR); 113 } 98 # since I can't figure out how to do input and output within PERL, I'm writing to a temp file 99 my ($statFile, $statName) = tempfile( "/tmp/$camera.$det_type.norm.$det_id.$iter.stats.XXXX", UNLINK => !$save_temps ); 100 foreach my $line (@$stdout_buf) { 101 print $statFile $line; 102 } 103 close $statFile; 104 105 $command = "$ppStatsFromMetadata $statName - DETREND_NORM_EXP"; 106 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 107 run(command => $command, verbose => $verbose); 108 unless ($success) { 109 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 110 warn("Unable to perform ppStatsFromMetadata: $error_code\n"); 111 exit($error_code); 112 } 113 114 foreach my $line (@$stdout_buf) { 115 $cmdflags .= " $line"; 116 } 117 print "cmdflags: $cmdflags\n"; 114 118 } 115 119 … … 162 166 $command .= " -path_base $outroot "; 163 167 $command .= " -dbname $dbname" if defined $dbname; 164 $command .= $stats->cmdflags();168 $command .= " $cmdflags"; 165 169 166 170 # Add the processed file to the database
Note:
See TracChangeset
for help on using the changeset viewer.
