Changeset 19942
- Timestamp:
- Oct 7, 2008, 9:56:11 AM (18 years ago)
- Location:
- trunk/ippScripts/scripts
- Files:
-
- 7 edited
-
camera_exp.pl (modified) (10 diffs)
-
chip_imfile.pl (modified) (6 diffs)
-
detrend_norm_apply.pl (modified) (2 diffs)
-
detrend_process_exp.pl (modified) (4 diffs)
-
detrend_process_imfile.pl (modified) (6 diffs)
-
detrend_resid_exp.pl (modified) (1 diff)
-
detrend_stack.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/camera_exp.pl
r19938 r19942 19 19 use IPC::Cmd 0.36 qw( can_run run ); 20 20 use PS::IPP::Metadata::Config; 21 use PS::IPP::Metadata::Stats;22 21 use PS::IPP::Metadata::List qw( parse_md_list ); 23 22 use PS::IPP::Config 1.01 qw( :standard ); … … 79 78 &my_die("Unrecognised ADDSTAR recipe", $cam_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe1; 80 79 81 # values to extract from output metadata and the stats to calculate82 # these should be coming from the psastro results83 my $CHIPSTATS =84 [85 # PPSTATS KEYWORD STATISTIC CHIPTOOL FLAG86 { name => "bg", type => "mean", flag => "-bg", dtype => "float" },87 { name => "bg_stdev", type => "rms", flag => "-bg_stdev", dtype => "float" },88 { name => "bg_mean_stdev", type => "stdev", flag => "-bg_mean_stdev", dtype => "float" },89 { name => "bias", type => "mean", flag => "-bias", dtype => "float" },90 { name => "bias_stdev", type => "rms", flag => "-bias_stdev", dtype => "float" },91 { name => "fringe_0", type => "mean", flag => "-fringe_0", dtype => "float" },92 { name => "fringe_1", type => "rms", flag => "-fringe_1", dtype => "float" },93 { name => "fringe_2", type => "stdev", flag => "-fringe_2", dtype => "float" },94 { name => "ap_resid", type => "mean", flag => "-ap_resid", dtype => "float" },95 { name => "ap_resid_stdev", type => "rms", flag => "-ap_resid_stdev", dtype => "float" },96 { name => "fwhm_major", type => "mean", flag => "-fwhm_major", dtype => "float" },97 { name => "fwhm_minor", type => "mean", flag => "-fwhm_minor", dtype => "float" },98 { name => "n_stars", type => "sum", flag => "-n_stars", dtype => "int" },99 { name => "n_extended", type => "sum", flag => "-n_extended", dtype => "int" },100 { name => "n_cr", type => "sum", flag => "-n_cr", dtype => "int" },101 ];102 my $chipStats = PS::IPP::Metadata::Stats->new($CHIPSTATS); # Stats parser103 104 # values to extract from camera-level output metadata and the stats to calculate105 my $CAMSTATS =106 [107 # PPSTATS KEYWORD STATISTIC CHIPTOOL FLAG108 { name => "CERROR", type => "rms", flag => "-sigma_ra", dtype => "float" },109 { name => "CERROR", type => "rms", flag => "-sigma_dec", dtype => "float" },110 # { name => "DT_ASTR", type => "sum", flag => "-dtime_astrom", dtype => "float" },111 { name => "NASTRO", type => "sum", flag => "-n_astrom", dtype => "int" },112 # { name => "ZP??", type => "mean", flag => "-zp_mean", dtype => "float" },113 # { name => "ZP??", type => "rms", flag => "-zp_stdev", dtype => "float" },114 ];115 my $camStats = PS::IPP::Metadata::Stats->new($CAMSTATS); # Stats parser116 117 80 # Look for programs we need 118 81 my $missing_tools; … … 120 83 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 121 84 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 85 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 122 86 123 87 # test for addstar and psastro: … … 131 95 132 96 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 97 98 my $cmdflags; 133 99 134 100 # Get list of component files … … 150 116 &my_die("Unable to parse metadata list", $cam_id, $PS_EXIT_PROG_ERROR); 151 117 152 # extract the stats from the metadata 153 unless ($chipStats->parse($metadata)) { 154 &my_die("Unable to find all values in statistics output.\n", $cam_id, $PS_EXIT_PROG_ERROR); 118 # since I can't figure out how to do input and output within PERL, I'm writing to a temp file 119 my ($statFile, $statName) = tempfile( "/tmp/$exp_tag.cm.$cam_id.stats.XXXX", UNLINK => !$save_temps ); 120 print "saving stats to $statName\n"; 121 foreach my $line (@$stdout_buf) { 122 print $statFile $line; 123 } 124 close $statFile; 125 126 # parse the stats in the metadata file 127 $command = "$ppStatsFromMetadata $statName - CAMERA_EXP_IMFILE"; 128 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 129 run(command => $command, verbose => $verbose); 130 unless ($success) { 131 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 132 warn("Unable to perform ppStatsFromMetadata: $error_code\n"); 133 exit($error_code); 134 } 135 136 foreach my $line (@$stdout_buf) { 137 $cmdflags .= " $line"; 155 138 } 156 139 } … … 248 231 if ($chipObjectsExist) { 249 232 # run psastro on the chipObjects, producing fpaObjects 250 # XXX add a ppStats call which will collect the astrometry stats251 233 my $command; 252 234 $command = "$psastro -list $list3Name $outroot"; … … 256 238 my $do_stats; 257 239 if ($run_state eq 'new') { 258 $command .= " -stats $fpaStats -recipe PPSTATS C HIPSTATS";240 $command .= " -stats $fpaStats -recipe PPSTATS CAMSTATS"; 259 241 $command .= " -dumpconfig $configuration"; 260 242 $do_stats = 1; … … 275 257 276 258 if ($do_stats) { 277 &my_die("Unable to find expected output file: $fpaStats", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($fpaObjects); 278 279 # Get the statistics on the processed image 280 my $statsFile; # File handle 281 open $statsFile, $ipprc->file_resolve($fpaStats) or &my_die("Can't open statistics file $fpaStats: $!", $cam_id, $PS_EXIT_SYS_ERROR); 282 my @contents = <$statsFile>; # Contents of file 283 close $statsFile; 284 285 # parse the statistics MDC file 286 my $mdcParser = PS::IPP::Metadata::Config->new(); # Parser for metadata config files 287 my $metadata = $mdcParser->parse(join "", @contents); 288 unless ($metadata) { 289 &my_die("Unable to parse metadata config doc", $cam_id, $PS_EXIT_PROG_ERROR); 290 } 291 292 # extract the stats from the metadata 293 unless ($camStats->parse($metadata)) { 294 &my_die("Failure extracting metadata from the statistics output file.\n", $cam_id, $PS_EXIT_PROG_ERROR); 295 } 259 my $fpaStatsReal = $ipprc->file_resolve($fpaStats); 260 &my_die("Couldn't find expected output file: $fpaStats", $cam_id, $PS_EXIT_SYS_ERROR) unless -f $fpaStatsReal; 261 262 # parse stats from metadata 263 $command = "$ppStatsFromMetadata $fpaStatsReal - CAMERA_EXP_FPA"; 264 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 265 run(command => $command, verbose => $verbose); 266 unless ($success) { 267 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 268 &my_die("Unable to perform ppStatsFromMetadata: $error_code", $cam_id, $error_code); 269 } 270 foreach my $line (@$stdout_buf) { 271 $cmdflags .= " $line"; 272 } 273 chomp $cmdflags; 296 274 } 297 275 … … 340 318 } 341 319 342 343 320 my $fpaCommand = "$camtool -cam_id $cam_id"; 344 321 if ($run_state eq 'new') { … … 346 323 $fpaCommand .= " -uri UNKNOWN"; 347 324 $fpaCommand .= " -path_base $outroot"; 348 $fpaCommand .= $chipStats->cmdflags(); 349 $fpaCommand .= $camStats->cmdflags(); 325 $fpaCommand .= " $cmdflags"; 350 326 $fpaCommand .= " -hostname $host" if defined $host; 351 327 $fpaCommand .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); -
trunk/ippScripts/scripts/chip_imfile.pl
r19938 r19942 19 19 use IPC::Cmd 0.36 qw( can_run run ); 20 20 use PS::IPP::Metadata::Config; 21 use PS::IPP::Metadata::Stats;22 21 use PS::IPP::Config 1.01 qw( :standard ); 23 22 … … 74 73 } 75 74 76 # values to extract from output metadata and the stats to calculate77 # XXX commented-out entries are not yet defined in the output files78 my $STATS =79 [80 # PPSTATS KEYWORD STATISTIC CHIPTOOL FLAG81 { name => "ROBUST_MEDIAN", type => "mean", flag => "-bg", dtype => "float" },82 { name => "ROBUST_MEDIAN", type => "stdev", flag => "-bg_mean_stdev", dtype => "float" },83 { name => "ROBUST_STDEV", type => "rms", flag => "-bg_stdev", dtype => "float" },84 { name => "OVER_VAL", type => "mean", flag => "-bias", dtype => "float" },85 { name => "OVER_VAL", type => "stdev", flag => "-bias_stdev", dtype => "float" },86 { name => "FRINGE_0", type => "rms", flag => "-fringe_0", dtype => "float" },87 { name => "FRINGE_RESID_0", type => "rms", flag => "-fringe_1", dtype => "float" },88 { name => "FRINGE_ERR_0", type => "rms", flag => "-fringe_2", dtype => "float" },89 { name => "APMIFIT", type => "mean", flag => "-ap_resid", dtype => "float" },90 { name => "DAPMIFIT", type => "rms", flag => "-ap_resid_stdev", dtype => "float" },91 { name => "FWHM_X", type => "mean", flag => "-fwhm_major", dtype => "float" },92 { name => "FWHM_Y", type => "mean", flag => "-fwhm_minor", dtype => "float" },93 { name => "DT_DET", type => "sum", flag => "-dtime_detrend", dtype => "float" },94 { name => "DT_PHOT", type => "sum", flag => "-dtime_photom", dtype => "float" },95 { name => "DT_TOTAL", type => "sum", flag => "-dtime_total", dtype => "float" },96 { name => "NSTARS", type => "sum", flag => "-n_stars", dtype => "int" },97 # { name => "?", type => "sum", flag => "-n_extended", dtype => "int" },98 # { name => "?", type => "sum", flag => "-n_cr", dtype => "int" },99 ];100 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser101 102 75 # Look for programs we need 103 76 my $missing_tools; … … 105 78 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 106 79 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 80 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 107 81 if ($missing_tools) { 108 82 warn("Can't find required tools."); … … 137 111 } 138 112 113 my $cmdflags; 114 139 115 # Run ppImage 140 116 unless ($no_op) { 141 ## XXX can we convert ppImage log and trace to use the filerules to generate consistent names142 ## XXX also stats: output should be implied by $outroot143 117 my $command; 144 118 my $do_stats; … … 205 179 &my_die("Couldn't find expected output file: $outputStats\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStats); 206 180 207 # Get the statistics on the processed image 208 my $statsFile; # File handle 209 open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR); 210 my @contents = <$statsFile>; # Contents of file 211 close $statsFile; 212 213 # parse the statistics MDC file 214 my $mdcParser = PS::IPP::Metadata::Config->new(); # Parser for metadata config files 215 my $metadata = $mdcParser->parse(join "", @contents); 216 unless ($metadata) { 217 &my_die("Unable to parse metadata config doc", $exp_id, $chip_id, $class_id, $PS_EXIT_PROG_ERROR); 218 } 219 220 # extract the stats from the metadata 221 unless ($stats->parse($metadata)) { 222 &my_die("Failure extracting metadata from the statistics output file.\n", $exp_id, $chip_id, $class_id, $PS_EXIT_PROG_ERROR); 223 } 181 my $outputStatsReal = $ipprc->file_resolve($outputStats); 182 &my_die("Couldn't find expected output file: $outputStats", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStatsReal; 183 184 # measure chip stats 185 $command = "$ppStatsFromMetadata $outputStatsReal - CHIP_IMFILE"; 186 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 187 run(command => $command, verbose => $verbose); 188 unless ($success) { 189 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 190 &my_die("Unable to perform ppStatsFromMetadata: $error_code", $exp_id, $chip_id, $class_id, $error_code); 191 } 192 foreach my $line (@$stdout_buf) { 193 $cmdflags .= " $line"; 194 } 195 chomp $cmdflags; 224 196 } 225 197 } … … 236 208 $command .= " -hostname $host" if defined $host; 237 209 $command .= " -dbname $dbname" if defined $dbname; 238 $command .= $stats->cmdflags();210 $command .= " $cmdflags"; 239 211 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 240 212 } else { -
trunk/ippScripts/scripts/detrend_norm_apply.pl
r19817 r19942 109 109 my $outFile = ($det_type_real eq "mask") ? 'PPIMAGE.OUTPUT.DETMASK' : 'PPIMAGE.OUTPUT';; # XXXX something of a hack (too many places to control things...) 110 110 111 my $RECIPE_PPSTATS = ($det_type_real eq "dark") ? 'DARKSTATS' : ' CHIPSTATS';; # XXXX something of a hack (too many places to control things...)111 my $RECIPE_PPSTATS = ($det_type_real eq "dark") ? 'DARKSTATS' : 'DETSTATS';; # XXXX something of a hack (too many places to control things...) 112 112 113 113 my $output = $ipprc->filename($outFile, $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); … … 153 153 &my_die("Can't find expected output file: $statsName", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $statsNameReal; 154 154 155 # p pStatsFromMetadata $outputStats - DETREND_RESID_IMFILE156 $command = "$ppStatsFromMetadata $statsNameReal - DETREND_ RESID_IMFILE";155 # parse stats from metadata 156 $command = "$ppStatsFromMetadata $statsNameReal - DETREND_NORM_APPLY"; 157 157 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 158 158 run(command => $command, verbose => $verbose); -
trunk/ippScripts/scripts/detrend_process_exp.pl
r19658 r19942 16 16 use IPC::Cmd 0.36 qw( can_run run ); 17 17 use PS::IPP::Metadata::Config; 18 use PS::IPP::Metadata::Stats;19 18 use PS::IPP::Config 1.01 qw( :standard ); 20 19 use PS::IPP::Metadata::List qw( parse_md_list ); … … 68 67 &my_die("Unrecognised detrend type: $det_type", $det_id, $exp_id, $PS_EXIT_PROG_ERROR) unless defined $recipe; 69 68 70 # values to extract from output metadata and the stats to calculate71 # XXX -bg_mean_stdev should take rms of bg_mean_stdev if bg_mean_stdev != 0 (A)72 # XXX -bg_mean_stdev should take stdev of bg_mean if bg_mean_stdev == 0 (B)73 # XXX (A) if imfile.Ncomp > 1, (B) if imfile.Ncomp == 174 my $STATS =75 [76 # KEYWORD STATISTIC CHIPTOOL FLAG77 { name => "bg", type => "mean", flag => "-bg", dtype => "float" },78 { name => "bg", type => "stdev", flag => "-bg_mean_stdev", dtype => "float" },79 { name => "bg_stdev", type => "rms", flag => "-bg_stdev", dtype => "float" },80 # { name => "bg_mean_stdev", type => "rms", flag => "-bg_mean_stdev" },81 ];82 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser83 84 69 # Look for programs we need 85 70 my $missing_tools; 86 71 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 87 72 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 73 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 88 74 if ($missing_tools) { 89 75 warn("Can't find required tools."); 90 76 exit($PS_EXIT_CONFIG_ERROR); 91 77 } 78 79 my $cmdflags; 92 80 93 81 # Get list of component files … … 112 100 &my_die("Unable to parse metadata list", $det_id, $exp_id, $PS_EXIT_PROG_ERROR); 113 101 114 # parse the stats in the metadata 115 unless ($stats->parse($metadata)) { 116 &my_die("Unable to find all values in statistics output.\n", $det_id, $exp_id, $PS_EXIT_PROG_ERROR); 102 # since I can't figure out how to do input and output within PERL, I'm writing to a temp file 103 my ($statFile, $statName) = tempfile( "/tmp/$exp_tag.detproc.$det_id.stats.XXXX", UNLINK => !$save_temps ); 104 print "saving stats to $statName\n"; 105 foreach my $line (@$stdout_buf) { 106 print $statFile $line; 107 } 108 close $statFile; 109 110 # parse the stats in the metadata file 111 $command = "$ppStatsFromMetadata $statName - DETREND_PROCESS_EXP"; 112 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 113 run(command => $command, verbose => $verbose); 114 unless ($success) { 115 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 116 warn("Unable to perform ppStatsFromMetadata: $error_code\n"); 117 exit($error_code); 118 } 119 120 foreach my $line (@$stdout_buf) { 121 $cmdflags .= " $line"; 117 122 } 118 123 } … … 173 178 $command .= " -recip $recipe -path_base $outroot"; 174 179 $command .= " -dbname $dbname" if defined $dbname; 175 $command .= $stats->cmdflags();180 $command .= " $cmdflags"; 176 181 177 182 # Add the processed file to the database -
trunk/ippScripts/scripts/detrend_process_imfile.pl
r19652 r19942 16 16 use IPC::Cmd 0.36 qw( can_run run ); 17 17 use PS::IPP::Metadata::Config; 18 use PS::IPP::Metadata::Stats;19 18 use PS::IPP::Config 1.01 qw( :standard ); 20 19 … … 68 67 my $jpeg_recipe = $ipprc->reduction($reduction, uc($det_type) . '_JPEG_IMAGE'); # Recipe name for JPEG 69 68 70 # values to extract from output metadata and the stats to calculate71 my $STATS =72 [73 # PPSTATS KEYWORD STATISTIC CHIPTOOL FLAG74 { name => "ROBUST_MEDIAN", type => "mean", flag => "-bg", dtype => "float" },75 { name => "ROBUST_MEDIAN", type => "stdev", flag => "-bg_mean_stdev", dtype => "float" },76 { name => "ROBUST_STDEV", type => "rms", flag => "-bg_stdev", dtype => "float" },77 ];78 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser79 80 69 # Look for programs we need 81 70 my $missing_tools; 82 71 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 83 72 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 73 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 84 74 if ($missing_tools) { 85 75 warn("Can't find required tools."); … … 97 87 $ipprc->outroot_prepare($outroot); 98 88 89 my $cmdflags; 90 99 91 my $outputImage = $ipprc->filename("PPIMAGE.OUTPUT", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 100 92 my $outputBin1 = $ipprc->filename("PPIMAGE.BIN1", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); … … 107 99 $command .= " -recipe PPIMAGE $ppimage_recipe"; 108 100 $command .= " -recipe JPEG $jpeg_recipe"; 109 $command .= " -recipe PPSTATS CHIPSTATS";101 $command .= " -recipe PPSTATS DETSTATS"; 110 102 $command .= " -stats $outputStats"; 111 103 $command .= " -tracedest $traceDest -log $logDest"; … … 121 113 122 114 &my_die("Couldn't find expected output file: $outputImage", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputImage); 123 &my_die("Couldn't find expected output file: $outputStats", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats);124 115 &my_die("Couldn't find expected output file: $outputBin1", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin1); 125 116 &my_die("Couldn't find expected output file: $outputBin2", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin2); 126 117 127 # Get the statistics on the processed image 128 my $statsFile; # File handle 129 open $statsFile, $ipprc->file_resolve("$outputStats") or die "Can't open statistics file $outputStats: $!\n"; 130 my @contents = <$statsFile>; # Contents of file 131 close $statsFile; 118 my $outputStatsReal = $ipprc->file_resolve($outputStats); 119 &my_die("Couldn't find expected output file: $outputStats", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStatsReal; 132 120 133 # parse the statistics MDC file 134 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 135 my $metadata = $mdcParser->parse(join "", @contents) 136 or &my_die("Unable to parse metadata config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 137 138 # extract the stats from the metadata 139 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 121 # parse stats from metadata 122 $command = "$ppStatsFromMetadata $outputStatsReal - DETREND_PROCESS_IMFILE"; 123 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 124 run(command => $command, verbose => $verbose); 125 unless ($success) { 126 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 127 &my_die("Unable to perform ppStatsFromMetadata: $error_code", $det_id, $exp_id, $class_id, $error_code); 128 } 129 foreach my $line (@$stdout_buf) { 130 $cmdflags .= " $line"; 131 } 132 chomp $cmdflags; 140 133 } 141 134 … … 148 141 $command .= " -uri $outputImage -path_base $outroot"; 149 142 $command .= " -dbname $dbname" if defined $dbname; 150 $command .= $stats->cmdflags();143 $command .= " $cmdflags"; 151 144 152 145 # Add the processed file to the database -
trunk/ippScripts/scripts/detrend_resid_exp.pl
r19818 r19942 128 128 close $statFile; 129 129 130 # parse the stats in the metadata file 130 131 $command = "$ppStatsFromMetadata $statName - DETREND_RESID_EXP"; 131 132 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = -
trunk/ippScripts/scripts/detrend_stack.pl
r19374 r19942 16 16 use IPC::Cmd 0.36 qw( can_run run ); 17 17 use PS::IPP::Metadata::Config; 18 use PS::IPP::Metadata::Stats;19 18 use PS::IPP::Metadata::List qw( parse_md_list ); 20 19 use PS::IPP::Config 1.01 qw( :standard ); … … 67 66 my $recipe = $ipprc->reduction($reduction, $det_type . '_STACK'); # Recipe name to use 68 67 69 # values to extract from output metadata and the stats to calculate70 # XXX -bg_mean_stdev should take rms of bg_mean_stdev if bg_mean_stdev != 0 (A)71 # XXX -bg_mean_stdev should take stdev of bg_mean if bg_mean_stdev == 0 (B)72 # XXX (A) if imfile.Ncomp > 1, (B) if imfile.Ncomp == 173 my $STATS =74 [75 # KEYWORD STATISTIC DETTOOL FLAG76 { name => "ROBUST_MEDIAN", type => "clipmean", flag => "-bg", dtype => "float" },77 { name => "ROBUST_MEDIAN", type => "clipstdev", flag => "-bg_mean_stdev", dtype => "float" },78 { name => "ROBUST_STDEV", type => "rms", flag => "-bg_stdev", dtype => "float" },79 ];80 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser81 82 68 # Look for programs we need 83 69 my $missing_tools; 84 70 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 85 71 my $ppMerge = can_run('ppMerge') or (warn "Can't find ppMerge" and $missing_tools = 1); 72 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 86 73 if ($missing_tools) { 87 74 warn("Can't find required tools."); … … 112 99 113 100 # The stats recipe depends on the detrend type 114 my $STATRECIPES = {'FLATMASK' => ' CHIPSTATS',115 'DARKMASK' => ' CHIPSTATS',116 'MASK' => ' CHIPSTATS',117 'BIAS' => ' CHIPSTATS',101 my $STATRECIPES = {'FLATMASK' => 'DETSTATS', 102 'DARKMASK' => 'DETSTATS', 103 'MASK' => 'DETSTATS', 104 'BIAS' => 'DETSTATS', 118 105 'DARK' => 'DARKSTATS', 119 106 'DARK_PREMASK' => 'DARKSTATS', 120 107 'SHUTTER' => 'DARKSTATS', 121 'FLAT_PREMASK' => ' CHIPSTATS',122 'DOMEFLAT_PREMASK' => ' CHIPSTATS',123 'SKYFLAT_PREMASK' => ' CHIPSTATS',124 'FLAT_RAW' => ' CHIPSTATS',125 'DOMEFLAT_RAW' => ' CHIPSTATS',126 'SKYFLAT_RAW' => ' CHIPSTATS',127 'FLAT' => ' CHIPSTATS',128 'DOMEFLAT' => ' CHIPSTATS',129 'SKYFLAT' => ' CHIPSTATS',130 'FRINGE' => ' CHIPSTATS',108 'FLAT_PREMASK' => 'DETSTATS', 109 'DOMEFLAT_PREMASK' => 'DETSTATS', 110 'SKYFLAT_PREMASK' => 'DETSTATS', 111 'FLAT_RAW' => 'DETSTATS', 112 'DOMEFLAT_RAW' => 'DETSTATS', 113 'SKYFLAT_RAW' => 'DETSTATS', 114 'FLAT' => 'DETSTATS', 115 'DOMEFLAT' => 'DETSTATS', 116 'SKYFLAT' => 'DETSTATS', 117 'FRINGE' => 'DETSTATS', 131 118 }; 132 119 my $statrecipe = $STATRECIPES->{$det_type}; # File rule for output 120 121 my $cmdflags; 133 122 134 123 # Get list of files to stack … … 217 206 &my_die("Unable to find expected output file: $outputCount\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputCount); 218 207 &my_die("Unable to find expected output file: $outputSigma\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputSigma); 219 &my_die("Unable to find expected output file: $outputStats\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats); 220 221 # Get the statistics on the stacked image 222 open(my $statsFile, $ipprc->file_resolve("$outputStats")) or 223 &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR); 224 my $contents = do { local $/; <$statsFile> }; # Contents of file 225 close($statsFile); 226 227 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 228 my $metadata = $mdcParser->parse($contents) or 229 &my_die("Unable to parse metadata config doc", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR); 230 231 $stats->parse($metadata) or 232 &my_die("Unable to find all values in statistics output.", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR); 208 209 my $outputStatsReal = $ipprc->file_resolve($outputStats); 210 &my_die("Couldn't find expected output file: $outputStats", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStatsReal; 211 212 # parse stats from metadata 213 $command = "$ppStatsFromMetadata $outputStatsReal - DETREND_STACK"; 214 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 215 run(command => $command, verbose => $verbose); 216 unless ($success) { 217 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 218 &my_die("Unable to perform ppStatsFromMetadata: $error_code", $det_id, $iter, $class_id, $error_code); 219 } 220 foreach my $line (@$stdout_buf) { 221 $cmdflags .= " $line"; 222 } 223 chomp $cmdflags; 233 224 } 234 225 … … 241 232 $command .= " -recip $recipe"; 242 233 $command .= " -dbname $dbname" if defined $dbname; 243 $command .= $stats->cmdflags();234 $command .= " $cmdflags"; 244 235 245 236 # Add the resultant into the database
Note:
See TracChangeset
for help on using the changeset viewer.
