Changeset 14009 for trunk/ippScripts/scripts/detrend_process_imfile.pl
- Timestamp:
- Jul 4, 2007, 1:53:22 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_process_imfile.pl
r13989 r14009 48 48 49 49 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 50 pod2usage( 51 -msg => "Required options: --det_id --exp_tag --class_id --det_type --input_uri --camera", 52 -exitval => 3, 53 ) unless defined $det_id 50 pod2usage( -msg => "Required options: --det_id --exp_tag --class_id --det_type --input_uri --camera", 51 -exitval => 3) 52 unless defined $det_id 54 53 and defined $exp_tag 55 54 and defined $class_id … … 61 60 $ipprc->define_camera($camera); 62 61 62 # Recipes to use as a function of detrend type 63 63 $reduction = "DETREND" unless defined $reduction; 64 64 my $recipe = $ipprc->reduction($reduction, uc($det_type) . '_PROCESS'); # Recipe name to use 65 66 # values to extract from output metadata and the stats to calculate 67 my $STATS = 68 [ 69 # PPSTATS KEYWORD STATISTIC CHIPTOOL FLAG 70 { name => "ROBUST_MEDIAN", type => "mean", flag => "-bg" }, 71 { name => "ROBUST_MEDIAN", type => "stdev", flag => "-bg_mean_stdev" }, 72 { name => "ROBUST_STDEV", type => "rms", flag => "-bg_stdev" }, 73 ]; 65 74 66 75 # Look for programs we need … … 74 83 $ppImage .= " -dbname $dbname" if defined $dbname; 75 84 85 &my_die("Couldn't find input file: $input_uri\n", $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input_uri); 86 76 87 $workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir; 77 88 78 my $outputRoot = $ipprc->file_prepare( "$exp_tag/$exp_tag.detproc.$det_id", $workdir, $input_uri ); 89 my $outputRoot = $ipprc->file_prepare( "$exp_tag/$exp_tag.detproc.$det_id", $workdir, $input_uri ); 90 79 91 my $outputImage = $ipprc->filename("PPIMAGE.OUTPUT", $outputRoot, $class_id); 80 my $outputBin1 = $ipprc->filename("PPIMAGE.BIN1",$outputRoot, $class_id);81 my $outputBin2 = $ipprc->filename("PPIMAGE.BIN2",$outputRoot, $class_id);82 my $outputStats = $ outputRoot . '.' . $class_id . '.stats';92 my $outputBin1 = $ipprc->filename("PPIMAGE.BIN1", $outputRoot, $class_id); 93 my $outputBin2 = $ipprc->filename("PPIMAGE.BIN2", $outputRoot, $class_id); 94 my $outputStats = $ipprc->filename("PPIMAGE.STATS", $outputRoot, $class_id); 83 95 84 96 # Run ppImage 85 my $stats = PS::IPP::Metadata::Stats->new(); # Stats parser86 97 unless ($no_op) { 87 98 my $command = "$ppImage -file $input_uri $outputRoot"; … … 96 107 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $class_id, $error_code); 97 108 } 109 98 110 &my_die("Couldn't find expected output file: $outputImage", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputImage); 99 111 &my_die("Couldn't find expected output file: $outputStats", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats); … … 106 118 my @contents = <$statsFile>; # Contents of file 107 119 close $statsFile; 120 121 # parse the statistics MDC file 108 122 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 109 123 my $metadata = $mdcParser->parse(join "", @contents) 110 124 or &my_die("Unable to parse metadata config", $det_id, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 125 126 # extract the stats from the metadata 127 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser 111 128 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 112 129 } 113 130 114 my $bg = $stats->bg_mean(); 115 my $bg_stdev = $stats->bg_stdev(); 116 my $bg_mean_stdev = $stats->bg_mean_stdev(); 131 # command to update database 132 my $command = "$dettool -addprocessedimfile"; 133 $command .= " -det_id $det_id"; 134 $command .= " -exp_tag $exp_tag"; 135 $command .= " -class_id $class_id"; 136 $command .= " -recip $reduction"; 137 $command .= " -uri $outputImage -path_base $outputRoot"; 138 $command .= " -dbname $dbname" if defined $dbname; 139 140 # add in the elements from the selected stats above 141 foreach my $entry (@$STATS) { 142 my $value = $entry->{value}; 143 my $flag = $entry->{flag}; 144 $command .= " $flag $value"; 145 } 117 146 118 147 # Add the processed file to the database 119 148 unless ($no_update) { 120 my $command = "$dettool -addprocessedimfile";121 $command .= " -det_id $det_id";122 $command .= " -exp_tag $exp_tag";123 $command .= " -class_id $class_id";124 $command .= " -recip $recipe";125 $command .= " -uri $outputImage -path_base $outputRoot";126 $command .= " -bg $bg -bg_stdev $bg_stdev -bg_mean_stdev $bg_mean_stdev";127 $command .= " -dbname $dbname" if defined $dbname;128 129 149 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 130 150 run(command => $command, verbose => 1); … … 134 154 exit($error_code); 135 155 } 156 } else { 157 print "skipping command: $command\n"; 136 158 } 137 159 … … 146 168 carp($msg); 147 169 if ($det_id and $exp_tag and $class_id and not $no_update) { 148 my $command = "$dettool -addprocessedimfile -det_id $det_id -exp_tag $exp_tag -class_id $class_id -code $exit_code"; 170 my $command = "$dettool -addprocessedimfile"; 171 $command .= " -det_id $det_id"; 172 $command .= " -exp_tag $exp_tag"; 173 $command .= " -class_id $class_id"; 174 $command .= " -code $exit_code"; 149 175 $command .= " -dbname $dbname" if defined $dbname; 150 176 ### system ($command);
Note:
See TracChangeset
for help on using the changeset viewer.
