Changeset 8763
- Timestamp:
- Sep 6, 2006, 4:32:51 PM (20 years ago)
- Location:
- trunk/ippScripts/scripts
- Files:
-
- 6 edited
-
detrend_create_resid.pl (modified) (6 diffs)
-
detrend_process.pl (modified) (6 diffs)
-
detrend_reject_exp.pl (modified) (7 diffs)
-
detrend_reject_imfile.pl (modified) (9 diffs)
-
detrend_stack.pl (modified) (6 diffs)
-
phase0imfile.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_create_resid.pl
r8715 r8763 3 3 use warnings; 4 4 use strict; 5 6 use vars qw( $VERSION ); 7 $VERSION = '0.01'; 5 8 6 9 use IPC::Cmd qw( can_run run ); … … 9 12 use Data::Dumper; 10 13 14 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 15 use Pod::Usage qw( pod2usage ); 16 17 my ($det_id, $iter, $exp_id, $class_id, $det_type, $detrend, 18 $input_uri, $output_uri); 19 GetOptions( 20 'det_id|d=s' => \$det_id, 21 'iteration=s' => \$iter, 22 'exp_id|e=s' => \$exp_id, 23 'class_id|i=s' => \$class_id, 24 'det_type|t=s' => \$det_type, 25 'detrend=s' => \$detrend, 26 'input_uri|u=s' => \$input_uri, 27 'output_uri|o=s' => \$output_uri, 28 ) or pod2usage( 2 ); 29 30 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 31 pod2usage( 32 -msg => "Required options: --det_id --iteration --exp_id --class_id --det_type --detrend --input_uri --output_uri", 33 -exitval => 3, 34 ) unless defined $det_id 35 and defined $iter 36 and defined $exp_id 37 and defined $class_id 38 and defined $det_type 39 and defined $detrend 40 and defined $input_uri 41 and defined $output_uri; 11 42 12 43 # Recipes to use, as a function of the detrend type … … 34 65 use constant DELETE_STATS => 0; # Delete the statistics file when done? 35 66 36 # Parse the command-line arguments37 if (scalar @ARGV != 8) {38 die "Apply a stacked detrend image to an individual detrend.\n\n" .39 "Usage: $0 DET_ID ITERATION EXP_ID CLASS_ID DETREND_TYPE DETREND.fits INPUT.fits OUTPUT_ROOT\n\n";40 }41 my $detId = shift @ARGV; # Detrend ID42 my $iter = shift @ARGV; # Iteration43 my $expId = shift @ARGV; # Exposure ID44 my $classId = shift @ARGV; # Class ID45 my $detType = shift @ARGV; # Detrend type46 my $detrend = shift @ARGV; # The detrend frame to apply47 my $input = shift @ARGV; # Input FITS file48 my $output = shift @ARGV; # Output root name49 50 67 # Look for programs we need 51 68 my $missing_tools; … … 55 72 56 73 # Recipe to use in processing 57 my $recipe = RECIPES->{$det Type};58 die "Unrecognised detrend type: $det Type\n" if not defined $recipe;74 my $recipe = RECIPES->{$det_type}; 75 die "Unrecognised detrend type: $det_type\n" if not defined $recipe; 59 76 # Detrend to use in processing 60 my $detFlag = DETRENDS->{$det Type};61 die "Unrecognised detrend type: $det Type\n" if not defined $detFlag;77 my $detFlag = DETRENDS->{$det_type}; 78 die "Unrecognised detrend type: $det_type\n" if not defined $detFlag; 62 79 # Prefix to use for filename 63 my $prefix = PREFIX->{$det Type};64 die "Unrecognised detrend type: $det Type\n" if not defined $prefix;80 my $prefix = PREFIX->{$det_type}; 81 die "Unrecognised detrend type: $det_type\n" if not defined $prefix; 65 82 66 83 ### Output file names --- must match camera configuration! 67 my $outputRoot = $prefix . '_' . $output ;68 my $outputName = $outputRoot . '.' . $class Id . '.fit';69 my $outputStats = $outputRoot . '.' . $class Id . '.stats';70 my $bin1Name = $outputRoot . '.' . $class Id . '.b1.fit';71 my $bin2Name = $outputRoot . '.' . $class Id . '.b2.fit';84 my $outputRoot = $prefix . '_' . $output_uri; 85 my $outputName = $outputRoot . '.' . $class_id . '.fit'; 86 my $outputStats = $outputRoot . '.' . $class_id . '.stats'; 87 my $bin1Name = $outputRoot . '.' . $class_id . '.b1.fit'; 88 my $bin2Name = $outputRoot . '.' . $class_id . '.b2.fit'; 72 89 73 90 # Run ppImage 74 91 { 75 my $command = "$ppImage -file $input $outputRoot -recipe PPIMAGE $recipe" .92 my $command = "$ppImage -file $input_uri $outputRoot -recipe PPIMAGE $recipe" . 76 93 " -stat $outputStats $detFlag $detrend"; # Command to run ppImage 77 94 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 78 95 run(command => $command, verbose => 1); 79 die "Unable to perform ppImage on $input : $error_code\n" if not $success;96 die "Unable to perform ppImage on $input_uri: $error_code\n" if not $success; 80 97 die "Couldn't find expected output file: $outputName\n" if not -f $outputName; 81 98 die "Couldn't find expected output file: $bin1Name\n" if not -f $bin1Name; … … 99 116 # Add the processed file to the database 100 117 { 101 my $command = "$dettool -addresidimfile -det_id $det Id -iteration $iter -exp_id $expId " .102 "-class_id $class Id -recip $recipe -uri $outputName -b1_uri $bin1Name " .118 my $command = "$dettool -addresidimfile -det_id $det_id -iteration $iter -exp_id $exp_id " . 119 "-class_id $class_id -recip $recipe -uri $outputName -b1_uri $bin1Name " . 103 120 "-b2_uri $bin2Name"; # Command to run dettool 104 121 $command .= " -bg " . $stats->bg_mean(); … … 108 125 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 109 126 run(command => $command, verbose => 1); 110 die "Unable to perform dettool -addprocessed for $det Id/$expId/$classId: $error_code\n"127 die "Unable to perform dettool -addprocessed for $det_id/$exp_id/$class_id: $error_code\n" 111 128 if not $success; 112 129 } 113 130 114 unlink "$output .stats" if DELETE_STATS;131 unlink "$output_uri.stats" if DELETE_STATS; 115 132 116 133 __END__ -
trunk/ippScripts/scripts/detrend_process.pl
r8715 r8763 4 4 use strict; 5 5 6 use vars qw( $VERSION ); 7 $VERSION = '0.01'; 8 6 9 use IPC::Cmd qw( can_run run ); 7 10 use PS::IPP::Metadata::Config; 8 11 use PS::IPP::Metadata::Stats; 9 use Data::Dumper;10 12 13 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 14 use Pod::Usage qw( pod2usage ); 15 16 my ($det_id, $exp_id, $class, $class_id, $det_type, $input_uri, $output_uri); 17 GetOptions( 18 'det_id|d=s' => \$det_id, 19 'exp_id|e=s' => \$exp_id, 20 'class=s' => \$class, # unused 21 'class_id|i=s' => \$class_id, 22 'det_type|t=s' => \$det_type, 23 'input_uri|u=s' => \$input_uri, 24 'output_uri|o=s' => \$output_uri, 25 ) or pod2usage( 2 ); 26 27 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 28 pod2usage( 29 -msg => "Required options: --det_id --exp_id --class_id --det_type --input_uri --output_uri", 30 -exitval => 3, 31 ) unless defined $det_id 32 and defined $exp_id 33 and defined $class_id 34 and defined $det_type 35 and defined $input_uri 36 and defined $output_uri; 11 37 12 38 # Recipes to use, as a function of the detrend type … … 26 52 use constant DELETE_STATS => 0; # Delete the statistics file when done? 27 53 28 # Parse the command-line arguments29 if (scalar @ARGV != 6) {30 die "Perform detrend processing at the imfile level.\n\n" .31 "Usage: $0 DET_ID EXP_ID CLASS_ID DETREND_TYPE INPUT.fits OUTPUT_ROOT\n\n";32 }33 my $detId = shift @ARGV; # Detrend ID34 my $expId = shift @ARGV; # Exposure ID35 my $classId = shift @ARGV; # Class ID36 my $detType = shift @ARGV; # Detrend type37 my $input = shift @ARGV; # Input FITS file38 my $output = shift @ARGV; # Output root name39 40 54 # Look for programs we need 41 55 my $missing_tools; … … 45 59 46 60 # Recipe to use in processing 47 my $recipe = RECIPES->{$det Type};48 die "Unrecognised detrend type: $det Type\n" if not defined $recipe;49 die "Unrecognised detrend type: $det Type\n" if not defined PREFIX->{$detType};61 my $recipe = RECIPES->{$det_type}; 62 die "Unrecognised detrend type: $det_type\n" if not defined $recipe; 63 die "Unrecognised detrend type: $det_type\n" if not defined PREFIX->{$det_type}; 50 64 51 65 ### Output file name --- must match camera configuration! 52 my $outputRoot = PREFIX->{$det Type} . '_' . $output;53 my $outputName = $outputRoot . '.' . $class Id ;66 my $outputRoot = PREFIX->{$det_type} . '_' . $output_uri; 67 my $outputName = $outputRoot . '.' . $class_id ; 54 68 my $outputImage = $outputName . '.fit'; 55 69 my $outputStats = $outputName . '.stats'; … … 57 71 # Run ppImage 58 72 { 59 my $command = "$ppImage -file $input $outputRoot -recipe PPIMAGE $recipe" .73 my $command = "$ppImage -file $input_uri $outputRoot -recipe PPIMAGE $recipe" . 60 74 " -stat $outputStats"; # Command to run ppImage 61 75 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 62 76 run(command => $command, verbose => 1); 63 die "Unable to perform ppImage on $input : $error_code\n" if not $success;77 die "Unable to perform ppImage on $input_uri: $error_code\n" if not $success; 64 78 die "Couldn't find expected output file: $outputImage\n" if not -f $outputImage; 65 79 } … … 81 95 # Add the processed file to the database 82 96 { 83 my $command = "$dettool -addprocessed -det_id $det Id -exp_id $expId " .84 "-class_id $class Id -recip $recipe -uri $outputImage"; # Command to run dettool97 my $command = "$dettool -addprocessed -det_id $det_id -exp_id $exp_id " . 98 "-class_id $class_id -recip $recipe -uri $outputImage"; # Command to run dettool 85 99 $command .= " -bg " . $stats->bg_mean(); 86 100 $command .= " -bg_stdev " . $stats->bg_stdev(); … … 89 103 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 90 104 run(command => $command, verbose => 1); 91 die "Unable to perform dettool -addprocessed for $det Id/$expId/$classId: $error_code\n"105 die "Unable to perform dettool -addprocessed for $det_id/$exp_id/$class_id: $error_code\n" 92 106 if not $success; 93 107 } -
trunk/ippScripts/scripts/detrend_reject_exp.pl
r8715 r8763 4 4 use strict; 5 5 6 use vars qw( $VERSION ); 7 $VERSION = '0.01'; 8 6 9 use IPC::Cmd qw( can_run run ); 7 10 use PS::IPP::Metadata::Config; 8 11 use PS::IPP::Metadata::List qw( parse_md_list ); 9 12 use Statistics::Descriptive; 10 use Data::Dumper; 13 14 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 15 use Pod::Usage qw( pod2usage ); 16 17 my ($det_id, $iter, $det_type); 18 GetOptions( 19 'det_id|d=s' => \$det_id, 20 'iteration=s' => \$iter, 21 'det_type|t=s' => \$det_type, 22 ) or pod2usage( 2 ); 23 24 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 25 pod2usage( 26 -msg => "Required options: --det_id --exp_id --class_id --det_type --input_uri --output_uri", 27 -exitval => 3, 28 ) unless defined $det_id 29 and defined $iter 30 and defined $det_type; 31 32 my $detType = shift @ARGV; # Detrend type 11 33 12 34 # Rejection threshold for the mean, in terms of the standard deviation … … 34 56 }; 35 57 36 # Parse command-line arguments37 die "Reject exposures based on the sample of exposures.\n\n" .38 "Usage: $0 DET_ID ITER DETREND_TYPE\n\n"39 if scalar @ARGV != 3;40 my $detId = shift @ARGV; # Detrend ID41 my $iter = shift @ARGV; # Iteration number42 my $detType = shift @ARGV; # Detrend type43 44 58 # Look for programs we need 45 59 my $missing_tools; … … 51 65 my $exposures; # Array of exposures 52 66 { 53 my $command = "$dettool -residexp -det_id $det Id -iteration $iter"; # Command to run67 my $command = "$dettool -residexp -det_id $det_id -iteration $iter"; # Command to run 54 68 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 55 69 run(command => $command, verbose => 1); … … 82 96 83 97 # Check the existence of the required rejection levels as a function of detrend type 84 die "Unknown mean rejection level for detrend type $det Type\n"85 if not exists REJECT_MEAN->{$det Type};86 die "Unknown stdev rejection level for detrend type $det Type\n"87 if not exists REJECT_STDEV->{$det Type};88 die "Unknown mean stdev rejection level for detrend type $det Type\n"89 if not exists REJECT_MEAN_STDEV->{$det Type};98 die "Unknown mean rejection level for detrend type $det_type\n" 99 if not exists REJECT_MEAN->{$det_type}; 100 die "Unknown stdev rejection level for detrend type $det_type\n" 101 if not exists REJECT_STDEV->{$det_type}; 102 die "Unknown mean stdev rejection level for detrend type $det_type\n" 103 if not exists REJECT_MEAN_STDEV->{$det_type}; 90 104 91 105 # Go through again to do rejection, and update the database for each exposure … … 93 107 for (my $i = 0; $i < scalar @means; $i++) { 94 108 my $expId = $expIds[$i]; # Exposure ID 95 my $command = "$dettool -updateresidexp -det_id $det Id -iteration $iter -exp_id $expId"; # Command to run109 my $command = "$dettool -updateresidexp -det_id $det_id -iteration $iter -exp_id $expId"; # Command to run 96 110 my $reject = 0; # Reject this exposure? 97 if (defined REJECT_MEAN->{$det Type} and111 if (defined REJECT_MEAN->{$det_type} and 98 112 defined $meanStats->standard_deviation() and 99 113 $meanStats->standard_deviation() > 0 and 100 ($means[$i] - $meanStats->mean()) / $meanStats->standard_deviation() > REJECT_MEAN->{$det Type}) {114 ($means[$i] - $meanStats->mean()) / $meanStats->standard_deviation() > REJECT_MEAN->{$det_type}) { 101 115 print "Rejecting $expId based on bad mean: " . 102 116 (($means[$i] - $meanStats->mean()) / $meanStats->standard_deviation()) . 103 " vs " . REJECT_MEAN->{$det Type} . "\n";117 " vs " . REJECT_MEAN->{$det_type} . "\n"; 104 118 $reject = 1; 105 } elsif (defined REJECT_STDEV->{$det Type} and119 } elsif (defined REJECT_STDEV->{$det_type} and 106 120 defined $stdevStats->standard_deviation() and 107 121 $stdevStats->standard_deviation() > 0 and 108 122 ($stdevs[$i] - $stdevStats->mean()) / $stdevStats->standard_deviation() > 109 REJECT_STDEV->{$det Type}) {123 REJECT_STDEV->{$det_type}) { 110 124 print "Rejecting $expId based on bad stdev: " . 111 125 (($stdevs[$i] - $stdevStats->mean()) / $stdevStats->standard_deviation()) . 112 " vs " . REJECT_STDEV->{$det Type} . "\n";126 " vs " . REJECT_STDEV->{$det_type} . "\n"; 113 127 $reject = 1; 114 } elsif (defined REJECT_MEAN_STDEV->{$det Type} and128 } elsif (defined REJECT_MEAN_STDEV->{$det_type} and 115 129 defined $meanStdevStats->standard_deviation() and 116 130 $meanStdevStats->standard_deviation() > 0 and 117 131 ($meanStdevs[$i] - $meanStdevStats->mean()) / $meanStdevStats->standard_deviation() > 118 REJECT_MEAN_STDEV->{$det Type}) {132 REJECT_MEAN_STDEV->{$det_type}) { 119 133 print "Rejecting $expId based on bad stdev: " . 120 134 (($meanStdevs[$i] - $meanStdevStats->mean()) / $meanStdevStats->standard_deviation()) . 121 " vs " . REJECT_MEAN_STDEV->{$det Type} . "\n";135 " vs " . REJECT_MEAN_STDEV->{$det_type} . "\n"; 122 136 $reject = 1; 123 137 } … … 147 161 # Put the result into the database 148 162 { 149 my $command = "$dettool -adddetrunsummary -det_id $det Id -iteration $iter " .163 my $command = "$dettool -adddetrunsummary -det_id $det_id -iteration $iter " . 150 164 "-bg " . $meanStats->mean() . " -bg_stdev " . $stdevStats->mean() . 151 165 " -bg_mean_stdev " . $meanStdevStats->mean(); … … 159 173 # Re-run processing if required 160 174 { 161 my $command = "$dettool -updatedetrun -det_id $det Id";175 my $command = "$dettool -updatedetrun -det_id $det_id"; 162 176 if ($stop) { 163 177 $command .= ' -stop'; -
trunk/ippScripts/scripts/detrend_reject_imfile.pl
r8715 r8763 3 3 use warnings; 4 4 use strict; 5 6 use vars qw( $VERSION ); 7 $VERSION = '0.01'; 5 8 6 9 use IPC::Cmd qw( can_run run ); … … 8 11 use PS::IPP::Metadata::List qw( parse_md_list ); 9 12 use Statistics::Descriptive; 10 use Data::Dumper; 13 14 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 15 use Pod::Usage qw( pod2usage ); 16 17 my ($det_id, $iter, $exp_id, $det_type); 18 GetOptions( 19 'det_id|d=s' => \$det_id, 20 'iteration=s' => \$iter, 21 'exp_id|e=s' => \$exp_id, 22 'det_type|t=s' => \$det_type, 23 ) or pod2usage( 2 ); 24 25 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 26 pod2usage( 27 -msg => "Required options: --det_id --iteration --exp_id --det_type", 28 -exitval => 3, 29 ) unless defined $det_id 30 and defined $iter 31 and defined $exp_id 32 and defined $det_type; 11 33 12 34 use constant RECIPE => 'PPIMAGE_J'; # Recipe to use for ppImage to make JPEGs … … 52 74 53 75 54 # Parse command-line arguments55 die "Reject exposures based on the imfile.\n\n" .56 "Usage: $0 DET_ID ITER EXP_ID DETREND_TYPE\n\n"57 if scalar @ARGV != 4;58 my $detId = shift @ARGV; # Detrend ID59 my $iter = shift @ARGV; # Iteration number60 my $expId = shift @ARGV; # Exposure ID61 my $detType = shift @ARGV; # Detrend type62 63 76 # Look for programs we need 64 77 my $missing_tools; … … 72 85 my $files; # Array of component files 73 86 { 74 my $command = "$dettool -residimfile -det_id $det Id -iteration $iter -exp_id $expId"; # Command to run87 my $command = "$dettool -residimfile -det_id $det_id -iteration $iter -exp_id $exp_id"; # Command to run 75 88 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 76 89 run(command => $command, verbose => 1); … … 82 95 83 96 # Generate the file list, and get the statistics 84 my $outputName = $det Type . '_' . $detId . '_' . $iter; # Root output name97 my $outputName = $det_type . '_' . $det_id . '_' . $iter; # Root output name 85 98 my $list1Name = $outputName . '_jpeg1.list'; # Name for the input file list for binning 1 86 99 my $list2Name = $outputName . '_jpeg2.list'; # Name for the input file list for binning 2 … … 119 132 120 133 # Check the existence of the required rejection levels as a function of detrend type 121 die "Unknown expected mean for detrend type $det Type\n"122 if not exists EXPECTED_MEAN->{$det Type};123 die "Unknown individual mean rejection level for detrend type $det Type\n"124 if not exists REJECT_INDIVIDUAL_MEAN->{$det Type};125 die "Unknown individual stdev rejection level for detrend type $det Type\n"126 if not exists REJECT_INDIVIDUAL_STDEV->{$det Type};127 die "Unknown sample mean rejection level for detrend type $det Type\n"128 if not exists REJECT_SAMPLE_MEAN->{$det Type};129 die "Unknown sample stdev rejection level for detrend type $det Type\n"130 if not exists REJECT_SAMPLE_STDEV->{$det Type};134 die "Unknown expected mean for detrend type $det_type\n" 135 if not exists EXPECTED_MEAN->{$det_type}; 136 die "Unknown individual mean rejection level for detrend type $det_type\n" 137 if not exists REJECT_INDIVIDUAL_MEAN->{$det_type}; 138 die "Unknown individual stdev rejection level for detrend type $det_type\n" 139 if not exists REJECT_INDIVIDUAL_STDEV->{$det_type}; 140 die "Unknown sample mean rejection level for detrend type $det_type\n" 141 if not exists REJECT_SAMPLE_MEAN->{$det_type}; 142 die "Unknown sample stdev rejection level for detrend type $det_type\n" 143 if not exists REJECT_SAMPLE_STDEV->{$det_type}; 131 144 132 145 # Reject based on the individual stats … … 135 148 for (my $i = 0; $i < scalar @means; $i++) { 136 149 my $mean = $means[$i]; # Mean for this component 137 $mean -= EXPECTED_MEAN->{$det Type} if defined EXPECTED_MEAN->{$detType};150 $mean -= EXPECTED_MEAN->{$det_type} if defined EXPECTED_MEAN->{$det_type}; 138 151 my $stdev = $stdevs[$i]; # Stdev for this component 139 152 140 if (defined REJECT_INDIVIDUAL_MEAN->{$det Type}153 if (defined REJECT_INDIVIDUAL_MEAN->{$det_type} 141 154 and $stdev > 0 and 142 $mean / $stdev > REJECT_INDIVIDUAL_MEAN->{$det Type}) {155 $mean / $stdev > REJECT_INDIVIDUAL_MEAN->{$det_type}) { 143 156 print "Rejecting exposure based on bad individual mean for component $i: " . 144 ($mean / $stdev) . " vs " . REJECT_INDIVIDUAL_MEAN->{$det Type} . "\n";157 ($mean / $stdev) . " vs " . REJECT_INDIVIDUAL_MEAN->{$det_type} . "\n"; 145 158 $reject = 1; 146 159 last; 147 } elsif (defined REJECT_INDIVIDUAL_STDEV->{$det Type} and148 $stdev > REJECT_INDIVIDUAL_STDEV->{$det Type}) {160 } elsif (defined REJECT_INDIVIDUAL_STDEV->{$det_type} and 161 $stdev > REJECT_INDIVIDUAL_STDEV->{$det_type}) { 149 162 print "Rejecting exposure based on bad individual stdev for component $i: " . 150 $stdev . " vs " . REJECT_INDIVIDUAL_STDEV->{$det Type} . "\n";163 $stdev . " vs " . REJECT_INDIVIDUAL_STDEV->{$det_type} . "\n"; 151 164 $reject = 1; 152 165 last; … … 165 178 } 166 179 my $meanStdev = $stdevStats->mean(); # Mean of the sample of stdevs 167 if (defined REJECT_SAMPLE_MEAN->{$det Type} and180 if (defined REJECT_SAMPLE_MEAN->{$det_type} and 168 181 $stdev != 0 and 169 $mean / $stdev > REJECT_SAMPLE_MEAN->{$det Type}) {182 $mean / $stdev > REJECT_SAMPLE_MEAN->{$det_type}) { 170 183 print "Rejecting exposure based on bad mean: " . ($mean / $stdev) . " vs " . 171 REJECT_SAMPLE_MEAN->{$det Type} . "\n";184 REJECT_SAMPLE_MEAN->{$det_type} . "\n"; 172 185 $reject = 1; 173 } elsif (defined REJECT_SAMPLE_STDEV->{$det Type} and174 $meanStdev > REJECT_SAMPLE_STDEV->{$det Type}) {186 } elsif (defined REJECT_SAMPLE_STDEV->{$det_type} and 187 $meanStdev > REJECT_SAMPLE_STDEV->{$det_type}) { 175 188 print "Rejecting exposure based on bad mean stdev: " . $meanStdev . " vs " . 176 REJECT_SAMPLE_STDEV->{$det Type} . "\n";189 REJECT_SAMPLE_STDEV->{$det_type} . "\n"; 177 190 $reject = 1; 178 191 } … … 180 193 # Add the result into the database 181 194 { 182 my $command = "$dettool -addresidexp -det_id $det Id -iteration $iter -exp_id $expId " .195 my $command = "$dettool -addresidexp -det_id $det_id -iteration $iter -exp_id $exp_id " . 183 196 "-recip " . RECIPE() . " -b1_uri $jpeg1Name -b2_uri $jpeg2Name -bg $mean -bg_stdev $stdev " . 184 197 "-bg_mean_stdev $meanStdev"; # Command to run -
trunk/ippScripts/scripts/detrend_stack.pl
r8734 r8763 4 4 use strict; 5 5 6 use vars qw( $VERSION ); 7 $VERSION = '0.01'; 8 6 9 use IPC::Cmd qw( can_run run ); 7 10 use PS::IPP::Metadata::Config; 8 11 use PS::IPP::Metadata::List qw( parse_md_list ); 9 12 use PS::IPP::Metadata::Stats; 10 use Data::Dumper; 13 14 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 15 use Pod::Usage qw( pod2usage ); 16 17 my ($det_id, $iter, $class_id, $det_type); 18 GetOptions( 19 'det_id|d=s' => \$det_id, 20 'iteration=s' => \$iter, 21 'class_id|i=s' => \$class_id, 22 'det_type|t=s' => \$det_type, 23 ) or pod2usage( 2 ); 24 25 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 26 pod2usage( 27 -msg => "Required options: --det_id --iteration --class_id --det_type", 28 -exitval => 3, 29 ) unless defined $det_id 30 and defined $iter 31 and defined $class_id 32 and defined $det_type; 11 33 12 34 # Recipes to use as a function of detrend type … … 24 46 }; 25 47 26 # Parse command-line arguments 27 die "Stack detrends.\n\n" . 28 "Usage: $0 DET_ID ITER CLASS_ID DETREND_TYPE\n\n" 29 if scalar @ARGV != 4; 30 my $detId = shift @ARGV; # Detrend ID 31 my $iter = shift @ARGV; # Iteration number 32 my $classId = shift @ARGV; # Class ID 33 my $detType = shift @ARGV; # Detrend type 34 35 die "Unrecognised detrend type: $detType\n" if not defined RECIPES->{$detType}; 36 my $recipe = RECIPES->{$detType}; # Recipe to use in stacking 48 die "Unrecognised detrend type: $det_type\n" if not defined RECIPES()->{$det_type}; 49 my $recipe = RECIPES()->{$det_type}; # Recipe to use in stacking 37 50 38 51 # Look for programs we need … … 47 60 my $files; # Array of files to be stacked 48 61 { 49 my $command = "$dettool -processed -det_id $det Id -iteration $iter -class_id $classId"; # Command to run62 my $command = "$dettool -processed -det_id $det_id -iteration $iter -class_id $class_id"; # Command to run 50 63 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 51 64 run(command => $command, verbose => 1); … … 57 70 58 71 # Stack the files 59 my $output = $det Type . '_' . $classId . '_' . $detId . '_' . $iter . '.fit'; # Output name60 my $outputStats = $det Type . '_' . $classId . '_' . $detId . '_' . $iter . '.stats'; # Statistics name72 my $output = $det_type . '_' . $class_id . '_' . $det_id . '_' . $iter . '.fit'; # Output name 73 my $outputStats = $det_type . '_' . $class_id . '_' . $det_id . '_' . $iter . '.stats'; # Statistics name 61 74 { 62 75 my $command = "$ppMerge $output"; # Command to run … … 66 79 } 67 80 $command .= " -recipe PPMERGE $recipe"; 68 $command .= ' -type ' . uc($det Type); # Type of stacking to perform81 $command .= ' -type ' . uc($det_type); # Type of stacking to perform 69 82 $command .= " -stats $outputStats"; # Statistics output filename 70 83 … … 95 108 # Add the resultant into the database 96 109 { 97 my $command = "$dettool -addstacked -det_id $det Id -iteration $iter -class_id $classId" .110 my $command = "$dettool -addstacked -det_id $det_id -iteration $iter -class_id $class_id" . 98 111 " -uri $output -recip $recipe"; # Command to run 99 112 $command .= ' -bg ' . $stats->bg_mean(); 100 113 $command .= ' -bg_stdev ' . $stats->bg_stdev(); 101 114 $command .= ' -bg_mean_stdev ' . $stats->bg_mean_stdev(); 102 $command .= ' -pleasenormalize' if NORMALISE()->{$det Type};115 $command .= ' -pleasenormalize' if NORMALISE()->{$det_type}; 103 116 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 104 117 run(command => $command, verbose => 1); -
trunk/ippScripts/scripts/phase0imfile.pl
r8715 r8763 4 4 use strict; 5 5 6 use vars qw( $VERSION ); 7 $VERSION = '0.01'; 8 6 9 use IPC::Cmd qw( can_run run ); 7 10 use PS::IPP::Metadata::Config; 8 11 use PS::IPP::Metadata::Stats; 12 use PS::IPP::Metadata::StatsFilter; 9 13 use Data::Dumper; 14 15 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 16 use Pod::Usage qw( pod2usage ); 17 18 my ($exp_id, $class, $class_id, $uri); 19 20 GetOptions( 21 'exp_id|e=s' => \$exp_id, 22 'class|c=s' => \$class, 23 'class_id|i=s' => \$class_id, 24 'uri|u=s' => \$uri, 25 ) or pod2usage( 2 ); 26 27 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 28 pod2usage( 29 -msg => "Required options: --exp_id --class --class_id --uri", 30 -exitval => 3, 31 ) unless defined $exp_id 32 and defined $class 33 and defined $class_id 34 and defined $uri; 35 36 # XXX the uri should be processed either here or by ppImage 37 my $file = $uri; 10 38 11 39 use constant RECIPE => "PPSTATS_PHASE0"; # Recipe to use for ppStats … … 40 68 use constant P0TOOL_BG_MEAN_STDEV => '-bg_mean_stdev'; # Switch to add the bg mean stdev 41 69 42 # Parse command-line arguments43 if (scalar @ARGV == 0 || scalar @ARGV > 3) {44 die "Perform phase 0 processing at the imfile level.\n\n" .45 "Usage: $0 EXP_ID CLASS_ID FILE.fits\n\n";46 }47 48 my $expid = shift @ARGV; # Exposure identifier49 my $classid = shift @ARGV; # Class identifier50 my $file = shift @ARGV; # Input filename51 52 53 70 # Look for programs we need 54 71 my $missing_tools; … … 63 80 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 64 81 run(command => $command, verbose => 1); 65 die "Unable to perform ppStats on exposure id $exp id: $error_code\n" if not $success;82 die "Unable to perform ppStats on exposure id $exp_id: $error_code\n" if not $success; 66 83 67 84 # Parse the output … … 69 86 my $metadata = $mdcParser->parse(join "", @$stdout_buf) 70 87 or die "unable to parse metadata config doc"; 88 my $statsfilter = PS::IPP::Metadata::StatsFilter->new; 89 $metadata = $statsfilter->filter($metadata) 90 or die "failed to filter stats document"; 71 91 my @constants = keys %{CONSTANTS()}; # List of constants to parse out 72 92 my @variables = keys %{VARIABLES()}; # List of variables to parse out … … 77 97 # Push the results into the database 78 98 { 79 my $command = $p0tool . " " . P0TOOL_MODE() . " " . P0TOOL_EXPID() . " " . $exp id . " " .80 P0TOOL_CLASSID() . " " . $class id; # Command to run p0tool99 my $command = $p0tool . " " . P0TOOL_MODE() . " " . P0TOOL_EXPID() . " " . $exp_id . " " . 100 P0TOOL_CLASSID() . " " . $class_id; # Command to run p0tool 81 101 82 102 foreach my $constant (keys %{CONSTANTS()}) {
Note:
See TracChangeset
for help on using the changeset viewer.
