Changeset 13275 for trunk/ippScripts/scripts/detrend_norm_exp.pl
- Timestamp:
- May 4, 2007, 4:52:03 PM (19 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
r12800 r13275 17 17 use PS::IPP::Metadata::List qw( parse_md_list ); 18 18 use Statistics::Descriptive; 19 use File::Temp qw( tempfile ); 19 20 20 use PS::IPP::Config qw( 21 $PS_EXIT_SUCCESS 22 $PS_EXIT_UNKNOWN_ERROR23 $PS_EXIT_SYS_ERROR24 $PS_EXIT_CONFIG_ERROR25 $PS_EXIT_PROG_ERROR26 $PS_EXIT_DATA_ERROR27 $PS_EXIT_TIMEOUT_ERROR 28 );21 use PS::IPP::Config qw($PS_EXIT_SUCCESS 22 $PS_EXIT_UNKNOWN_ERROR 23 $PS_EXIT_SYS_ERROR 24 $PS_EXIT_CONFIG_ERROR 25 $PS_EXIT_PROG_ERROR 26 $PS_EXIT_DATA_ERROR 27 $PS_EXIT_TIMEOUT_ERROR 28 caturi 29 ); 29 30 my $ipprc = PS::IPP::Config->new(); # IPP configuration 30 use File::Spec;31 31 32 32 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 115 115 } 116 116 117 # Set output directory 118 if (defined $workdir) { 119 $workdir = $ipprc->convert_filename_absolute( $workdir ); 120 my $subdir = "$camera.$det_type.$det_id"; 121 $workdir = File::Spec->catdir( $workdir, $subdir ); 122 } else { 123 my $example = $ipprc->convert_filename_absolute( ${$files}[0]->{path_base} ); # Example file, for path 124 my ($vol, $dir, $file) = File::Spec->splitpath( $example ); 125 $workdir = $dir; 126 } 127 system "mkdir -p $workdir" unless -d $workdir; 128 129 # Generate the file list, and get the statistics 130 my $outputFile = "$camera.$det_type.norm.$det_id.$iter"; # Root output name 131 my $outputRoot = File::Spec->catfile( $workdir, $outputFile ); 132 133 my $list1Name = $outputRoot . '.b1.list'; # Name for the input file list for binning 1 134 my $list2Name = $outputRoot . '.b2.list'; # Name for the input file list for binning 2 117 my ($list1File, $list1Name) = tempfile( "$camera.$det_type.norm.$det_id.$iter.b1.list.XXXX", UNLINK => 1 ); 118 my ($list2File, $list2Name) = tempfile( "$camera.$det_type.norm.$det_id.$iter.b2.list.XXXX", UNLINK => 1 ); 135 119 my @means; # Array of means 136 120 my @stdevs; # Array of stdevs 137 open my $list1File, '>' . $list1Name;138 open my $list2File, '>' . $list2Name;139 121 foreach my $file (@$files) { 140 my $origRoot = $ipprc->convert_filename_absolute( $file->{path_base} ); # Original root name 141 print $list1File ( $ipprc->filename( "PPIMAGE.BIN1", $origRoot, $file->{class_id} ) . "\n"); 142 print $list2File ( $ipprc->filename( "PPIMAGE.BIN2", $origRoot, $file->{class_id} ) . "\n"); 122 print $list1File ( $ipprc->filename( "PPIMAGE.BIN1", $file->{path_base}, $file->{class_id} ) . "\n"); 123 print $list2File ( $ipprc->filename( "PPIMAGE.BIN2", $file->{path_base}, $file->{class_id} ) . "\n"); 143 124 push @means, $file->{bg}; 144 125 push @stdevs, $file->{bg_stdev}; … … 148 129 149 130 # Output products 131 $workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir; 132 my $outputRoot = $ipprc->file_prepare( "$camera.$det_type.norm.$det_id.$iter", $workdir ); 150 133 my $jpeg1Name = $ipprc->filename("PPIMAGE.JPEG1", $outputRoot); # Binned JPEG #1 151 134 my $jpeg2Name = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2 … … 157 140 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 158 141 run(command => $command, verbose => 1); 159 &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $ jpeg1Name;142 &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1Name); 160 143 } 161 144 … … 165 148 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 166 149 run(command => $command, verbose => 1); 167 &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $ jpeg2Name;150 &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2Name); 168 151 } 169 152 } 170 171 # Add the result into the database172 $outputRoot = $ipprc->convert_filename_relative( $outputRoot );173 153 174 154 unless ($no_update) { … … 183 163 &my_die("Unable to perform dettool -addnormalizedexp: $error_code", $det_id, $iter, $error_code); 184 164 } 185 186 unlink $list1Name;187 unlink $list2Name;188 165 } 189 166
Note:
See TracChangeset
for help on using the changeset viewer.
