Changeset 17941 for trunk/ippScripts/scripts/detrend_resid.pl
- Timestamp:
- Jun 5, 2008, 11:43:34 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_resid.pl (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_resid.pl
r17671 r17941 39 39 'outroot|w=s' => \$outroot, # output file base name 40 40 'dbname|d=s' => \$dbname, # Database name 41 'reduction=s' => \$reduction, # Reduction class41 'reduction=s' => \$reduction, # Reduction class 42 42 'verbose' => \$verbose, # Print to stdout 43 43 'no-update' => \$no_update, … … 47 47 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 48 48 pod2usage( -msg => "Required options: --det_id --iteration --exp_id --exp_tag --class_id --det_type --camera --input_uri --mode --detrend --outroot (not for 'verify' mode)", 49 -exitval => 3) unless 50 defined $det_id and 51 defined $iter and 52 defined $exp_id and 53 defined $exp_tag and 54 defined $class_id and 55 defined $det_type and 56 defined $input_uri and 57 defined $camera and 58 defined $mode and 59 defined $outroot and 49 -exitval => 3) unless 50 defined $det_id and 51 defined $iter and 52 defined $exp_id and 53 defined $exp_tag and 54 defined $class_id and 55 defined $det_type and 56 defined $input_uri and 57 defined $camera and 58 defined $mode and 59 defined $outroot and 60 60 (defined $detrend or lc($mode) eq 'verify'); 61 61 … … 64 64 # Recipes to use as a function of detrend type and mode 65 65 $reduction = 'DETREND' unless defined $reduction; 66 my $recipe; # Name of recipe to use66 my $recipe; # Name of recipe to use 67 67 if ($mode eq 'master') { 68 68 $recipe = uc($det_type) . '_RESID'; … … 75 75 76 76 # values to extract from output metadata and the stats to calculate 77 my $STATS = 77 my $STATS = 78 78 [ 79 79 # PPSTATS KEYWORD STATISTIC CHIPTOOL FLAG 80 80 { name => "ROBUST_MEDIAN", type => "mean", flag => "-bg", dtype => "float" }, 81 81 { name => "ROBUST_MEDIAN", type => "stdev", flag => "-bg_mean_stdev", dtype => "float" }, 82 { name => "ROBUST_STDEV", type => "rms", flag => "-bg_stdev", dtype => "float" },82 { name => "ROBUST_STDEV", type => "rms", flag => "-bg_stdev", dtype => "float" }, 83 83 { name => "SAMPLE_SKEWNESS", type => "mean", flag => "-bg_skewness", dtype => "float" }, 84 84 { name => "SAMPLE_KURTOSIS", type => "mean", flag => "-bg_kurtosis", dtype => "float" }, 85 { name => "FRINGE_0", type => "mean", flag => "-fringe_0", dtype => "float" },86 { name => "FRINGE_ERR_0", type => "rms", flag => "-fringe_1", dtype => "float" },87 { name => "FRINGE_0", type => "stdev", flag => "-fringe_2", dtype => "float" },85 { name => "FRINGE_0", type => "mean", flag => "-fringe_0", dtype => "float" }, 86 { name => "FRINGE_ERR_0", type => "rms", flag => "-fringe_1", dtype => "float" }, 87 { name => "FRINGE_0", type => "stdev", flag => "-fringe_2", dtype => "float" }, 88 88 { name => "FRINGE_RESID_0", type => "mean", flag => "-fringe_resid_0", dtype => "float" }, 89 89 { name => "FRINGE_RESID_ERR_0", type => "rms", flag => "-fringe_resid_1", dtype => "float" }, … … 92 92 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser 93 93 94 my $BINNED_STATS = 94 my $BINNED_STATS = 95 95 [ 96 96 { name => "ROBUST_STDEV", type => "rms", flag => "-bin_stdev" }, … … 100 100 # Flags to specify the particular detrend to use 101 101 use constant DETRENDS => { 102 'bias' => '-bias', # Specify the bias frame103 'dark' => '-dark', # Specify the dark frame104 'shutter' => '-shutter', # Specify the shutter frame105 'flat' => '-flat', # Specify the flat frame106 'domeflat' => '-flat', # Specify the flat frame107 'skyflat' => '-flat', # Specify the flat frame108 'fringe' => '-fringe', # Specify the fringe frame109 'mask' => '-mask', # Specify the mask frame110 'darkmask' => '-mask', # Specify the mask frame111 'flatmask' => '-mask', # Specify the mask frame102 'bias' => '-bias', # Specify the bias frame 103 'dark' => '-dark', # Specify the dark frame 104 'shutter' => '-shutter', # Specify the shutter frame 105 'flat' => '-flat', # Specify the flat frame 106 'domeflat' => '-flat', # Specify the flat frame 107 'skyflat' => '-flat', # Specify the flat frame 108 'fringe' => '-fringe', # Specify the fringe frame 109 'mask' => '-mask', # Specify the mask frame 110 'darkmask' => '-mask', # Specify the mask frame 111 'flatmask' => '-mask', # Specify the mask frame 112 112 }; 113 113 114 use constant DELETE_STATS => 0; # Delete the statistics file when done?114 use constant DELETE_STATS => 0; # Delete the statistics file when done? 115 115 116 116 # Look for programs we need … … 119 119 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 120 120 my $ppStats = can_run('ppStats') or (warn "Can't find ppStats" and $missing_tools = 1); 121 if ($missing_tools) { 121 if ($missing_tools) { 122 122 warn("Can't find required tools."); 123 exit($PS_EXIT_CONFIG_ERROR); 123 exit($PS_EXIT_CONFIG_ERROR); 124 124 } 125 125 $ppImage .= " -dbname $dbname" if defined $dbname; … … 147 147 $command .= " -stats $outputStats"; 148 148 $command .= " -tracedest $traceDest -log $logDest"; 149 $command .= " -dbname $dbname" if defined $dbname; 149 150 150 151 # Detrend to use in processing 151 152 if (lc($mode) ne 'verify') { 152 my $detFlag = DETRENDS->{lc($det_type)};153 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_PROG_ERROR) unless defined $detFlag;154 $command .= " $detFlag $detrend";153 my $detFlag = DETRENDS->{lc($det_type)}; 154 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_PROG_ERROR) unless defined $detFlag; 155 $command .= " $detFlag $detrend"; 155 156 } 156 157 157 158 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 158 run(command => $command, verbose => $verbose);159 run(command => $command, verbose => $verbose); 159 160 unless ($success) { 160 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);161 &my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $exp_id, $class_id, $error_code);161 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 162 &my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $exp_id, $class_id, $error_code); 162 163 } 163 164 &my_die("Couldn't find expected output file: $outputName", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputName); … … 167 168 168 169 # Load the raw output stats file 169 my $statsFile; # File handle170 my $statsFile; # File handle 170 171 open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_SYS_ERROR); 171 172 my @contents = <$statsFile>; # Contents of file … … 173 174 174 175 # Parse the stats file contents into a metadata 175 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files176 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 176 177 my $metadata = $mdcParser->parse(join "", @contents) or &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 177 178 … … 182 183 $command = "$ppStats -recipe PPSTATS RESIDUAL $bin2Name"; 183 184 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 184 run(command => $command, verbose => $verbose);185 run(command => $command, verbose => $verbose); 185 186 unless ($success) { 186 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);187 &my_die("Unable to perform ppStats: $error_code", $det_id, $iter, $exp_id, $class_id, $error_code);187 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 188 &my_die("Unable to perform ppStats: $error_code", $det_id, $iter, $exp_id, $class_id, $error_code); 188 189 } 189 190 … … 211 212 unless ($no_update) { 212 213 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 213 run(command => $command, verbose => $verbose);214 run(command => $command, verbose => $verbose); 214 215 unless ($success) { 215 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);216 warn("Unable to perform dettool -addresidimfile: $error_code\n");217 exit($error_code);216 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 217 warn("Unable to perform dettool -addresidimfile: $error_code\n"); 218 exit($error_code); 218 219 } 219 220 } else { … … 224 225 { 225 226 my $msg = shift; # Warning message on die 226 my $det_id = shift; # Detrend identifier227 my $iter = shift; # Iteration227 my $det_id = shift; # Detrend identifier 228 my $iter = shift; # Iteration 228 229 my $exp_id = shift; # Exposure tag 229 230 my $class_id = shift; # Class identifier … … 232 233 carp($msg); 233 234 if (defined $det_id and defined $iter and defined $exp_id and not $no_update) { 234 my $command = "$dettool -addresidimfile";235 $command .= " -det_id $det_id";236 $command .= " -iteration $iter";237 $command .= " -exp_id $exp_id";238 $command .= " -class_id $class_id";239 $command .= " -code $exit_code";240 $command .= " -dbname $dbname" if defined $dbname;235 my $command = "$dettool -addresidimfile"; 236 $command .= " -det_id $det_id"; 237 $command .= " -iteration $iter"; 238 $command .= " -exp_id $exp_id"; 239 $command .= " -class_id $class_id"; 240 $command .= " -code $exit_code"; 241 $command .= " -dbname $dbname" if defined $dbname; 241 242 system ($command); 242 243 }
Note:
See TracChangeset
for help on using the changeset viewer.
