Changeset 19942 for trunk/ippScripts/scripts/detrend_process_exp.pl
- Timestamp:
- Oct 7, 2008, 9:56:11 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_process_exp.pl (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_process_exp.pl
r19658 r19942 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 ); … … 68 67 &my_die("Unrecognised detrend type: $det_type", $det_id, $exp_id, $PS_EXIT_PROG_ERROR) unless defined $recipe; 69 68 70 # values to extract from output metadata and the stats to calculate71 # XXX -bg_mean_stdev should take rms of bg_mean_stdev if bg_mean_stdev != 0 (A)72 # XXX -bg_mean_stdev should take stdev of bg_mean if bg_mean_stdev == 0 (B)73 # XXX (A) if imfile.Ncomp > 1, (B) if imfile.Ncomp == 174 my $STATS =75 [76 # KEYWORD STATISTIC CHIPTOOL FLAG77 { name => "bg", type => "mean", flag => "-bg", dtype => "float" },78 { name => "bg", type => "stdev", flag => "-bg_mean_stdev", dtype => "float" },79 { name => "bg_stdev", type => "rms", flag => "-bg_stdev", dtype => "float" },80 # { name => "bg_mean_stdev", type => "rms", flag => "-bg_mean_stdev" },81 ];82 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser83 84 69 # Look for programs we need 85 70 my $missing_tools; 86 71 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 87 72 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 73 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 88 74 if ($missing_tools) { 89 75 warn("Can't find required tools."); 90 76 exit($PS_EXIT_CONFIG_ERROR); 91 77 } 78 79 my $cmdflags; 92 80 93 81 # Get list of component files … … 112 100 &my_die("Unable to parse metadata list", $det_id, $exp_id, $PS_EXIT_PROG_ERROR); 113 101 114 # parse the stats in the metadata 115 unless ($stats->parse($metadata)) { 116 &my_die("Unable to find all values in statistics output.\n", $det_id, $exp_id, $PS_EXIT_PROG_ERROR); 102 # since I can't figure out how to do input and output within PERL, I'm writing to a temp file 103 my ($statFile, $statName) = tempfile( "/tmp/$exp_tag.detproc.$det_id.stats.XXXX", UNLINK => !$save_temps ); 104 print "saving stats to $statName\n"; 105 foreach my $line (@$stdout_buf) { 106 print $statFile $line; 107 } 108 close $statFile; 109 110 # parse the stats in the metadata file 111 $command = "$ppStatsFromMetadata $statName - DETREND_PROCESS_EXP"; 112 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 113 run(command => $command, verbose => $verbose); 114 unless ($success) { 115 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 116 warn("Unable to perform ppStatsFromMetadata: $error_code\n"); 117 exit($error_code); 118 } 119 120 foreach my $line (@$stdout_buf) { 121 $cmdflags .= " $line"; 117 122 } 118 123 } … … 173 178 $command .= " -recip $recipe -path_base $outroot"; 174 179 $command .= " -dbname $dbname" if defined $dbname; 175 $command .= $stats->cmdflags();180 $command .= " $cmdflags"; 176 181 177 182 # Add the processed file to the database
Note:
See TracChangeset
for help on using the changeset viewer.
