Changeset 11837
- Timestamp:
- Feb 15, 2007, 2:23:33 PM (19 years ago)
- Location:
- trunk/ippScripts/scripts
- Files:
-
- 14 edited
-
detrend_norm_apply.pl (modified) (6 diffs)
-
detrend_norm_calc.pl (modified) (8 diffs)
-
detrend_norm_exp.pl (modified) (4 diffs)
-
detrend_process_exp.pl (modified) (4 diffs)
-
detrend_process_imfile.pl (modified) (6 diffs)
-
detrend_reject_exp.pl (modified) (6 diffs)
-
detrend_reject_imfile.pl (modified) (7 diffs)
-
detrend_resid.pl (modified) (5 diffs)
-
detrend_stack.pl (modified) (7 diffs)
-
phase2.pl (modified) (7 diffs)
-
phase3.pl (modified) (5 diffs)
-
phase4_overlap.pl (modified) (3 diffs)
-
phase4_warp.pl (modified) (6 diffs)
-
phase5_subtract.pl (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_norm_apply.pl
r11830 r11837 39 39 $dbname, # Database name 40 40 $workdir, # Working directory, for output files 41 $no_update # Don't update the database 41 $no_update, # Don't update the database 42 $no_op, # Don't do any operations 42 43 ); 43 44 GetOptions( … … 51 52 'dbname|d=s' => \$dbname, 52 53 'workdir|w=s' => \$workdir, # Working directory, for output files 53 'no-update' => \$no_update 54 'no-update' => \$no_update, 55 'no-op' => \$no_op, 54 56 ) or pod2usage( 2 ); 55 57 … … 100 102 101 103 # Run normalisation 102 { 104 my $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 105 unless ($no_op) { 103 106 my $command = "$ppImage -file $input $outputRoot -norm $value -stat $statsName -recipe PPIMAGE " . RECIPE(); # Command to run 104 107 $command .= ' -isfringe' if lc($det_type) eq 'fringe'; … … 113 116 &my_die("Can't find expected output file: $b2name", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -e $b2name; 114 117 &my_die("Can't find expected output file: $statsName", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -e $statsName; 115 } 116 117 # Get the statistics on the normalised image 118 my $stats; # Statistics from ppImage 119 { 118 119 # Get the statistics on the normalised image 120 120 my $statsFile; # File handle 121 121 open $statsFile, $statsName or &my_die("Can't open statistics file $statsName: $!\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR); … … 124 124 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 125 125 my $metadata = $mdcParser->parse(join "", @contents) 126 or &my_die("Unable to parse metadata config", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR); 127 $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 126 or &my_die("Unable to parse metadata config", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR); 128 127 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR); 129 } 128 } 130 129 131 130 # Update the database … … 133 132 $b1name = $ipprc->convert_filename_relative( $b1name ); 134 133 $b2name = $ipprc->convert_filename_relative( $b2name ); 134 135 my $bg = ($stats->bg_mean() or 'NAN'); 136 my $bg_stdev = ($stats->bg_stdev() or 'NAN'); 137 my $bg_mean_stdev = ($stats->bg_mean_stdev() or 'NAN'); 138 135 139 unless ($no_update) { 136 140 my $command = "$dettool -addnormalizedimfile -det_id $det_id -iteration $iter -class_id $class_id ". 137 141 "-uri $output -b1_uri $outputRoot"; # Command to run 138 # Add the statistics triplet 139 $command .= " -bg " . $stats->bg_mean(); 140 if (defined($stats->bg_mean_stdev())) { 141 $command .= " -bg_mean_stdev " . $stats->bg_mean_stdev(); 142 } else { 143 # May be undefined if there's only a single imfile 144 $command .= " -bg_mean_stdev 0"; 145 } 146 $command .= " -bg_stdev " . $stats->bg_stdev(); 147 142 $command .= " -bg $bg -bg_stdev $bg_stdev -bg_mean_stdev $bg_mean_stdev"; 148 143 $command .= " -dbname $dbname" if defined $dbname; 149 144 -
trunk/ippScripts/scripts/detrend_norm_calc.pl
r11831 r11837 31 31 32 32 # Parse command-line arguments 33 my ($det Id, # Detrend id33 my ($det_id, # Detrend id 34 34 $iter, # Iteration 35 35 $detType, # Detrend type 36 36 $workdir, # Working directory for output files 37 37 $dbname, # Database name 38 $no_update # Don't update the database? 38 $no_update, # Don't update the database? 39 $no_op, # Don't do operations 39 40 ); 40 41 GetOptions( 41 'det_id|d=s' => \$det Id,42 'det_id|d=s' => \$det_id, 42 43 'iteration|i=s' => \$iter, 43 44 'det_type|t=s' => \$detType, 44 45 'workdir|w=s' => \$workdir, 45 46 'dbname|d=s' => \$dbname,# Database name 46 'no-update' => \$no_update 47 'no-update' => \$no_update, 48 'no-op' => \$no_op, 47 49 ) or pod2usage( 2 ); 48 50 … … 50 52 pod2usage( -msg => "Required options --det_id --iteration --det_type", 51 53 -exitval => 3, 52 ) unless defined $det Id54 ) unless defined $det_id 53 55 and defined $iter 54 56 and defined $detType; … … 85 87 my @files; # The input files 86 88 { 87 my $command = "$dettool -processedimfile -det_id $det Id"; # Command to run89 my $command = "$dettool -processedimfile -det_id $det_id"; # Command to run 88 90 $command .= " -dbname $dbname" if defined $dbname; 89 91 my @command = split /\s+/, $command; … … 91 93 print "Running [$command]...\n"; 92 94 if (not run(\@command, \$stdin, \$stdout, \$stderr)) { 93 &my_die("Unable to perform dettool -processedimfile on detrend $det Id/$iter: $?",95 &my_die("Unable to perform dettool -processedimfile on detrend $det_id/$iter: $?", 94 96 $det_id, $iter, $PS_EXIT_SYS_ERROR); 95 97 } … … 115 117 116 118 my $norms; # MDC with normalisations 117 if (NORMALIZE()->{lc($detType)} ) {119 if (NORMALIZE()->{lc($detType)} and not $no_op) { 118 120 119 121 my %matrix; # Matrix of statistics as a function of exposures and classes 120 122 foreach my $file (@files) { 121 my $exp Tag = $file->{'exp_tag'}; # Exposure ID122 my $class Id = $file->{'class_id'}; # Class ID123 my $exp_tag = $file->{'exp_tag'}; # Exposure ID 124 my $class_id = $file->{'class_id'}; # Class ID 123 125 my $stat = $file->{STATISTIC()}; # Statistic of interest 124 126 125 127 # Create matrix elements 126 $matrix{$exp Tag} = {} if not defined $matrix{$expTag};127 $matrix{$exp Tag}->{$classId} = $stat;128 $matrix{$exp_tag} = {} if not defined $matrix{$exp_tag}; 129 $matrix{$exp_tag}->{$class_id} = $stat; 128 130 } 129 131 130 132 # Generate the input for ppNormCalc 131 133 my $normData; # Normalisation data 132 foreach my $exp Tag (keys %matrix) {133 $normData .= "$exp Tag\tMETADATA\n";134 foreach my $class Id (keys %{$matrix{$expTag}}) {135 $normData .= "\t" . $class Id . "\tF32\t" . $matrix{$expTag}->{$classId} . "\n";134 foreach my $exp_tag (keys %matrix) { 135 $normData .= "$exp_tag\tMETADATA\n"; 136 foreach my $class_id (keys %{$matrix{$exp_tag}}) { 137 $normData .= "\t" . $class_id . "\tF32\t" . $matrix{$exp_tag}->{$class_id} . "\n"; 136 138 } 137 139 $normData .= "END\n\n"; … … 157 159 my %classes; # List of unique classes 158 160 foreach my $file (@files) { 159 my $class Id = $file->{'class_id'}; # Class Id160 $classes{$class Id} = 1;161 my $class_id = $file->{'class_id'}; # Class Id 162 $classes{$class_id} = 1; 161 163 } 162 164 163 foreach my $class Id (keys %classes) {165 foreach my $class_id (keys %classes) { 164 166 my %mdValue; # Metadata value for this class id 165 $mdValue{name} = $class Id;167 $mdValue{name} = $class_id; 166 168 $mdValue{value} = 1.0; 167 169 push @$norms, \%mdValue; … … 176 178 my $normalisation = $normItem->{value}; # Normalisation for component 177 179 178 my $command = "$dettool -addnormalizedstat -det_id $det Id -iteration $iter -class_id $className ".180 my $command = "$dettool -addnormalizedstat -det_id $det_id -iteration $iter -class_id $className ". 179 181 "-norm $normalisation"; # Command to run 180 182 $command .= " -dbname $dbname" if defined $dbname; … … 199 201 200 202 warn($msg); 201 if ($det_id and $iter and $class_id andnot $no_update) {203 if ($det_id and $iter and not $no_update) { 202 204 my $command = "$dettool -addnormalizedstat -det_id $det_id -iteration $iter -code $exit_code"; 203 205 $command .= " -dbname $dbname" if defined $dbname; -
trunk/ippScripts/scripts/detrend_norm_exp.pl
r11829 r11837 33 33 use Pod::Usage qw( pod2usage ); 34 34 35 my ($det_id, $iter, $det_type, $camera, $dbname, $workdir, $no_update );35 my ($det_id, $iter, $det_type, $camera, $dbname, $workdir, $no_update, $no_op); 36 36 GetOptions( 37 37 'det_id|d=s' => \$det_id, … … 41 41 'dbname|d=s' => \$dbname, # Database name 42 42 'workdir|w=s' => \$workdir, # Working directory, for output files 43 'no-update' => \$no_update 43 'no-update' => \$no_update, 44 'no-op' => \$no_op, 44 45 ) or pod2usage( 2 ); 45 46 … … 104 105 my $stats = Statistics::Descriptive::Sparse->new; # Statistics calculator 105 106 $stats->add_data(@backgrounds); 106 $bg = $stats->mean();107 $bg_mean_stdev = $stats->standard_deviation() || 0.0;107 $bg = ($stats->mean() or 'NAN'); 108 $bg_mean_stdev = ($stats->standard_deviation() or 'NAN'); 108 109 } 109 110 { 110 111 my $stats = Statistics::Descriptive::Sparse->new; # Statistics calculator 111 112 $stats->add_data(@variances); 112 $bg_stdev = sqrt( $stats->mean());113 $bg_stdev = (sqrt( $stats->mean() ) or 'NAN'); 113 114 } 114 115 } … … 147 148 my $jpeg2Name = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2 148 149 149 # Make the jpeg for binning 1 150 { 151 my $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE " . RECIPE1; # Command to run 152 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 153 run(command => $command, verbose => 1); 154 &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $jpeg1Name; 155 } 156 157 # Make the jpeg for binning 2 158 { 159 my $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE " . RECIPE2; # Command to run 160 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 161 run(command => $command, verbose => 1); 162 &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $jpeg2Name; 150 unless ($no_op) { 151 # Make the jpeg for binning 1 152 { 153 my $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE " . RECIPE1; # Command to run 154 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 155 run(command => $command, verbose => 1); 156 &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $jpeg1Name; 157 } 158 159 # Make the jpeg for binning 2 160 { 161 my $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE " . RECIPE2; # Command to run 162 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 163 run(command => $command, verbose => 1); 164 &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $jpeg2Name; 165 } 163 166 } 164 167 -
trunk/ippScripts/scripts/detrend_process_exp.pl
r11829 r11837 33 33 use Pod::Usage qw( pod2usage ); 34 34 35 my ($det_id, $exp_tag, $camera, $dbname, $workdir, $no_update );35 my ($det_id, $exp_tag, $camera, $dbname, $workdir, $no_update, $no_op); 36 36 GetOptions( 37 37 'det_id|d=s' => \$det_id, … … 40 40 'dbname|d=s' => \$dbname, # Database name 41 41 'workdir|w=s' => \$workdir, # Working directory, for output files 42 'no-update' => \$no_update 42 'no-update' => \$no_update, 43 'no-op' => \$no_op, 43 44 ) or pod2usage( 2 ); 44 45 … … 102 103 my $stats = Statistics::Descriptive::Sparse->new; # Statistics calculator 103 104 $stats->add_data(@backgrounds); 104 $bg = $stats->mean();105 $bg_mean_stdev = $stats->standard_deviation() || 0.0;105 $bg = ($stats->mean() or 'NAN'); 106 $bg_mean_stdev = ($stats->standard_deviation() or 'NAN'); 106 107 } 107 108 { 108 109 my $stats = Statistics::Descriptive::Sparse->new; # Statistics calculator 109 110 $stats->add_data(@variances); 110 $bg_stdev = sqrt( $stats->mean());111 $bg_stdev = (sqrt( $stats->mean() ) or 'NAN'); 111 112 } 112 113 } … … 143 144 my $jpeg2 = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2 144 145 145 # Make the jpeg for binning 1 146 { 147 my $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE " . RECIPE1; # Command to run 148 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 149 run(command => $command, verbose => 1); 150 unless ($success) { 151 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 152 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $error_code); 153 } 154 &my_die("Unable to find expected output file: $jpeg1", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg1; 155 } 156 157 # Make the jpeg for binning 2 158 { 159 my $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE " . RECIPE2; # Command to run 160 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 161 run(command => $command, verbose => 1); 162 unless ($success) { 163 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 164 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $error_code); 165 } 166 &my_die("Unable to find expected output file: $jpeg2", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg2; 167 } 168 146 unless ($no_op) { 147 # Make the jpeg for binning 1 148 { 149 my $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE " . RECIPE1; # Command to run 150 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 151 run(command => $command, verbose => 1); 152 unless ($success) { 153 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 154 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $error_code); 155 } 156 &my_die("Unable to find expected output file: $jpeg1", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg1; 157 } 158 159 # Make the jpeg for binning 2 160 { 161 my $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE " . RECIPE2; # Command to run 162 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 163 run(command => $command, verbose => 1); 164 unless ($success) { 165 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 166 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $error_code); 167 } 168 &my_die("Unable to find expected output file: $jpeg2", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg2; 169 } 170 } 169 171 170 172 # Add the result into the database -
trunk/ippScripts/scripts/detrend_process_imfile.pl
r11830 r11837 32 32 use Pod::Usage qw( pod2usage ); 33 33 34 my ($det_id, $exp_tag, $class_id, $det_type, $input_uri, $camera, $dbname, $workdir, $no_update );34 my ($det_id, $exp_tag, $class_id, $det_type, $input_uri, $camera, $dbname, $workdir, $no_update, $no_op); 35 35 GetOptions( 36 36 'det_id|d=s' => \$det_id, … … 42 42 'dbname|d=s' => \$dbname, # Database name 43 43 'workdir|w=s' => \$workdir, # Working directory, for output files 44 'no-update' => \$no_update 44 'no-update' => \$no_update, 45 'no-op' => \$no_op, 45 46 ) or pod2usage( 2 ); 46 47 … … 105 106 106 107 # Run ppImage 107 { 108 my $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 109 unless ($no_op) { 108 110 my $command = "$ppImage -file $input_uri $outputRoot -recipe PPIMAGE $recipe" . 109 111 " -stat $outputStats"; # Command to run ppImage … … 118 120 &my_die("Couldn't find expected output file: $outputBin1", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin1; 119 121 &my_die("Couldn't find expected output file: $outputBin2", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin2; 120 }121 122 122 # Get the statistics on the processed image 123 my $stats; # Statistics from ppImage 124 { 123 # Get the statistics on the processed image 125 124 my $statsFile; # File handle 126 125 open $statsFile, "$outputStats" or die "Can't open statistics file $outputStats: $!\n"; … … 130 129 my $metadata = $mdcParser->parse(join "", @contents) 131 130 or &my_die("Unable to parse metadata config", $det_id, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 132 $stats = PS::IPP::Metadata::Stats->new(); # Stats parser133 131 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 134 132 } … … 139 137 $outputBin2 = $ipprc->convert_filename_relative( $outputBin2 ); 140 138 139 my $bg = ($stats->bg_mean() or 'NAN'); 140 my $bg_stdev = ($stats->bg_stdev() or 'NAN'); 141 my $bg_mean_stdev = ($stats->bg_mean_stdev() or 'NAN'); 142 141 143 # Add the processed file to the database 142 144 unless ($no_update) { 143 145 my $command = "$dettool -addprocessedimfile -det_id $det_id -exp_tag $exp_tag " . 144 146 "-class_id $class_id -recip $recipe -uri $outputImage -b1_uri $outputRoot"; # Command to run dettool 145 $command .= " -bg " . $stats->bg_mean(); 146 if (defined($stats->bg_mean_stdev())) { 147 $command .= " -bg_mean_stdev " . $stats->bg_mean_stdev(); 148 } else { 149 # May be undefined if there's only a single imfile 150 $command .= " -bg_mean_stdev 0"; 151 } 152 $command .= " -bg_stdev " . $stats->bg_stdev(); 147 $command .= " -bg $bg -bg_stdev $bg_stdev -bg_mean_stdev $bg_mean_stdev"; 153 148 $command .= " -dbname $dbname" if defined $dbname; 154 149 -
trunk/ippScripts/scripts/detrend_reject_exp.pl
r11829 r11837 32 32 use Pod::Usage qw( pod2usage ); 33 33 34 my ($det_id, $iter, $det_type, $camera, $filter, $workdir, $dbname, $no_update );34 my ($det_id, $iter, $det_type, $camera, $filter, $workdir, $dbname, $no_update, $no_op); 35 35 GetOptions( 36 36 'det_id|d=s' => \$det_id, … … 41 41 'workdir|w=s' => \$workdir, # Working directory for output files 42 42 'dbname|d=s' => \$dbname, # Database name 43 'no-update' => \$no_update 43 'no-update' => \$no_update, 44 'no-op' => \$no_op, 44 45 ) or pod2usage( 2 ); 45 46 … … 133 134 $command = "$dettool -updateresidexp -det_id $det_id -iteration $iter -exp_tag $expTag"; # Command to run 134 135 $command .= " -dbname $dbname" if defined $dbname; 135 136 136 137 $reject = 0; # Reject this exposure? 137 138 … … 143 144 } 144 145 146 # Cop-out if we're not doing any operations 147 if ($no_op) { 148 # Make sure something gets rejected (just once!), just so that 149 # we can trace the full range of the workflow 150 if ($i == 0 and $iter == 0) { 151 $reject = 1; 152 } 153 goto UPDATE; 154 } 155 145 156 if ($reject_mean and defined $meanStats->standard_deviation() ) { 146 157 my $dMean = abs($means[$i] - $meanStats->mean()) ; … … 201 212 } 202 213 } 203 214 204 215 # Decide if the current is sufficient to use as a master, and if we can stop iterating 205 216 my $master = 1; # This is good enough for a master … … 220 231 print "Stop: $stop\n"; 221 232 222 # Put the resultinto the database233 # Put results into the database 223 234 unless ($no_update) { 224 my $varianceStats = Statistics::Descriptive::Sparse->new(); # Statistics calculator 225 $varianceStats->add_data(@variances); 226 227 my $command = "$dettool -adddetrunsummary -det_id $det_id -iteration $iter" . 228 " -bg " . $meanStats->mean() . " -bg_stdev " . sqrt($varianceStats->mean()) . 229 " -bg_mean_stdev " . $meanStats->standard_deviation(); 230 $command .= " -accept" if $master; 231 $command .= " -dbname $dbname" if defined $dbname; 232 233 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 234 run(command => $command, verbose => 1); 235 unless ($success) { 236 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 237 warn("Unable to perform dettool -adddetrunsummary: $error_code"); 238 exit($error_code); 239 } 240 } 241 242 # Re-run processing if required 243 unless ($no_update) { 244 my $command = "$dettool -updatedetrun -det_id $det_id"; 245 if ($stop) { 246 $command .= ' -state stop'; 247 } else { 248 $command .= ' -again'; 249 } 250 251 $command .= " -dbname $dbname" if defined $dbname; 252 253 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 254 run(command => $command, verbose => 1); 255 unless ($success) { 256 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 257 warn("Unable to perform dettool -updatedetrun: $error_code"); 258 exit($error_code); 235 236 { 237 # Add the summary 238 my $varianceStats = Statistics::Descriptive::Sparse->new(); # Statistics calculator 239 $varianceStats->add_data(@variances); 240 241 my $bg = ($meanStats->mean() or 'NAN'); 242 my $bg_stdev = (sqrt( $varianceStats->mean() ) or 'NAN'); 243 my $bg_mean_stdev = ($meanStats->standard_deviation() or 'NAN'); 244 245 my $command = "$dettool -adddetrunsummary -det_id $det_id -iteration $iter"; 246 $command .= " -bg $bg -bg_stdev $bg_stdev -bg_mean_stdev $bg_mean_stdev"; 247 $command .= " -accept" if $master; 248 $command .= " -dbname $dbname" if defined $dbname; 249 250 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 251 run(command => $command, verbose => 1); 252 unless ($success) { 253 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 254 warn("Unable to perform dettool -adddetrunsummary: $error_code"); 255 exit($error_code); 256 } 257 } 258 259 # Re-run processing if required 260 { 261 my $command = "$dettool -updatedetrun -det_id $det_id"; 262 if ($stop) { 263 $command .= ' -state stop'; 264 } else { 265 $command .= ' -again'; 266 } 267 268 $command .= " -dbname $dbname" if defined $dbname; 269 270 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 271 run(command => $command, verbose => 1); 272 unless ($success) { 273 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 274 warn("Unable to perform dettool -updatedetrun: $error_code"); 275 exit($error_code); 276 } 259 277 } 260 278 } -
trunk/ippScripts/scripts/detrend_reject_imfile.pl
r11829 r11837 33 33 use Pod::Usage qw( pod2usage ); 34 34 35 my ($det_id, $iter, $exp_tag, $det_type, $camera, $filter, $reject, $dbname, $workdir, $no_update );35 my ($det_id, $iter, $exp_tag, $det_type, $camera, $filter, $reject, $dbname, $workdir, $no_update, $no_op); 36 36 GetOptions( 37 37 'det_id|d=s' => \$det_id, … … 45 45 'workdir|w=s' => \$workdir, # Working directory, for output files 46 46 'no-update' => \$no_update, 47 'no-op' => \$no_op, 47 48 ) or pod2usage( 2 ); 48 49 … … 129 130 my $jpeg2Name = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2 130 131 131 # Make the jpeg for binning 1 132 { 133 my $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE " . RECIPE1; # Command to run 134 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 135 run(command => $command, verbose => 1); 136 unless ($success) { 137 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 138 &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_tag, $error_code); 139 } 140 &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg1Name; 141 } 142 143 # Make the jpeg for binning 2 144 { 145 my $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE " . RECIPE2; # Command to run 146 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 147 run(command => $command, verbose => 1); 148 unless ($success) { 149 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 150 &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_tag, $error_code); 151 } 152 &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg2Name; 132 unless ($no_op) { 133 134 # Make the jpeg for binning 1 135 { 136 my $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE " . RECIPE1; # Command to run 137 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 138 run(command => $command, verbose => 1); 139 unless ($success) { 140 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 141 &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_tag, $error_code); 142 } 143 &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg1Name; 144 } 145 146 # Make the jpeg for binning 2 147 { 148 my $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE " . RECIPE2; # Command to run 149 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 150 run(command => $command, verbose => 1); 151 unless ($success) { 152 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 153 &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_tag, $error_code); 154 } 155 &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg2Name; 156 } 153 157 } 154 158 … … 172 176 my $stdev = sqrt($variances[$i]); # Stdev for this imfile 173 177 178 last if $no_op; 179 174 180 if ($reject_imfile_mean) { 175 181 if (abs($mean) > $reject_imfile_mean * $stdev) { … … 212 218 print "no rejection for imfile S/N\n"; 213 219 } 214 215 220 } 216 221 … … 235 240 ## Reject based on the exposure ensemble stats 236 241 # reject if the exposure ensemble mean is deviant 237 if ($reject_exp_mean) { 238 if (abs($mean) > $reject_exp_mean * $stdev) { 239 print "Rejecting exposure based on bad mean: \n"; 240 print "mean: $mean, stdev: $stdev (limit is: % $reject_exp_mean\n"; 241 $reject = 1; 242 } 243 } else { 244 print "no rejection for exp mean\n"; 245 } 246 # reject if the exposure ensemble stdev is deviant 247 if ($reject_exp_stdev) { 248 if ($stdev > $reject_exp_stdev) { 249 print "Rejecting exposure based on bad mean stdev: " . $stdev . " vs " . 250 $reject_exp_stdev . "\n"; 251 $reject = 1; 252 } 253 } else { 254 print "no rejection for exp stdev\n"; 255 } 256 # reject if the exposure ensemble mean stdev is deviant 257 if ($reject_exp_meanstdev) { 258 if ($meanStdev > $reject_exp_meanstdev) { 259 print "Rejecting exposure based on bad mean stdev: " . $meanStdev . " vs " . 260 $reject_exp_meanstdev . "\n"; 261 $reject = 1; 262 } 263 } else { 264 print "no rejection for exp mean stdev\n"; 265 } 266 # reject if the signal-to-noise is insufficient 267 if ($reject_exp_sn) { 268 if (abs($mean) < abs($stdev * $reject_exp_sn)) { 269 print "Rejecting exposure based on poor S/N: \n"; 270 print "signal: $mean vs noise: $stdev (s/n limit is: $reject_exp_sn)\n"; 271 $reject = 1; 272 } 273 } else { 274 print "no rejection for exp S/N\n"; 242 unless ($no_op) { 243 if ($reject_exp_mean) { 244 if (abs($mean) > $reject_exp_mean * $stdev) { 245 print "Rejecting exposure based on bad mean: \n"; 246 print "mean: $mean, stdev: $stdev (limit is: % $reject_exp_mean\n"; 247 $reject = 1; 248 } 249 } else { 250 print "no rejection for exp mean\n"; 251 } 252 # reject if the exposure ensemble stdev is deviant 253 if ($reject_exp_stdev) { 254 if ($stdev > $reject_exp_stdev) { 255 print "Rejecting exposure based on bad mean stdev: " . $stdev . " vs " . 256 $reject_exp_stdev . "\n"; 257 $reject = 1; 258 } 259 } else { 260 print "no rejection for exp stdev\n"; 261 } 262 # reject if the exposure ensemble mean stdev is deviant 263 if ($reject_exp_meanstdev) { 264 if ($meanStdev > $reject_exp_meanstdev) { 265 print "Rejecting exposure based on bad mean stdev: " . $meanStdev . " vs " . 266 $reject_exp_meanstdev . "\n"; 267 $reject = 1; 268 } 269 } else { 270 print "no rejection for exp mean stdev\n"; 271 } 272 # reject if the signal-to-noise is insufficient 273 if ($reject_exp_sn) { 274 if (abs($mean) < abs($stdev * $reject_exp_sn)) { 275 print "Rejecting exposure based on poor S/N: \n"; 276 print "signal: $mean vs noise: $stdev (s/n limit is: $reject_exp_sn)\n"; 277 $reject = 1; 278 } 279 } else { 280 print "no rejection for exp S/N\n"; 281 } 275 282 } 276 283 … … 278 285 $jpeg1Name = $ipprc->convert_filename_relative( $jpeg1Name ); 279 286 $jpeg2Name = $ipprc->convert_filename_relative( $jpeg2Name ); 287 288 my $bg = $mean; 289 my $bg_stdev = $stdev; 290 my $bg_mean_stdev = $meanStdev; 291 280 292 unless ($no_update) { 281 293 my $command = "$dettool -addresidexp -det_id $det_id -iteration $iter -exp_tag $exp_tag " . 282 "-recip " . RECIPE1() . "," . RECIPE2() . " -b1_uri $outputRoot " .283 "-bg $mean -bg_stdev $stdev -bg_mean_stdev $meanStdev"; # Command to run 294 "-recip " . RECIPE1() . "," . RECIPE2() . " -b1_uri $outputRoot "; # Command to run 295 $command .= " -bg $bg -bg_stdev $bg_stdev -bg_mean_stdev $bg_mean_stdev"; 284 296 $command .= ' -reject' if $reject; 285 297 $command .= " -dbname $dbname" if defined $dbname; -
trunk/ippScripts/scripts/detrend_resid.pl
r11829 r11837 34 34 35 35 my ($det_id, $iter, $exp_tag, $class_id, $det_type, $detrend, 36 $input_uri, $camera, $mode, $dbname, $workdir, $no_update );36 $input_uri, $camera, $mode, $dbname, $workdir, $no_update, $no_op); 37 37 GetOptions( 38 38 'det_id|d=s' => \$det_id, … … 48 48 'workdir|w=s' => \$workdir, # Working directory, for output files 49 49 'no-update' => \$no_update, 50 'no-op' => \$no_op, 50 51 ) or pod2usage( 2 ); 51 52 … … 138 139 139 140 # Run ppImage 140 { 141 my $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 142 unless ($no_op) { 141 143 my $command = "$ppImage -file $input_uri $outputRoot -recipe PPIMAGE $recipe" . 142 144 " -stat $outputStats "; # Command to run ppImage … … 159 161 &my_die("Couldn't find expected output file: $bin1Name", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $bin1Name; 160 162 &my_die("Couldn't find expected output file: $bin2Name", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $bin2Name; 161 } 162 163 # Get the statistics on the residual image 164 my $stats; # Statistics from ppImage 165 { 163 164 # Get the statistics on the residual image 166 165 my $statsFile; # File handle 167 166 open $statsFile, $outputStats or &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR); … … 179 178 $bin1Name = $ipprc->convert_filename_relative( $bin1Name ); 180 179 $bin2Name = $ipprc->convert_filename_relative( $bin2Name ); 180 181 my $bg = ($stats->bg_mean() or 'NAN'); 182 my $bg_stdev = ($stats->bg_stdev() or 'NAN'); 183 my $bg_mean_stdev = ($stats->bg_mean_stdev() or 'NAN'); 184 181 185 unless ($no_update) { 182 186 my $command = "$dettool -addresidimfile -det_id $det_id -iteration $iter -exp_tag $exp_tag " . 183 187 "-class_id $class_id -recip $recipe -uri $outputName -b1_uri $outputRoot"; # Command to run dettool 184 $command .= " -bg " . $stats->bg_mean();188 $command .= " -bg $bg -bg_stdev $bg_stdev -bg_mean_stdev $bg_mean_stdev"; 185 189 $command .= " -dbname $dbname" if defined $dbname; 186 187 if (defined($stats->bg_mean_stdev())) {188 $command .= " -bg_mean_stdev " . $stats->bg_mean_stdev();189 } else {190 # May be undefined if there is only a single imfile191 $command .= ' -bg_mean_stdev 0';192 }193 194 $command .= " -bg_stdev " . $stats->bg_stdev();195 190 196 191 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = -
trunk/ippScripts/scripts/detrend_stack.pl
r11830 r11837 33 33 use Pod::Usage qw( pod2usage ); 34 34 35 my ($det_id, $iter, $class_id, $det_type, $camera, $dbname, $workdir, $no_update );35 my ($det_id, $iter, $class_id, $det_type, $camera, $dbname, $workdir, $no_update, $no_op); 36 36 GetOptions( 37 37 'det_id|d=s' => \$det_id, … … 42 42 'dbname|d=s' => \$dbname, # Database name 43 43 'workdir|w=s' => \$workdir, # Working directory, for output files 44 'no-update' => \$no_update 44 'no-update' => \$no_update, 45 'no-op' => \$no_op, 45 46 ) or pod2usage( 2 ); 46 47 … … 112 113 my $outputStats = $outputRoot . '.stats'; # Statistics name 113 114 114 { 115 my $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 116 unless ($no_op) { 115 117 my $command = "$ppMerge $outputStack"; # Command to run 116 118 foreach my $file (@$files) { … … 122 124 $command .= ' -type ' . uc($det_type); # Type of stacking to perform 123 125 $command .= " -stats $outputStats"; # Statistics output filename 124 126 125 127 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 126 128 run(command => $command, verbose => 1); … … 131 133 &my_die("Unable to find expected output file: $outputStack\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStack; 132 134 &my_die("Unable to find expected output file: $outputStats\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStats; 133 }134 135 135 # Get the statistics on the stacked image 136 my $stats; # Statistics from ppMerge 137 { 136 # Get the statistics on the stacked image 138 137 open(my $statsFile, "$outputStats") or 139 138 &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR); 140 139 my $contents = do { local $/; <$statsFile> }; # Contents of file 141 140 close($statsFile); 142 141 143 142 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 144 143 my $metadata = $mdcParser->parse($contents) or … … 149 148 } 150 149 150 my $bg = ($stats->bg_mean() or 'NAN'); 151 my $bg_stdev = ($stats->bg_stdev() or 'NAN'); 152 my $bg_mean_stdev = ($stats->bg_mean_stdev() or 'NAN'); 153 151 154 # Add the resultant into the database 152 155 $outputStack = $ipprc->convert_filename_relative($outputStack); … … 154 157 my $command = "$dettool -addstacked -det_id $det_id -iteration $iter -class_id $class_id" . 155 158 " -uri $outputStack -recip $recipe"; # Command to run 156 $command .= ' -bg ' . $stats->bg_mean(); 157 if (defined($stats->bg_mean_stdev())) { 158 $command .= ' -bg_mean_stdev ' . $stats->bg_mean_stdev(); 159 } else { 160 # May be undefined if there is only a single imfile 161 $command .= ' -bg_mean_stdev 0'; 162 } 163 $command .= ' -bg_stdev ' . $stats->bg_stdev(); 159 $command .= " -bg $bg -bg_stdev $bg_stdev -bg_mean_stdev $bg_mean_stdev"; 164 160 $command .= " -dbname $dbname" if defined $dbname; 161 165 162 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 166 163 run(command => $command, verbose => 1); -
trunk/ippScripts/scripts/phase2.pl
r11830 r11837 38 38 $dbname, # Database name 39 39 $workdir, # Working directory, for output files 40 $no_update # Don't update the database? 40 $no_update, # Don't update the database? 41 $no_op, # Don't do any operations? 41 42 ); 42 43 GetOptions( … … 47 48 'dbname|d=s' => \$dbname, # Database name 48 49 'workdir|w=s' => \$workdir, 49 'no-update' => \$no_update 50 'no-update' => \$no_update, 51 'no-op' => \$no_op, 50 52 ) or pod2usage( 2 ); 51 53 … … 88 90 $input = $ipprc->convert_filename_absolute( $input ); 89 91 90 # Run ppImage 91 { 92 my $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 93 unless ($no_op) { 94 # Run ppImage 92 95 print "outputImage: $outputImage\n"; 93 96 print "outputBin1: $outputBin1\n"; 94 97 print "outputStats: $outputStats\n"; 95 98 96 99 my $command = "$ppImage -file $input $outputRoot -recipe PPIMAGE " . RECIPE . 97 100 " -stat $outputStats"; # Command to run ppImage … … 106 109 &my_die("Couldn't find expected output file: $outputBin2\n", $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin2; 107 110 &my_die("Couldn't find expected output file: $outputStats\n", $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStats; 108 }109 111 110 # Get the statistics on the processed image 111 my $stats; # Statistics from ppImage 112 { 112 # Get the statistics on the processed image 113 113 my $statsFile; # File handle 114 114 open $statsFile, $outputStats or &my_die("Can't open statistics file $outputStats: $!", $exp_tag, $class_id, $PS_EXIT_SYS_ERROR); … … 118 118 my $metadata = $mdcParser->parse(join "", @contents) or 119 119 &my_die("Unable to parse metadata config doc", $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 120 $stats = PS::IPP::Metadata::Stats->new(); # Stats parser121 120 $stats->parse($metadata) or 122 121 &my_die("Unable to find all values in statistics output.\n", $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); … … 127 126 $outputBin1 = $ipprc->convert_filename_relative( $outputBin1 ); 128 127 $outputBin2 = $ipprc->convert_filename_relative( $outputBin2 ); 128 129 my $bg = ($stats->bg_mean() or 'NAN'); 130 my $bg_stdev = ($stats->bg_stdev() or 'NAN'); 131 my $bg_mean_stdev = ($stats->bg_mean_stdev() or 'NAN'); 132 129 133 unless ($no_update) { 130 134 # Command to run p2tool … … 135 139 $command .= " -uri $outputImage"; 136 140 $command .= " -b1_uri $outputRoot"; 137 $command .= " -bg " . $stats->bg_mean(); 138 $command .= " -bg_stdev " . $stats->bg_stdev(); 139 if ( defined $stats->bg_mean_stdev() ) { 140 $command .= " -bg_mean_stdev " . $stats->bg_mean_stdev(); 141 } else { 142 $command .= " -bg_mean_stdev 0.0"; 143 } 141 $command .= " -bg $bg -bg_stdev $bg_stdev -bg_mean_stdev $bg_mean_stdev"; 144 142 $command .= " -dbname $dbname" if defined $dbname; 145 143 -
trunk/ippScripts/scripts/phase3.pl
r11829 r11837 33 33 use Pod::Usage qw( pod2usage ); 34 34 35 my ($exp_tag, $camera, $dbname, $workdir, $no_update );35 my ($exp_tag, $camera, $dbname, $workdir, $no_update, $no_op); 36 36 GetOptions( 37 37 'exp_tag|e=s' => \$exp_tag, … … 39 39 'dbname|d=s' => \$dbname, # Database name 40 40 'workdir|w=s' => \$workdir, 41 'no-update' => \$no_update 41 'no-update' => \$no_update, 42 'no-op' => \$no_op, 42 43 ) or pod2usage( 2 ); 43 44 … … 111 112 my $stats = Statistics::Descriptive::Sparse->new; # Statistics calculator 112 113 $stats->add_data(@backgrounds); 113 $bg = $stats->mean();114 $bg_mean_stdev = $stats->standard_deviation() || 0.0;114 $bg = ($stats->mean() or 'NAN'); 115 $bg_mean_stdev = ($stats->standard_deviation() or 'NAN'); 115 116 } 116 117 { 117 118 my $stats = Statistics::Descriptive::Sparse->new; # Statistics calculator 118 119 $stats->add_data(@variances); 119 $bg_stdev = sqrt( $stats->mean());120 $bg_stdev = (sqrt( $stats->mean() ) or 'NAN'); 120 121 } 121 122 } … … 169 170 my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT", $outputRoot); # MEF psastro output 170 171 171 # run psastro +mosastro on the set of chips 172 # XXX note that this is wrong if imfiles are cells 173 if (@$files > 1) { 174 my $command = "$psastro -list $list3Name $outputRoot +mosastro -chipastro"; 175 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 176 run(command => $command, verbose => 1); 177 unless ($success) { 178 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 179 &my_die("Unable to perform psastro: $error_code", $exp_tag, $error_code); 180 } 181 &my_die("Unable to find expected output file: $fpaObjects", $exp_tag, $PS_EXIT_PROG_ERROR) unless -f $fpaObjects; 182 } else { 183 $fpaObjects = $chipObjects; 184 } 185 186 # run addstar on either the single chip output or the single fpa output 187 # XXX this construct requires the user to have a valid .ptolemyrc 188 # XXX which in turn points at ippconfig/dvo.site 189 { 190 my $command = "addstar -D CAMERA $camera $fpaObjects"; 191 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 192 run(command => $command, verbose => 1); 193 unless ($success) { 194 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 195 &my_die("Unable to perform addstar: $error_code", $exp_tag, $error_code); 196 } 197 } 198 199 # Make the jpeg for binning 1 200 { 201 my $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE " . RECIPE1; # Command to run 202 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 203 run(command => $command, verbose => 1); 204 unless ($success) { 205 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 206 &my_die("Unable to perform ppImage: $error_code", $exp_tag, $error_code); 207 } 208 &my_die("Unable to find expected output file: $jpeg1", $exp_tag, $PS_EXIT_PROG_ERROR) unless -f $jpeg1; 209 } 210 211 # Make the jpeg for binning 2 212 { 213 my $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE " . RECIPE2; # Command to run 214 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 215 run(command => $command, verbose => 1); 216 unless ($success) { 217 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 218 &my_die("Unable to perform ppImage: $error_code", $exp_tag, $error_code); 219 } 220 &my_die("Unable to find expected output file: $jpeg2", $exp_tag, $PS_EXIT_PROG_ERROR) unless -f $jpeg2; 172 unless ($no_op) { 173 174 # run psastro +mosastro on the set of chips 175 # XXX note that this is wrong if imfiles are cells 176 if (@$files > 1) { 177 my $command = "$psastro -list $list3Name $outputRoot +mosastro -chipastro"; 178 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 179 run(command => $command, verbose => 1); 180 unless ($success) { 181 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 182 &my_die("Unable to perform psastro: $error_code", $exp_tag, $error_code); 183 } 184 &my_die("Unable to find expected output file: $fpaObjects", $exp_tag, $PS_EXIT_PROG_ERROR) unless -f $fpaObjects; 185 } else { 186 $fpaObjects = $chipObjects; 187 } 188 189 # run addstar on either the single chip output or the single fpa output 190 # XXX this construct requires the user to have a valid .ptolemyrc 191 # XXX which in turn points at ippconfig/dvo.site 192 { 193 my $command = "addstar -D CAMERA $camera $fpaObjects"; 194 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 195 run(command => $command, verbose => 1); 196 unless ($success) { 197 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 198 &my_die("Unable to perform addstar: $error_code", $exp_tag, $error_code); 199 } 200 } 201 202 # Make the jpeg for binning 1 203 { 204 my $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE " . RECIPE1; # Command to run 205 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 206 run(command => $command, verbose => 1); 207 unless ($success) { 208 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 209 &my_die("Unable to perform ppImage: $error_code", $exp_tag, $error_code); 210 } 211 &my_die("Unable to find expected output file: $jpeg1", $exp_tag, $PS_EXIT_PROG_ERROR) unless -f $jpeg1; 212 } 213 214 # Make the jpeg for binning 2 215 { 216 my $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE " . RECIPE2; # Command to run 217 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 218 run(command => $command, verbose => 1); 219 unless ($success) { 220 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 221 &my_die("Unable to perform ppImage: $error_code", $exp_tag, $error_code); 222 } 223 &my_die("Unable to find expected output file: $jpeg2", $exp_tag, $PS_EXIT_PROG_ERROR) unless -f $jpeg2; 224 } 221 225 } 222 226 … … 226 230 $jpeg1 = $ipprc->convert_filename_relative($jpeg1); 227 231 $jpeg2 = $ipprc->convert_filename_relative($jpeg2); 232 228 233 unless ($no_update) { 229 234 my $command = "$p3tool -addprocessedexp -exp_tag $exp_tag -uri UNKNOWN " . -
trunk/ippScripts/scripts/phase4_overlap.pl
r11829 r11837 32 32 use Pod::Usage qw( pod2usage ); 33 33 34 my ($ det_id, $dbname, $workdir, $no_update);34 my ($p4_id, $dbname, $workdir, $no_update, $no_op); 35 35 GetOptions( 36 36 'p4_id|i=s' => \$p4_id, # Phase 4 identifier 37 37 'dbname|d=s' => \$dbname, # Database name 38 38 'workdir|w=s' => \$workdir, # Working directory, for output files 39 'no-update' => \$no_update 39 'no-update' => \$no_update, # Don't update the database? 40 'no-op' => \$no_op, # Don't do any operations 40 41 ) or pod2usage( 2 ); 41 42 … … 67 68 } 68 69 70 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 69 71 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 70 72 &my_die("Unable to parse metadata config doc", $p4_id, $PS_EXIT_PROG_ERROR); … … 73 75 } 74 76 77 unless ($no_op) { 78 75 79 ### Calculates, in some as-yet unknown way the overlaps between imfiles and skycells 76 80 77 # Add in the skycell and tesselation for each imfile 78 foreach my $imfile (@$imfiles) { 79 $imfile->{skycell_id} = 'default'; 80 $imfile->{tess_id} = 'default'; 81 } else { 82 # Add in the skycell and tesselation for each imfile 83 foreach my $imfile (@$imfiles) { 84 $imfile->{skycell_id} = 'default'; 85 $imfile->{tess_id} = 'default'; 86 } 81 87 } 82 88 83 89 84 90 # Generate a MDC file with the overlaps 85 91 $workdir = $ipprc->convert_filename_absolute( $workdir ); 86 my $overlapName = File::Spec->catfile( $workdir, $p4_id . ".overlap.mdc");87 open my $overlapFile "> $overlapName" or92 my $overlapName = File::Spec->catfile( $workdir, $p4_id . '.overlap.mdc' ); 93 open my $overlapFile, "> $overlapName" or 88 94 &my_die("Unable to open mdc file $overlapName", $p4_id, $PS_EXIT_DATA_ERROR); 89 95 print $overlapFile "p4SkyCellMap MULTI\n\n"; -
trunk/ippScripts/scripts/phase4_warp.pl
r11830 r11837 32 32 use Pod::Usage qw( pod2usage ); 33 33 34 my ($p4_id, $skycell_id, $camera, $dbname, $workdir, $no_update );34 my ($p4_id, $skycell_id, $camera, $dbname, $workdir, $no_update, $no_op); 35 35 GetOptions( 36 36 'p4_id|i=s' => \$p4_id, # Phase 4 identifier … … 39 39 'dbname|d=s' => \$dbname, # Database name 40 40 'workdir|w=s' => \$workdir, # Working directory, for output files 41 'no-update' => \$no_update 41 'no-update' => \$no_update, # Don't update the database? 42 'no-op' => \$no_op, # Don't do any operations? 42 43 ) or pod2usage( 2 ); 43 44 … … 62 63 63 64 # Get list of component imfiles for exposure 65 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 64 66 my $imfiles; 65 67 { … … 97 99 open my $listFile, '>' . $listName; 98 100 foreach my $imfile (@$imfiles) { 99 my $uri = $ipprc->convert_filename_absolute( $ file->{uri} );101 my $uri = $ipprc->convert_filename_absolute( $imfile->{uri} ); 100 102 101 print $listFile $uri . "\n";103 print $listFile "$uri\n"; 102 104 } 103 105 close $listFile; 104 106 105 107 # Run pswarp 106 { 107 my $command = "$pswarp -file $uri $outputRoot -stat $outputStats"; # Command to run pswarp 108 my $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 109 unless ($no_op) { 110 my $command = "$pswarp -list $listName $outputRoot -stat $outputStats"; # Command to run pswarp 108 111 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 109 112 run(command => $command, verbose => 1); … … 116 119 &my_die("Couldn't find expected output file: $outputBin1", $p4_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin1; 117 120 &my_die("Couldn't find expected output file: $outputBin2", $p4_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin2; 118 }119 121 120 # Get the statistics on the warped image 121 my $stats; # Statistics from pswarp 122 { 122 # Get the statistics on the warped image 123 123 my $statsFile; # File handle 124 124 open $statsFile, "$outputStats" or die "Can't open statistics file $outputStats: $!\n"; 125 125 my @contents = <$statsFile>; # Contents of file 126 126 close $statsFile; 127 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files128 127 my $metadata = $mdcParser->parse(join "", @contents) 129 128 or &my_die("Unable to parse metadata config", $p4_id, $skycell_id, $PS_EXIT_PROG_ERROR); 130 $stats = PS::IPP::Metadata::Stats->new(); # Stats parser131 129 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $p4_id, $skycell_id, $PS_EXIT_PROG_ERROR); 132 130 } … … 137 135 $outputBin2 = $ipprc->convert_filename_relative( $outputBin2 ); 138 136 137 my $bg = ($stats->bg_mean() or 'NAN'); 138 my $bg_stdev = ($stats->bg_stdev() or 'NAN'); 139 139 140 # Add the processed file to the database 140 141 unless ($no_update) { 141 142 my $command = "$p4tool -warped -p4_id $p4_id -skycell_id $skycell_id" . 142 143 " -uri $outputImage -b1_uri $outputRoot"; # Command to run dettool 143 $command .= " -bg " . $stats->bg_mean(); 144 $command .= " -bg_stdev " . $stats->bg_stdev(); 144 $command .= " -bg $bg -bg_stdev $bg_stdev"; 145 145 $command .= " -dbname $dbname" if defined $dbname; 146 146 -
trunk/ippScripts/scripts/phase5_subtract.pl
r11830 r11837 33 33 use Pod::Usage qw( pod2usage ); 34 34 35 my ($p5_id, $camera, $dbname, $workdir, $no_update );35 my ($p5_id, $camera, $dbname, $workdir, $no_update, $no_op); 36 36 GetOptions( 37 37 'p5_id|d=s' => \$p5_id, # Phase 5 identifier … … 39 39 'dbname|d=s' => \$dbname, # Database name 40 40 'workdir|w=s' => \$workdir, # Working directory, for output files 41 'no-update' => \$no_update, 41 'no-update' => \$no_update, # Don't update the database? 42 'no-op' => \$no_op, # Don't do any operations? 42 43 ) or pod2usage( 2 ); 43 44 … … 61 62 62 63 # Get list of components for subtraction 64 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 63 65 my $files; 64 66 { 65 my $command = "$p5tool -inputscfile -p5_id $p 4_id";67 my $command = "$p5tool -inputscfile -p5_id $p5_id"; 66 68 $command .= " -dbname $dbname" if defined $dbname; 67 69 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 116 118 117 119 my $outputName = $outputRoot . ".fits"; 118 # my $bin1Name = $ipprc->filename("PPIMAGE.BIN1", $outputRoot, $class_id);119 # my $bin2Name = $ipprc->filename("PPIMAGE.BIN2", $outputRoot, $class_id);120 #my $outputStats = $outputRoot . '.stats';120 my $bin1Name = $ipprc->filename("PPIMAGE.BIN1", $outputRoot); 121 my $bin2Name = $ipprc->filename("PPIMAGE.BIN2", $outputRoot); 122 my $outputStats = $outputRoot . '.stats'; 121 123 122 124 # Perform subtraction 123 { 125 my $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 126 unless ($no_op) { 124 127 my $command = "$pois $template $input $outputName"; # Command to run pois 125 128 … … 134 137 # &my_die("Couldn't find expected output file: $bin2Name", $p5_id, $PS_EXIT_SYS_ERROR) unless -f $bin2Name; 135 138 # &my_die("Couldn't find expected output file: $outputStats", $p5_id, $PS_EXIT_SYS_ERROR) unless -f $outputStats; 136 } 137 138 # Get the statistics on the residual image 139 if (0) { ### Disabled because pois doesn't output stats yet 140 my $stats; # Statistics from ppImage 141 { 139 140 # Get the statistics on the residual image 141 if (0) { ### Disabled because pois doesn't output stats yet 142 142 my $statsFile; # File handle 143 open $statsFile, $outputStats or &my_die("Can't open statistics file $outputStats: $!", $ det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR);143 open $statsFile, $outputStats or &my_die("Can't open statistics file $outputStats: $!", $p5_id, $PS_EXIT_SYS_ERROR); 144 144 my @contents = <$statsFile>; # Contents of file 145 close $statsFile; 146 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 145 close $statsFile; 147 146 my $metadata = $mdcParser->parse(join "", @contents) or 148 &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 149 $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 150 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 147 &my_die("Unable to parse metadata config doc", $p5_id, $PS_EXIT_PROG_ERROR); 148 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $p5_id, $PS_EXIT_PROG_ERROR); 151 149 } 152 150 } … … 154 152 # Add the processed file to the database 155 153 $outputName = $ipprc->convert_filename_relative( $outputName ); 154 155 my $bg = ($stats->bg_mean() or 'NAN'); 156 my $bg_stdev = ($stats->bg_stdev() or 'NAN'); 157 156 158 unless ($no_update) { 157 159 158 160 # Add the subtraction result 159 161 { 160 my $command = "$p5tool -adddiffscfile -p5_id $p5_id -uri $outputName -b1_uri $outputRoot"; # Command to run p5tool 162 my $command = "$p5tool -adddiffscfile -p5_id $p5_id -uri $outputName -b1_uri $outputRoot"; 163 $command .= " -bg $bg -bg_stdev $bg_stdev"; 161 164 $command .= " -dbname $dbname" if defined $dbname; 162 163 if (0) { ### Disabled because no statistics yet164 $command .= " -bg " . $stats->bg_mean();165 $command .= " -bg_stdev " . $stats->bg_stdev();166 }167 165 168 166 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 170 168 unless ($success) { 171 169 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 172 &my_die("Unable to perform p5tool -adddiffscfile: $error_code", $p5_id, $ iter, $exp_tag, $class_id, $error_code);170 &my_die("Unable to perform p5tool -adddiffscfile: $error_code", $p5_id, $error_code); 173 171 } 174 172 … … 199 197 200 198 warn($msg); 201 if ($ det_id and $iter and $exp_tagand not $no_update) {199 if ($p5_id and not $no_update) { 202 200 my $command = "$p5tool -updaterun -p5_id $p5_id -state stop -code $exit_code"; 203 201 $command .= " -dbname $dbname" if defined $dbname;
Note:
See TracChangeset
for help on using the changeset viewer.
