Changeset 17943
- Timestamp:
- Jun 5, 2008, 12:09:48 PM (18 years ago)
- Location:
- trunk/ippScripts/scripts
- Files:
-
- 7 edited
-
detrend_norm_apply.pl (modified) (9 diffs)
-
detrend_norm_exp.pl (modified) (7 diffs)
-
detrend_process_exp.pl (modified) (8 diffs)
-
detrend_reject_imfile.pl (modified) (27 diffs)
-
diff_skycell.pl (modified) (1 diff)
-
stack_skycell.pl (modified) (1 diff)
-
warp_skycell.pl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_norm_apply.pl
r17671 r17943 28 28 $no_update, $no_op ); 29 29 GetOptions( 30 'det_id|d=s' => \$det_id, # Detrend ID 31 'iteration|n=s' => \$iter, # Iteration32 'class_id|i=s' => \$class_id, # Class ID33 'value|v=s' => \$value, # Value to multiple (for normalisation)34 'input_uri|u=s' => \$input_uri, # Input file35 'camera|c=s' => \$camera, # Camera36 'det_type|t=s' => \$det_type, # Detrend type30 'det_id|d=s' => \$det_id, # Detrend ID 31 'iteration|n=s' => \$iter, # Iteration 32 'class_id|i=s' => \$class_id, # Class ID 33 'value|v=s' => \$value, # Value to multiple (for normalisation) 34 'input_uri|u=s' => \$input_uri, # Input file 35 'camera|c=s' => \$camera, # Camera 36 'det_type|t=s' => \$det_type, # Detrend type 37 37 'outroot|w=s' => \$outroot, # output file base name 38 'dbname|d=s' => \$dbname, # Database name38 'dbname|d=s' => \$dbname, # Database name 39 39 'verbose' => \$verbose, # Print to stdout 40 'no-update' => \$no_update, # Don't update the database41 'no-op' => \$no_op, # Don't do any operations40 'no-update' => \$no_update, # Don't update the database 41 'no-op' => \$no_op, # Don't do any operations 42 42 ) or pod2usage( 2 ); 43 43 44 44 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 45 45 pod2usage( -msg => "Required options: --det_id --iteration --class_id --value --input_uri --camera --det_type --outroot", 46 -exitval => 3) unless 47 defined $det_id and 48 defined $iter and 49 defined $class_id and 50 defined $value and 51 defined $input_uri and 52 defined $camera and 46 -exitval => 3) unless 47 defined $det_id and 48 defined $iter and 49 defined $class_id and 50 defined $value and 51 defined $input_uri and 52 defined $camera and 53 53 defined $det_type and 54 54 defined $outroot; … … 65 65 66 66 # values to extract from output metadata and the stats to calculate 67 my $STATS = 68 [ 67 my $STATS = 68 [ 69 69 # PPSTATS KEYWORD STATISTIC CHIPTOOL FLAG 70 70 { name => "ROBUST_MEDIAN", type => "mean", flag => "-bg", dtype => "float" }, … … 78 78 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 79 79 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 80 if ($missing_tools) { 80 if ($missing_tools) { 81 81 warn("Can't find required tools."); 82 exit($PS_EXIT_CONFIG_ERROR); 82 exit($PS_EXIT_CONFIG_ERROR); 83 83 } 84 84 … … 100 100 my $statsName = $ipprc->filename("PPIMAGE.STATS", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); 101 101 my $traceDest = $ipprc->filename("TRACE.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); 102 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR);102 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); 103 103 104 104 # Run normalisation … … 112 112 $command .= ' -isdark' if lc($det_type) eq 'dark'; 113 113 $command .= " -tracedest $traceDest -log $logDest"; 114 $command .= " -dbname $dbname" if defined $dbname; 114 115 115 116 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 116 run(command => $command, verbose => $verbose);117 run(command => $command, verbose => $verbose); 117 118 unless ($success) { 118 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);119 &my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $class_id, $error_code);119 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 120 &my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $class_id, $error_code); 120 121 } 121 122 &my_die("Can't find expected output file: $output", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($output); … … 123 124 &my_die("Can't find expected output file: $b2name", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($b2name); 124 125 &my_die("Can't find expected output file: $statsName", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($statsName); 125 126 126 127 # Get the statistics on the normalised image 127 128 my $statsFile; # File handle … … 132 133 133 134 # parse the statistics MDC file 134 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files135 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 135 136 my $metadata = $mdcParser->parse(join "", @contents); 136 137 unless ($metadata) { 137 &my_die("Unable to parse metadata config", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR);138 &my_die("Unable to parse metadata config", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR); 138 139 } 139 140 140 141 # extract the stats from the metadata 141 142 unless ($stats->parse($metadata)) { 142 &my_die("Unable to find all values in statistics output.", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR);143 &my_die("Unable to find all values in statistics output.", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR); 143 144 } 144 145 } … … 157 158 unless ($no_update) { 158 159 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 159 run(command => $command, verbose => $verbose);160 run(command => $command, verbose => $verbose); 160 161 unless ($success) { 161 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);162 warn("Unable to perform dettool -addnormalizedimfile: $error_code\n");163 exit($error_code);162 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 163 warn("Unable to perform dettool -addnormalizedimfile: $error_code\n"); 164 exit($error_code); 164 165 } 165 166 } else { … … 169 170 sub my_die 170 171 { 171 my $msg = shift; # Warning message on die172 my $det_id = shift; # Detrend identifier173 my $iter = shift; # Iteration174 my $class_id = shift; # Class identifier175 my $exit_code = shift; # Exit code to add172 my $msg = shift; # Warning message on die 173 my $det_id = shift; # Detrend identifier 174 my $iter = shift; # Iteration 175 my $class_id = shift; # Class identifier 176 my $exit_code = shift; # Exit code to add 176 177 177 178 carp($msg); 178 179 if (defined $det_id and defined $iter and defined $class_id and not $no_update) { 179 my $command = "$dettool -addnormalizedimfile";180 $command .= " -det_id $det_id";181 $command .= " -iteration $iter";182 $command .= " -class_id $class_id";183 $command .= " -code $exit_code";184 $command .= " -dbname $dbname" if defined $dbname;180 my $command = "$dettool -addnormalizedimfile"; 181 $command .= " -det_id $det_id"; 182 $command .= " -iteration $iter"; 183 $command .= " -class_id $class_id"; 184 $command .= " -code $exit_code"; 185 $command .= " -dbname $dbname" if defined $dbname; 185 186 system ($command); 186 187 } -
trunk/ippScripts/scripts/detrend_norm_exp.pl
r17671 r17943 28 28 my ($det_id, $iter, $det_type, $camera, $outroot, $dbname, $reduction, $verbose, $no_update, $no_op, $save_temps); 29 29 GetOptions( 30 'det_id|d=s' => \$det_id,31 'iteration|i=s' => \$iter,32 'camera|c=s' => \$camera,33 'det_type|t=s' => \$det_type,34 'outroot|w=s' => \$outroot, # output file base name35 'dbname|d=s' => \$dbname, # Database name36 'reduction|=s' => \$reduction,30 'det_id|d=s' => \$det_id, 31 'iteration|i=s' => \$iter, 32 'camera|c=s' => \$camera, 33 'det_type|t=s' => \$det_type, 34 'outroot|w=s' => \$outroot, # output file base name 35 'dbname|d=s' => \$dbname, # Database name 36 'reduction|=s' => \$reduction, 37 37 'verbose' => \$verbose, # Print to stdout 38 'no-update' => \$no_update,39 'no-op' => \$no_op,40 'save-temps' => \$save_temps, # Save temporary files?41 ) or pod2usage( 2 );38 'no-update' => \$no_update, 39 'no-op' => \$no_op, 40 'save-temps' => \$save_temps, # Save temporary files? 41 ) or pod2usage( 2 ); 42 42 43 43 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 44 44 pod2usage( -msg => "Required options: --det_id --iteration --camera --det_type --outroot", 45 -exitval => 3) unless 46 defined $det_id and 47 defined $iter and 48 defined $camera and 45 -exitval => 3) unless 46 defined $det_id and 47 defined $iter and 48 defined $camera and 49 49 defined $det_type and 50 50 defined $outroot; … … 65 65 # XXX -bg_mean_stdev should take stdev of bg_mean if bg_mean_stdev == 0 (B) 66 66 # XXX (A) if imfile.Ncomp > 1, (B) if imfile.Ncomp == 1 67 my $STATS = 68 [ 69 # KEYWORD STATISTIC CHIPTOOL FLAG70 { name => "bg", type => "mean", flag => "-bg", dtype => "float" },71 { name => "bg", type => "stdev", flag => "-bg_mean_stdev", dtype => "float" },72 { name => "bg_stdev", type => "rms", flag => "-bg_stdev", dtype => "float" },73 # { name => "bg_mean_stdev", type => "rms", flag => "-bg_mean_stdev" },74 ];67 my $STATS = 68 [ 69 # KEYWORD STATISTIC CHIPTOOL FLAG 70 { name => "bg", type => "mean", flag => "-bg", dtype => "float" }, 71 { name => "bg", type => "stdev", flag => "-bg_mean_stdev", dtype => "float" }, 72 { name => "bg_stdev", type => "rms", flag => "-bg_stdev", dtype => "float" }, 73 # { name => "bg_mean_stdev", type => "rms", flag => "-bg_mean_stdev" }, 74 ]; 75 75 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser 76 76 … … 79 79 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 80 80 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 81 if ($missing_tools) { 81 if ($missing_tools) { 82 82 warn("Can't find required tools."); 83 exit($PS_EXIT_CONFIG_ERROR); 83 exit($PS_EXIT_CONFIG_ERROR); 84 84 } 85 85 … … 90 90 $command .= " -dbname $dbname" if defined $dbname; 91 91 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 92 run(command => $command, verbose => $verbose);92 run(command => $command, verbose => $verbose); 93 93 unless ($success) { 94 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);95 &my_die("Unable to get list of normalized imfiles from dettool: $error_code", $det_id, $iter, $error_code);94 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 95 &my_die("Unable to get list of normalized imfiles from dettool: $error_code", $det_id, $iter, $error_code); 96 96 } 97 97 98 98 # convert stdout to a metadata 99 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files99 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 100 100 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 101 &my_die("Unable to parse metadata config doc", $det_id, $iter, $PS_EXIT_PROG_ERROR);101 &my_die("Unable to parse metadata config doc", $det_id, $iter, $PS_EXIT_PROG_ERROR); 102 102 103 103 # parse the file info in the metadata 104 104 $files = parse_md_list($metadata) or 105 &my_die("Unable to parse metadata list", $det_id, $iter, $PS_EXIT_PROG_ERROR);105 &my_die("Unable to parse metadata list", $det_id, $iter, $PS_EXIT_PROG_ERROR); 106 106 107 107 # parse the stats in the metadata 108 108 unless ($stats->parse($metadata)) { 109 &my_die("Unable to find all values in statistics output.\n", $det_id, $iter, $PS_EXIT_PROG_ERROR);109 &my_die("Unable to find all values in statistics output.\n", $det_id, $iter, $PS_EXIT_PROG_ERROR); 110 110 } 111 111 } … … 134 134 # Make the jpeg for binning 1 135 135 $command = "$ppImage -list $list1Name $outroot -recipe PPIMAGE $recipe1"; # Command to run 136 $command .= " -dbname $dbname" if defined $dbname; 136 137 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 137 run(command => $command, verbose => $verbose);138 run(command => $command, verbose => $verbose); 138 139 &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1Name); 139 140 140 141 # Make the jpeg for binning 2 141 142 $command = "$ppImage -list $list2Name $outroot -recipe PPIMAGE $recipe2"; # Command to run 143 $command .= " -dbname $dbname" if defined $dbname; 142 144 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 143 run(command => $command, verbose => $verbose);145 run(command => $command, verbose => $verbose); 144 146 &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2Name); 145 147 … … 158 160 unless ($no_update) { 159 161 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 160 run(command => $command, verbose => $verbose);162 run(command => $command, verbose => $verbose); 161 163 unless ($success) { 162 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);163 &my_die("Unable to perform dettool -addnormalizedexp: $error_code", $det_id, $iter, $error_code);164 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 165 &my_die("Unable to perform dettool -addnormalizedexp: $error_code", $det_id, $iter, $error_code); 164 166 } 165 167 } else { … … 170 172 { 171 173 my $msg = shift; # Warning message on die 172 my $det_id = shift; # Detrend identifier173 my $iter = shift; # Iteration174 my $det_id = shift; # Detrend identifier 175 my $iter = shift; # Iteration 174 176 my $exit_code = shift; # Exit code to add 175 177 176 178 carp($msg); 177 179 if (defined $det_id and defined $iter and not $no_update) { 178 my $command = "$dettool -addnormalizedexp";179 $command .= " -det_id $det_id";180 $command .= " -iteration $iter";181 $command .= " -code $exit_code";182 $command .= " -dbname $dbname" if defined $dbname;180 my $command = "$dettool -addnormalizedexp"; 181 $command .= " -det_id $det_id"; 182 $command .= " -iteration $iter"; 183 $command .= " -code $exit_code"; 184 $command .= " -dbname $dbname" if defined $dbname; 183 185 system ($command); 184 186 } -
trunk/ippScripts/scripts/detrend_process_exp.pl
r17671 r17943 45 45 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 46 46 pod2usage( -msg => "Required options: --det_id --det_type --exp_id --exp_tag --camera --outroot", 47 -exitval => 3) unless 48 defined $det_id and 49 defined $det_type and 50 defined $exp_id and 51 defined $exp_tag and 47 -exitval => 3) unless 48 defined $det_id and 49 defined $det_type and 50 defined $exp_id and 51 defined $exp_tag and 52 52 defined $camera and 53 53 defined $outroot; … … 68 68 # XXX -bg_mean_stdev should take stdev of bg_mean if bg_mean_stdev == 0 (B) 69 69 # XXX (A) if imfile.Ncomp > 1, (B) if imfile.Ncomp == 1 70 my $STATS = 71 [ 70 my $STATS = 71 [ 72 72 # KEYWORD STATISTIC CHIPTOOL FLAG 73 73 { name => "bg", type => "mean", flag => "-bg", dtype => "float" }, … … 82 82 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 83 83 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 84 if ($missing_tools) { 84 if ($missing_tools) { 85 85 warn("Can't find required tools."); 86 exit($PS_EXIT_CONFIG_ERROR); 86 exit($PS_EXIT_CONFIG_ERROR); 87 87 } 88 88 … … 93 93 $command .= " -dbname $dbname" if defined $dbname; 94 94 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 95 run(command => $command, verbose => $verbose);96 unless ($success) { 97 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);98 &my_die("Unable to perform dettool -processedimfile: $error_code", $det_id, $exp_id, $error_code);95 run(command => $command, verbose => $verbose); 96 unless ($success) { 97 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 98 &my_die("Unable to perform dettool -processedimfile: $error_code", $det_id, $exp_id, $error_code); 99 99 } 100 100 101 101 # convert stdout to a metadata 102 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files102 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 103 103 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 104 &my_die("Unable to parse metadata config doc", $det_id, $exp_id, $PS_EXIT_PROG_ERROR);104 &my_die("Unable to parse metadata config doc", $det_id, $exp_id, $PS_EXIT_PROG_ERROR); 105 105 106 106 # parse the file info in the metadata 107 107 $files = parse_md_list($metadata) or 108 &my_die("Unable to parse metadata list", $det_id, $exp_id, $PS_EXIT_PROG_ERROR);108 &my_die("Unable to parse metadata list", $det_id, $exp_id, $PS_EXIT_PROG_ERROR); 109 109 110 110 # parse the stats in the metadata 111 111 unless ($stats->parse($metadata)) { 112 &my_die("Unable to find all values in statistics output.\n", $det_id, $exp_id, $PS_EXIT_PROG_ERROR);112 &my_die("Unable to find all values in statistics output.\n", $det_id, $exp_id, $PS_EXIT_PROG_ERROR); 113 113 } 114 114 } … … 138 138 # Make the jpeg for binning 1 139 139 $command = "$ppImage -list $list1Name $outroot -recipe PPIMAGE $recipe1"; # Command to run 140 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 141 run(command => $command, verbose => $verbose); 142 unless ($success) { 143 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 144 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_id, $error_code); 140 $command .= " -dbname $dbname" if defined $dbname; 141 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 142 run(command => $command, verbose => $verbose); 143 unless ($success) { 144 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 145 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_id, $error_code); 145 146 } 146 147 &my_die("Unable to find expected output file: $jpeg1", $det_id, $exp_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1); 147 148 148 149 # Make the jpeg for binning 2 149 150 $command = "$ppImage -list $list2Name $outroot -recipe PPIMAGE $recipe2"; # Command to run 150 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 151 run(command => $command, verbose => $verbose); 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_id, $error_code); 151 $command .= " -dbname $dbname" if defined $dbname; 152 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 153 run(command => $command, verbose => $verbose); 154 unless ($success) { 155 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 156 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_id, $error_code); 155 157 } 156 158 &my_die("Unable to find expected output file: $jpeg2", $det_id, $exp_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2); … … 168 170 unless ($no_update) { 169 171 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 170 run(command => $command, verbose => $verbose);171 unless ($success) { 172 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);173 warn("Unable to perform dettool -addprocessedexp: $error_code");174 exit($error_code);172 run(command => $command, verbose => $verbose); 173 unless ($success) { 174 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 175 warn("Unable to perform dettool -addprocessedexp: $error_code"); 176 exit($error_code); 175 177 } 176 178 } else { … … 181 183 { 182 184 my $msg = shift; # Warning message on die 183 my $det_id = shift; # Detrend identifier185 my $det_id = shift; # Detrend identifier 184 186 my $exp_id = shift; # Exposure tag 185 187 my $exit_code = shift; # Exit code to add … … 187 189 carp($msg); 188 190 if (defined $det_id and defined $exp_id and not $no_update) { 189 my $command = "$dettool -addprocessedexp";190 $command .= " -det_id $det_id";191 $command .= " -exp_id $exp_id";192 $command .= " -code $exit_code";193 $command .= " -dbname $dbname" if defined $dbname;191 my $command = "$dettool -addprocessedexp"; 192 $command .= " -det_id $det_id"; 193 $command .= " -exp_id $exp_id"; 194 $command .= " -code $exit_code"; 195 $command .= " -dbname $dbname" if defined $dbname; 194 196 system ($command); 195 197 } -
trunk/ippScripts/scripts/detrend_reject_imfile.pl
r17671 r17943 3 3 # this program has two jobs: 4 4 # 1: for the given exp_tag, generate the binned & mosaiced JPEG images 5 # 2: examine the collection of per-imfile statistics and reject. At the moment, 5 # 2: examine the collection of per-imfile statistics and reject. At the moment, 6 6 # this program (and the database) only allows rejection at the exposure level, 7 # not at the imfile level. 7 # not at the imfile level. 8 8 9 9 use Carp; … … 32 32 33 33 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); # option parsing 34 use Pod::Usage qw( pod2usage ); 34 use Pod::Usage qw( pod2usage ); 35 35 36 36 # parse the command-line options … … 38 38 $verbose, $no_update, $no_op, $save_temps ); 39 39 GetOptions( 40 'det_id|d=s' => \$det_id,41 'iteration=s' => \$iter,42 'exp_id|e=s' => \$exp_id,43 'exp_tag|=s' => \$exp_tag,44 'det_type|t=s' => \$det_type,45 'camera=s' => \$camera,46 'outroot|w=s' => \$outroot, # output file base name47 'filter=s' => \$filter,48 'reject' => \$reject,49 'dbname|d=s' => \$dbname, # Database name50 'reduction|=s' => \$reduction,51 'verbose' => \$verbose, # Print to stdout52 'no-update' => \$no_update,53 'no-op' => \$no_op,54 'save-temps' => \$save_temps, # Save temporary files?55 ) or pod2usage( 2 );40 'det_id|d=s' => \$det_id, 41 'iteration=s' => \$iter, 42 'exp_id|e=s' => \$exp_id, 43 'exp_tag|=s' => \$exp_tag, 44 'det_type|t=s' => \$det_type, 45 'camera=s' => \$camera, 46 'outroot|w=s' => \$outroot, # output file base name 47 'filter=s' => \$filter, 48 'reject' => \$reject, 49 'dbname|d=s' => \$dbname, # Database name 50 'reduction|=s' => \$reduction, 51 'verbose' => \$verbose, # Print to stdout 52 'no-update' => \$no_update, 53 'no-op' => \$no_op, 54 'save-temps' => \$save_temps, # Save temporary files? 55 ) or pod2usage( 2 ); 56 56 57 57 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 58 58 pod2usage( -msg => "Required options: --det_id --iteration --exp_id --exp_tag --det_type --camera --outroot", 59 -exitval => 3) unless 60 defined $det_id and 61 defined $iter and 62 defined $exp_id and 63 defined $exp_tag and 64 defined $det_type and 59 -exitval => 3) unless 60 defined $det_id and 61 defined $iter and 62 defined $exp_id and 63 defined $exp_tag and 64 defined $det_type and 65 65 defined $camera and 66 66 defined $outroot; … … 82 82 # XXX -bg_mean_stdev should take stdev of bg_mean if bg_mean_stdev == 0 (B) 83 83 # XXX (A) if imfile.Ncomp > 1, (B) if imfile.Ncomp == 1 84 my $STATS = 84 my $STATS = 85 85 [ 86 # KEYWORD STATISTIC CHIPTOOL FLAG87 { name => "bg", type => "mean", flag => "-bg", dtype => "float" },88 { name => "bg_mean_stdev", type => "stdev", flag => "-bg_mean_stdev", dtype => "float" },89 { name => "bg_stdev", type => "rms", flag => "-bg_stdev", dtype => "float" }, 90 { name => "bg_skewness", type => "mean", flag => "-bg_skewness", dtype => "float" }, 91 { name => "bg_kurtosis", type => "mean", flag => "-bg_kurtosis", dtype => "float" }, 92 { name => "bin_stdev", type => "rms", flag => "-bin_stdev", dtype => "float" },93 { name => "fringe_0", type => "mean", flag => "-fringe_0", dtype => "float" },94 { name => "fringe_1", type => "rms", flag => "-fringe_1", dtype => "float" },95 { name => "fringe_0", type => "stdev", flag => "-fringe_2", dtype => "float" },96 { name => "user_1", type => "mean", flag => "-user_1",dtype => "float" }, # fringe residual97 { name => "user_2", type => "rms", flag => "-user_2",dtype => "float" }, # fringe residual98 { name => "user_1", type => "stdev", flag => "-user_3",dtype => "float" }, # fringe residual99 ];86 # KEYWORD STATISTIC CHIPTOOL FLAG 87 { name => "bg", type => "mean", flag => "-bg", dtype => "float" }, 88 { name => "bg_mean_stdev", type => "stdev", flag => "-bg_mean_stdev", dtype => "float" }, 89 { name => "bg_stdev", type => "rms", flag => "-bg_stdev", dtype => "float" }, 90 { name => "bg_skewness", type => "mean", flag => "-bg_skewness", dtype => "float" }, 91 { name => "bg_kurtosis", type => "mean", flag => "-bg_kurtosis", dtype => "float" }, 92 { name => "bin_stdev", type => "rms", flag => "-bin_stdev", dtype => "float" }, 93 { name => "fringe_0", type => "mean", flag => "-fringe_0", dtype => "float" }, 94 { name => "fringe_1", type => "rms", flag => "-fringe_1", dtype => "float" }, 95 { name => "fringe_0", type => "stdev", flag => "-fringe_2", dtype => "float" }, 96 { name => "user_1", type => "mean", flag => "-user_1", dtype => "float" }, # fringe residual 97 { name => "user_2", type => "rms", flag => "-user_2", dtype => "float" }, # fringe residual 98 { name => "user_1", type => "stdev", flag => "-user_3", dtype => "float" }, # fringe residual 99 ]; 100 100 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser 101 101 … … 104 104 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 105 105 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 106 if ($missing_tools) { 106 if ($missing_tools) { 107 107 warn("Can't find required tools."); 108 exit($PS_EXIT_CONFIG_ERROR); 108 exit($PS_EXIT_CONFIG_ERROR); 109 109 } 110 110 … … 119 119 $command .= " -dbname $dbname" if defined $dbname; 120 120 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 121 run(command => $command, verbose => $verbose);121 run(command => $command, verbose => $verbose); 122 122 unless ($success) { 123 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);124 warn("Unable to perform dettool -residimfile: $error_code\n");125 exit($error_code);123 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 124 warn("Unable to perform dettool -residimfile: $error_code\n"); 125 exit($error_code); 126 126 } 127 127 # XXX report an error message if stdout_buf is empty 128 128 129 129 # Parse the stdout buffer into a metadata 130 my $mdcParser = PS::IPP::Metadata::Config->new; 130 my $mdcParser = PS::IPP::Metadata::Config->new; 131 131 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 132 &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR);132 &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR); 133 133 134 134 # parse the file info in the metadata 135 135 $files = parse_md_list($metadata) or 136 &my_die("Unable to parse metadata list", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR);136 &my_die("Unable to parse metadata list", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR); 137 137 138 138 # Parse the statistics on the residual image … … 172 172 # Make the jpeg for binning 1 173 173 $command = "$ppImage -list $list1Name $outroot -recipe PPIMAGE $recipe1"; # Command to run 174 $command .= " -dbname $dbname" if defined $dbname; 174 175 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 175 run(command => $command, verbose => $verbose);176 run(command => $command, verbose => $verbose); 176 177 unless ($success) { 177 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);178 &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_id, $error_code);178 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 179 &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_id, $error_code); 179 180 } 180 181 &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $exp_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1Name); 181 182 182 183 # Make the jpeg for binning 2 183 184 $command = "$ppImage -list $list2Name $outroot -recipe PPIMAGE $recipe2"; # Command to run 185 $command .= " -dbname $dbname" if defined $dbname; 184 186 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 185 run(command => $command, verbose => $verbose);187 run(command => $command, verbose => $verbose); 186 188 unless ($success) { 187 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);188 &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_id, $error_code);189 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 190 &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_id, $error_code); 189 191 } 190 192 &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $exp_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2Name); … … 217 219 foreach my $file (@$files) { 218 220 my $name = $file->{class_id}; 219 my $mean = $file->{bg}; # Mean for this imfile221 my $mean = $file->{bg}; # Mean for this imfile 220 222 my $stdev = $file->{bg_stdev}; # Stdev for this imfile 221 223 my $skewness = $file->{bg_skewness}; # Skewness for this imfile … … 227 229 my $flux; 228 230 if ($file->{exp_time} == 0.0) { 229 $flux = $mean;230 } else { 231 $flux = $mean / $file->{exp_time};231 $flux = $mean; 232 } else { 233 $flux = $mean / $file->{exp_time}; 232 234 } 233 235 push @fluxes, $flux; … … 243 245 # 0.0 for a bias). in general, use with ADDITIVE components 244 246 if ($reject_imfile_mean > 0) { 245 if (abs($mean) > $reject_imfile_mean * $stdev) {246 print $logFile "Rejecting exposure based on bad imfile mean for $name: ";247 $reject = 1;248 } else {249 print $logFile "Imfile mean for $name meets requirements: ";250 }251 print $logFile "$mean vs $reject_imfile_mean * $stdev\n";247 if (abs($mean) > $reject_imfile_mean * $stdev) { 248 print $logFile "Rejecting exposure based on bad imfile mean for $name: "; 249 $reject = 1; 250 } else { 251 print $logFile "Imfile mean for $name meets requirements: "; 252 } 253 print $logFile "$mean vs $reject_imfile_mean * $stdev\n"; 252 254 } else { 253 print $logFile "No rejection on imfile mean for $name\n";255 print $logFile "No rejection on imfile mean for $name\n"; 254 256 } 255 257 … … 260 262 # for a bias). in general, use with ADDITIVE components 261 263 if ($reject_imfile_flux > 0) { 262 if (abs($flux) > $reject_imfile_flux) {263 print $logFile "Rejecting exposure based on bad imfile flux for $name: ";264 $reject = 1;265 } else {266 print $logFile "Imfile flux for $name meets requirements: ";267 }268 print $logFile "$flux vs $reject_imfile_flux\n";264 if (abs($flux) > $reject_imfile_flux) { 265 print $logFile "Rejecting exposure based on bad imfile flux for $name: "; 266 $reject = 1; 267 } else { 268 print $logFile "Imfile flux for $name meets requirements: "; 269 } 270 print $logFile "$flux vs $reject_imfile_flux\n"; 269 271 } else { 270 print $logFile "No rejection on imfile flux for $name\n";272 print $logFile "No rejection on imfile flux for $name\n"; 271 273 } 272 274 … … 274 276 # larger than the limit 275 277 if ($reject_imfile_stdev > 0) { 276 if ($stdev > $reject_imfile_stdev) {277 print $logFile "Rejecting exposure based on bad imfile stdev for $name: ";278 $reject = 1;279 } else {280 print $logFile "Imfile stdev for $name meets requirements: ";281 }282 print $logFile "$stdev vs $reject_imfile_stdev\n";283 284 } else { 285 print $logFile "No rejection on imfile stdev for $name\n";278 if ($stdev > $reject_imfile_stdev) { 279 print $logFile "Rejecting exposure based on bad imfile stdev for $name: "; 280 $reject = 1; 281 } else { 282 print $logFile "Imfile stdev for $name meets requirements: "; 283 } 284 print $logFile "$stdev vs $reject_imfile_stdev\n"; 285 286 } else { 287 print $logFile "No rejection on imfile stdev for $name\n"; 286 288 } 287 289 … … 289 291 # larger than the limit 290 292 if ($reject_imfile_skewness > 0) { 291 if ($stdev > $reject_imfile_skewness) {292 print $logFile "Rejecting exposure based on bad imfile skewness for $name: ";293 $reject = 1;294 } else {295 print $logFile "Imfile skewness for $name meets requirements: ";296 }297 print $logFile "$skewness vs $reject_imfile_skewness\n";298 299 } else { 300 print $logFile "No rejection on imfile skewness for $name\n";293 if ($stdev > $reject_imfile_skewness) { 294 print $logFile "Rejecting exposure based on bad imfile skewness for $name: "; 295 $reject = 1; 296 } else { 297 print $logFile "Imfile skewness for $name meets requirements: "; 298 } 299 print $logFile "$skewness vs $reject_imfile_skewness\n"; 300 301 } else { 302 print $logFile "No rejection on imfile skewness for $name\n"; 301 303 } 302 304 … … 304 306 # larger than the limit 305 307 if ($reject_imfile_kurtosis > 0) { 306 if ($stdev > $reject_imfile_kurtosis) {307 print $logFile "Rejecting exposure based on bad imfile kurtosis for $name: ";308 $reject = 1;309 } else {310 print $logFile "Imfile kurtosis for $name meets requirements: ";311 }312 print $logFile "$kurtosis vs $reject_imfile_kurtosis\n";313 314 } else { 315 print $logFile "No rejection on imfile kurtosis for $name\n";308 if ($stdev > $reject_imfile_kurtosis) { 309 print $logFile "Rejecting exposure based on bad imfile kurtosis for $name: "; 310 $reject = 1; 311 } else { 312 print $logFile "Imfile kurtosis for $name meets requirements: "; 313 } 314 print $logFile "$kurtosis vs $reject_imfile_kurtosis\n"; 315 316 } else { 317 print $logFile "No rejection on imfile kurtosis for $name\n"; 316 318 } 317 319 … … 319 321 # component means is larger than the limit 320 322 if ($reject_imfile_meanstdev > 0) { 321 if ($meanStdev > $reject_imfile_meanstdev) {322 print $logFile "Rejecting exposure based on bad imfile mean stdev for $name: ";323 $reject = 1;324 } else {325 print $logFile "Imfile mean stdev for $name meets requirements: ";326 }327 print $logFile "$meanStdev vs $reject_imfile_meanstdev\n";328 } else { 329 print $logFile "No rejection on imfile mean stdev for $name\n";323 if ($meanStdev > $reject_imfile_meanstdev) { 324 print $logFile "Rejecting exposure based on bad imfile mean stdev for $name: "; 325 $reject = 1; 326 } else { 327 print $logFile "Imfile mean stdev for $name meets requirements: "; 328 } 329 print $logFile "$meanStdev vs $reject_imfile_meanstdev\n"; 330 } else { 331 print $logFile "No rejection on imfile mean stdev for $name\n"; 330 332 } 331 333 … … 333 335 # the mean counts / total pixel variance) of the imfile component 334 336 # means are less than the limit. this test is sensible for images 335 # which have finite residual flux such as a flat-field image. 337 # which have finite residual flux such as a flat-field image. 336 338 if ($reject_imfile_snr > 0) { 337 if ($mean < $stdev * $reject_imfile_snr) {338 print $logFile "Rejecting exposure based on bad imfile S/N for $name: ";339 $reject = 1;340 } else {341 print $logFile "Imfile S/N for $name meets requirements: ";342 }343 print $logFile "mean: $mean vs stdev*SNlimit: " . $stdev * $reject_imfile_snr . "\n";344 } else { 345 print $logFile "No rejection on imfile S/N for $name\n";339 if ($mean < $stdev * $reject_imfile_snr) { 340 print $logFile "Rejecting exposure based on bad imfile S/N for $name: "; 341 $reject = 1; 342 } else { 343 print $logFile "Imfile S/N for $name meets requirements: "; 344 } 345 print $logFile "mean: $mean vs stdev*SNlimit: " . $stdev * $reject_imfile_snr . "\n"; 346 } else { 347 print $logFile "No rejection on imfile S/N for $name\n"; 346 348 } 347 349 … … 351 353 # have finite residual flux such as a flat-field image. 352 354 if ($reject_imfile_bin_stdev > 0) { 353 if ($binStdev > $reject_imfile_bin_stdev) {354 print $logFile "Rejecting exposure based on bad imfile binned stdev for $name: ";355 $reject = 1;356 } else {357 print $logFile "Imfile binned stdev for $name meets requirements: ";358 }359 print $logFile "$binStdev vs $reject_imfile_bin_stdev\n";360 } else { 361 print $logFile "No rejection on imfile binned stdev for $name\n";355 if ($binStdev > $reject_imfile_bin_stdev) { 356 print $logFile "Rejecting exposure based on bad imfile binned stdev for $name: "; 357 $reject = 1; 358 } else { 359 print $logFile "Imfile binned stdev for $name meets requirements: "; 360 } 361 print $logFile "$binStdev vs $reject_imfile_bin_stdev\n"; 362 } else { 363 print $logFile "No rejection on imfile binned stdev for $name\n"; 362 364 } 363 365 if ($reject_imfile_bin_snr > 0) { 364 if ($mean < $binStdev * $reject_imfile_bin_snr) {365 print $logFile "Rejecting exposure based on bad imfile binned S/N for $name: ";366 $reject = 1;367 } else {368 print $logFile "Imfile binned S/N for $name meets requirements: ";369 }370 print $logFile "mean: $mean vs binStdev*SNlimit: " . $binStdev * $reject_imfile_bin_snr . "\n";371 } else { 372 print $logFile "No rejection on imfile binned S/N for $name\n";366 if ($mean < $binStdev * $reject_imfile_bin_snr) { 367 print $logFile "Rejecting exposure based on bad imfile binned S/N for $name: "; 368 $reject = 1; 369 } else { 370 print $logFile "Imfile binned S/N for $name meets requirements: "; 371 } 372 print $logFile "mean: $mean vs binStdev*SNlimit: " . $binStdev * $reject_imfile_bin_snr . "\n"; 373 } else { 374 print $logFile "No rejection on imfile binned S/N for $name\n"; 373 375 } 374 376 } 375 377 376 378 # basic ensemble stats 377 my $mean = $stats->value_for_flag ("-bg");378 my $meanStdev = $stats->value_for_flag ("-bg_mean_stdev");379 my $stdev = $stats->value_for_flag ("-bg_stdev");380 my $binStdev = $stats->value_for_flag ("-bin_stdev");379 my $mean = $stats->value_for_flag ("-bg"); 380 my $meanStdev = $stats->value_for_flag ("-bg_mean_stdev"); 381 my $stdev = $stats->value_for_flag ("-bg_stdev"); 382 my $binStdev = $stats->value_for_flag ("-bin_stdev"); 381 383 my $fringe_mean = $stats->value_for_flag ("-fringe_0"); 382 384 my $fringe_err = $stats->value_for_flag ("-fringe_1"); … … 387 389 388 390 # other stats (flux depends on bg and exp_time) 389 my $fluxStats = Statistics::Descriptive::Sparse->new(); # Statistics calculator for means391 my $fluxStats = Statistics::Descriptive::Sparse->new(); # Statistics calculator for means 390 392 $fluxStats->add_data(@fluxes); 391 my $flux = $fluxStats->mean(); # Mean of the imfile means393 my $flux = $fluxStats->mean(); # Mean of the imfile means 392 394 393 395 # other stats … … 406 408 # for a bias). in general, use with ADDITIVE components 407 409 if ($reject_exp_mean > 0) { 408 if (abs($mean) > $reject_exp_mean * $stdev) {409 print $logFile "Rejecting exposure based on bad mean counts: ";410 $reject = 1;411 } else {412 print $logFile "Exposure mean counts meets requirements: ";413 }414 print $logFile "mean: $mean, stdev: $stdev (limit is: " . $reject_exp_mean * $stdev . ") \n";415 } else { 416 print $logFile "No rejection for exp mean\n";410 if (abs($mean) > $reject_exp_mean * $stdev) { 411 print $logFile "Rejecting exposure based on bad mean counts: "; 412 $reject = 1; 413 } else { 414 print $logFile "Exposure mean counts meets requirements: "; 415 } 416 print $logFile "mean: $mean, stdev: $stdev (limit is: " . $reject_exp_mean * $stdev . ") \n"; 417 } else { 418 print $logFile "No rejection for exp mean\n"; 417 419 } 418 420 … … 423 425 # for a bias). in general, use with ADDITIVE components 424 426 if ($reject_exp_flux > 0) { 425 if (abs($flux) > $reject_exp_flux * $stdev) {426 print $logFile "Rejecting exposure based on bad mean flux: ";427 $reject = 1;428 } else {429 print $logFile "Exposure mean flux meets requirements: ";430 }431 print $logFile "flux: $flux, stdev: $stdev (limit is: " . $reject_exp_flux * $stdev . ")\n";432 } else { 433 print $logFile "No rejection for exp mean\n";427 if (abs($flux) > $reject_exp_flux * $stdev) { 428 print $logFile "Rejecting exposure based on bad mean flux: "; 429 $reject = 1; 430 } else { 431 print $logFile "Exposure mean flux meets requirements: "; 432 } 433 print $logFile "flux: $flux, stdev: $stdev (limit is: " . $reject_exp_flux * $stdev . ")\n"; 434 } else { 435 print $logFile "No rejection for exp mean\n"; 434 436 } 435 437 … … 437 439 # limit 438 440 if ($reject_exp_stdev > 0) { 439 if ($stdev > $reject_exp_stdev) {440 print $logFile "Rejecting exposure based on bad stdev: ";441 $reject = 1;442 } else {443 print $logFile "Exposure stdev meets requirements: ";444 }445 print $logFile "$stdev vs $reject_exp_stdev\n";446 } else { 447 print $logFile "No rejection for exp stdev\n";441 if ($stdev > $reject_exp_stdev) { 442 print $logFile "Rejecting exposure based on bad stdev: "; 443 $reject = 1; 444 } else { 445 print $logFile "Exposure stdev meets requirements: "; 446 } 447 print $logFile "$stdev vs $reject_exp_stdev\n"; 448 } else { 449 print $logFile "No rejection for exp stdev\n"; 448 450 } 449 451 … … 451 453 # than the limit 452 454 if ($reject_exp_meanstdev > 0) { 453 if ($meanStdev > $reject_exp_meanstdev) {454 print $logFile "Rejecting exposure based on bad mean stdev: ";455 $reject = 1;456 } else {457 print $logFile "Exposure mean stdev meets requirements: ";458 }459 print $logFile "$meanStdev vs $reject_exp_meanstdev\n";460 } else { 461 print $logFile "No rejection for exp mean stdev\n";455 if ($meanStdev > $reject_exp_meanstdev) { 456 print $logFile "Rejecting exposure based on bad mean stdev: "; 457 $reject = 1; 458 } else { 459 print $logFile "Exposure mean stdev meets requirements: "; 460 } 461 print $logFile "$meanStdev vs $reject_exp_meanstdev\n"; 462 } else { 463 print $logFile "No rejection for exp mean stdev\n"; 462 464 } 463 465 464 466 # reject if the signal-to-noise is insufficient 465 467 if ($reject_exp_snr > 0) { 466 if (abs($mean) < abs($stdev * $reject_exp_snr)) {467 print $logFile "Rejecting exposure based on poor S/N: \n";468 $reject = 1;469 } else {470 print $logFile "Exposure S/N meets requirements: \n";471 }472 print $logFile "signal: $mean vs noise: $stdev (s/n limit is: $reject_exp_snr)\n";473 } else { 474 print $logFile "No rejection for exp S/N\n";468 if (abs($mean) < abs($stdev * $reject_exp_snr)) { 469 print $logFile "Rejecting exposure based on poor S/N: \n"; 470 $reject = 1; 471 } else { 472 print $logFile "Exposure S/N meets requirements: \n"; 473 } 474 print $logFile "signal: $mean vs noise: $stdev (s/n limit is: $reject_exp_snr)\n"; 475 } else { 476 print $logFile "No rejection for exp S/N\n"; 475 477 } 476 478 # reject if the exposure ensemble stdev is deviant 477 479 if ($reject_exp_bin_stdev > 0) { 478 if ($binStdev > $reject_exp_bin_stdev) {479 print $logFile "Rejecting exposure based on bad binned stdev: ";480 $reject = 1;481 } else {482 print $logFile "Exposure binned stdev meets requirements: ";483 }484 print $logFile "$stdev vs $reject_exp_bin_stdev\n";485 } else { 486 print $logFile "No rejection for exp binned stdev\n";480 if ($binStdev > $reject_exp_bin_stdev) { 481 print $logFile "Rejecting exposure based on bad binned stdev: "; 482 $reject = 1; 483 } else { 484 print $logFile "Exposure binned stdev meets requirements: "; 485 } 486 print $logFile "$stdev vs $reject_exp_bin_stdev\n"; 487 } else { 488 print $logFile "No rejection for exp binned stdev\n"; 487 489 } 488 490 # reject if the signal-to-noise is insufficient 489 491 if ($reject_exp_bin_snr > 0) { 490 if (abs($mean) < abs($binStdev * $reject_exp_bin_snr)) {491 print $logFile "Rejecting exposure based on poor binned S/N: \n";492 $reject = 1;493 } else {494 print $logFile "Exposure binned S/N meets requirements: \n";495 }496 print $logFile "signal: $mean vs noise: $binStdev (s/n limit is: $reject_exp_bin_snr)\n";497 } else { 498 print $logFile "No rejection for exp binned S/N\n";492 if (abs($mean) < abs($binStdev * $reject_exp_bin_snr)) { 493 print $logFile "Rejecting exposure based on poor binned S/N: \n"; 494 $reject = 1; 495 } else { 496 print $logFile "Exposure binned S/N meets requirements: \n"; 497 } 498 print $logFile "signal: $mean vs noise: $binStdev (s/n limit is: $reject_exp_bin_snr)\n"; 499 } else { 500 print $logFile "No rejection for exp binned S/N\n"; 499 501 } 500 502 … … 510 512 unless ($no_update) { 511 513 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 512 run(command => $command, verbose => $verbose);514 run(command => $command, verbose => $verbose); 513 515 unless ($success) { 514 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);515 warn("Unable to perform dettool -addresidexp: $error_code\n");516 exit($error_code);516 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 517 warn("Unable to perform dettool -addresidexp: $error_code\n"); 518 exit($error_code); 517 519 } 518 520 } else { … … 531 533 { 532 534 my $msg = shift; # Warning message on die 533 my $det_id = shift; # Detrend identifier534 my $iter = shift; # Iteration535 my $det_id = shift; # Detrend identifier 536 my $iter = shift; # Iteration 535 537 my $exp_id = shift; # Exposure tag 536 538 my $exit_code = shift; # Exit code to add … … 538 540 carp($msg); 539 541 if (defined $det_id and defined $iter and defined $exp_id and not $no_update) { 540 my $command = "$dettool -addresidexp";541 $command .= " -det_id $det_id";542 $command .= " -iteration $iter";543 $command .= " -exp_id $exp_id";544 $command .= " -code $exit_code";545 $command .= " -dbname $dbname" if defined $dbname;542 my $command = "$dettool -addresidexp"; 543 $command .= " -det_id $det_id"; 544 $command .= " -iteration $iter"; 545 $command .= " -exp_id $exp_id"; 546 $command .= " -code $exit_code"; 547 $command .= " -dbname $dbname" if defined $dbname; 546 548 system ($command); 547 549 } … … 552 554 sub rejection_limit 553 555 { 554 my $name = shift; # Rejection limit to555 my $type = shift; # Type of exposure556 my $filter = shift; # Filter556 my $name = shift; # Rejection limit to 557 my $type = shift; # Type of exposure 558 my $filter = shift; # Filter 557 559 558 560 my $value = $ipprc->rejection( $name, $det_type, $filter ); 559 561 if (not defined $value) { 560 $filter = "(no filter)" if not defined $filter;561 die "Unable to determine $name rejection limit for $det_type with $filter.\n";562 $filter = "(no filter)" if not defined $filter; 563 die "Unable to determine $name rejection limit for $det_type with $filter.\n"; 562 564 } 563 565 … … 589 591 ## 5) is the mean stdev > limit (poor images) 590 592 ## 6) calculate the ensemble stdev (rms) of remaining (excluding rejects) 591 ## 7) is the ensemble stdev > limit 593 ## 7) is the ensemble stdev > limit 592 594 593 595 ## for flats, the value used for stdev should be the fractional stdev -
trunk/ippScripts/scripts/diff_skycell.pl
r17858 r17943 178 178 $command .= " -photometry"; 179 179 $command .= " -tracedest $traceDest -log $logDest"; 180 $command .= " -dbname $dbname" if defined $dbname; 180 181 181 182 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = -
trunk/ippScripts/scripts/stack_skycell.pl
r17803 r17943 173 173 $command .= " -photometry"; 174 174 $command .= " -tracedest $traceDest -log $logDest"; 175 $command .= " -dbname $dbname" if defined $dbname; 175 176 176 177 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = -
trunk/ippScripts/scripts/warp_skycell.pl
r17803 r17943 181 181 $command .= " -psf"; # Turn on PSF determination 182 182 $command .= " -tracedest $traceDest -log $logDest"; 183 $command .= " -dbname $dbname" if defined $dbname; 183 184 184 185 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
Note:
See TracChangeset
for help on using the changeset viewer.
