Changeset 13275 for trunk/ippScripts/scripts/detrend_reject_imfile.pl
- Timestamp:
- May 4, 2007, 4:52:03 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_reject_imfile.pl (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_reject_imfile.pl
r12979 r13275 17 17 use PS::IPP::Metadata::List qw( parse_md_list ); 18 18 use Statistics::Descriptive; 19 20 use PS::IPP::Config qw( 21 $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 ); 19 use File::Temp qw( tempfile ); 20 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 ); … … 93 93 } 94 94 95 # Set output directory 96 if (defined $workdir) { 97 $workdir = $ipprc->convert_filename_absolute( $workdir ); 98 my $subdir = "$camera.$det_type.$det_id"; 99 $workdir = File::Spec->catdir( $workdir, $subdir, $exp_tag ); 100 } else { 101 my $example = $ipprc->convert_filename_absolute( ${$files}[0]->{path_base} ); # Example original name 102 my ($vol, $dir, $file) = File::Spec->splitpath( $example ); 103 $workdir = $dir; 104 } 105 system "mkdir -p $workdir" unless -d $workdir; 106 107 # Generate the file list, and get the statistics 108 my $outputFile = "$exp_tag.detresid.$det_id.$iter"; # Root name 109 my $outputRoot = File::Spec->catfile( $workdir, $outputFile ); 110 111 my $list1Name = $outputRoot . '.b1.list'; # Name for the input file list for binning 1 112 my $list2Name = $outputRoot . '.b2.list'; # Name for the input file list for binning 2 113 95 96 my ($list1File, $list1Name) = tempfile( "$exp_tag.detresid.$det_id.$iter.b1.list.XXXX", UNLINK => 1 ); 97 my ($list2File, $list2Name) = tempfile( "$exp_tag.detresid.$det_id.$iter.b2.list.XXXX", UNLINK => 1 ); 114 98 my @means; # Array of means 115 99 my @variances; # Array of variances 116 100 my @meanStdevs; # Array of mean stdevs 117 101 my @names; # Array of names (class_id) 118 open my $list1File, '>' . $list1Name;119 open my $list2File, '>' . $list2Name;120 102 foreach my $file (@$files) { 121 my $origRoot = $ipprc->convert_filename_absolute( $file->{path_base} ); # Original root name 122 print $list1File ($ipprc->filename( "PPIMAGE.BIN1", $origRoot, $file->{class_id} ) . "\n"); 123 print $list2File ($ipprc->filename( "PPIMAGE.BIN2", $origRoot, $file->{class_id} ) . "\n"); 103 print $list1File ($ipprc->filename( "PPIMAGE.BIN1", $file->{path_base}, $file->{class_id} ) . "\n"); 104 print $list2File ($ipprc->filename( "PPIMAGE.BIN2", $file->{path_base}, $file->{class_id} ) . "\n"); 124 105 push @means, $file->{bg}; 125 106 push @meanStdevs, $file->{bg_mean_stdev}; … … 131 112 close $list2File; 132 113 133 # Output products --- need to synch with the camera configuration! 114 # Output products 115 $workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir; 116 my $outputRoot = $ipprc->file_prepare( "$exp_tag.detresid.$det_id.$iter", $workdir, ${$files}[0]->{path_base} ); 134 117 my $jpeg1Name = $ipprc->filename("PPIMAGE.JPEG1", $outputRoot); # Binned JPEG #1 135 118 my $jpeg2Name = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2 … … 146 129 &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_tag, $error_code); 147 130 } 148 &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $ jpeg1Name;131 &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1Name); 149 132 } 150 133 … … 158 141 &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_tag, $error_code); 159 142 } 160 &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $ jpeg2Name;143 &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2Name); 161 144 } 162 145 } … … 173 156 my $reject_exp_sn = rejection_limit( 'EXP.SN', $det_type, $filter ); 174 157 175 my $logName = "$exp_tag.detreject.$det_id.$iter.log"; # Name for log 176 $logName = File::Spec->catfile( $workdir, $logName ); 158 my $logName = caturi( $workdir, "$exp_tag.detreject.$det_id.$iter.log" ); # Name for log 177 159 my $logFile; 178 160 unless ($no_op) { 179 open $logFile, "> $logName" or &my_die("Unable to open log file $logName", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR);161 $logFile = $ipprc->file_create_open( $logName ); 180 162 } 181 163 … … 311 293 312 294 # Add the result into the database 313 $outputRoot = $ipprc->convert_filename_relative( $outputRoot );314 315 295 my $bg = $mean; 316 296 my $bg_stdev = $stdev; … … 330 310 exit($error_code); 331 311 } 332 333 unlink $list1Name;334 unlink $list2Name;335 312 } 336 313
Note:
See TracChangeset
for help on using the changeset viewer.
