Changeset 17803 for trunk/ippScripts/scripts/camera_exp.pl
- Timestamp:
- May 23, 2008, 5:10:21 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/camera_exp.pl (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/camera_exp.pl
r17671 r17803 29 29 $no_op, $save_temps ); 30 30 GetOptions( 31 'exp_tag=s' => \$exp_tag, # Exposure identifier32 'cam_id=s' => \$cam_id, # Camtool identifier33 'recipe=s' => \$recipe, # Recipe to use34 'camera|c=s' => \$camera, # Camera35 'dbname|d=s' => \$dbname, # Database name36 'outroot|w=s' => \$outroot, # output file base name37 'reduction=s' => \$reduction, # Reduction class 38 'dvodb|w=s' => \$dvodb, # output DVO database39 'verbose' => \$verbose, # Print to stdout40 'no-update' => \$no_update, # Update the database?41 'no-op' => \$no_op, # Don't do any operations?42 'save-temps' => \$save_temps, # Save temporary files?43 ) or pod2usage( 2 );31 'exp_tag=s' => \$exp_tag, # Exposure identifier 32 'cam_id=s' => \$cam_id, # Camtool identifier 33 'recipe=s' => \$recipe, # Recipe to use 34 'camera|c=s' => \$camera, # Camera 35 'dbname|d=s' => \$dbname, # Database name 36 'outroot|w=s' => \$outroot, # output file base name 37 'reduction=s' => \$reduction, # Reduction class 38 'dvodb|w=s' => \$dvodb, # output DVO database 39 'verbose' => \$verbose, # Print to stdout 40 'no-update' => \$no_update, # Update the database? 41 'no-op' => \$no_op, # Don't do any operations? 42 'save-temps' => \$save_temps, # Save temporary files? 43 ) or pod2usage( 2 ); 44 44 45 45 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 46 46 pod2usage( 47 -msg => "Required options: --exp_tag --cam_id --camera --outroot",48 -exitval => 3,49 ) unless 47 -msg => "Required options: --exp_tag --cam_id --camera --outroot", 48 -exitval => 3, 49 ) unless 50 50 defined $exp_tag and 51 51 defined $cam_id and … … 66 66 # values to extract from output metadata and the stats to calculate 67 67 # these should be coming from the psastro results 68 my $CHIPSTATS = 69 [ 70 # PPSTATS KEYWORD STATISTIC CHIPTOOL FLAG71 { name => "bg", type => "mean", flag => "-bg",dtype => "float" },72 { name => "bg_stdev", type => "rms", flag => "-bg_stdev", dtype => "float" }, 73 { name => "bg_mean_stdev", type => "stdev", flag => "-bg_mean_stdev",dtype => "float" },74 { name => "bias", type => "mean", flag => "-bias", dtype => "float" }, 75 { name => "bias_stdev", type => "rms", flag => "-bias_stdev", dtype => "float" }, 76 { name => "fringe_0", type => "mean", flag => "-fringe_0", dtype => "float" },77 { name => "fringe_1", type => "rms", flag => "-fringe_1", dtype => "float" },78 { name => "fringe_0", type => "stdev", flag => "-fringe_2", dtype => "float" },79 { name => "sigma_ra", type => "rms", flag => "-sigma_ra", dtype => "float" }, 80 { name => "sigma_dec", type => "rms", flag => "-sigma_dec", dtype => "float" }, 81 { name => "ap_resid", type => "mean", flag => "-ap_resid", dtype => "float" }, 82 { name => "ap_resid_stdev", type => "rms", flag => "-ap_resid_stdev", dtype => "float" }, 83 { name => "zp_mean", type => "mean", flag => "-zp_mean", dtype => "float" }, 84 { name => "zp_stdev", type => "rms", flag => "-zp_stdev", dtype => "float" }, 85 { name => "fwhm_major", type => "mean", flag => "-fwhm_major", dtype => "float" }, 86 { name => "fwhm_minor", type => "mean", flag => "-fwhm_minor", dtype => "float" }, 87 { name => "dtime_detrend", type => "sum", flag => "-dtime_detrend", dtype => "float" }, 88 { name => "dtime_photom", type => "sum", flag => "-dtime_photom", dtype => "float" }, 89 { name => "dtime_astrom", type => "sum", flag => "-dtime_astrom", dtype => "float" }, 90 { name => "n_stars", type => "sum", flag => "-n_stars", dtype => "int" }, 91 { name => "n_extended", type => "sum", flag => "-n_extended", dtype => "int" }, 92 { name => "n_cr", type => "sum", flag => "-n_cr", dtype => "int" }, 93 { name => "n_astrom", type => "sum", flag => "-n_astrom", dtype => "int" }, 68 my $CHIPSTATS = 69 [ 70 # PPSTATS KEYWORD STATISTIC CHIPTOOL FLAG 71 { name => "bg", type => "mean", flag => "-bg", dtype => "float" }, 72 { name => "bg_stdev", type => "rms", flag => "-bg_stdev", dtype => "float" }, 73 { name => "bg_mean_stdev", type => "stdev", flag => "-bg_mean_stdev", dtype => "float" }, 74 { name => "bias", type => "mean", flag => "-bias", dtype => "float" }, 75 { name => "bias_stdev", type => "rms", flag => "-bias_stdev", dtype => "float" }, 76 { name => "fringe_0", type => "mean", flag => "-fringe_0", dtype => "float" }, 77 { name => "fringe_1", type => "rms", flag => "-fringe_1", dtype => "float" }, 78 { name => "fringe_0", type => "stdev", flag => "-fringe_2", dtype => "float" }, 79 { name => "sigma_ra", type => "rms", flag => "-sigma_ra", dtype => "float" }, 80 { name => "sigma_dec", type => "rms", flag => "-sigma_dec", dtype => "float" }, 81 { name => "ap_resid", type => "mean", flag => "-ap_resid", dtype => "float" }, 82 { name => "ap_resid_stdev", type => "rms", flag => "-ap_resid_stdev", dtype => "float" }, 83 { name => "zp_mean", type => "mean", flag => "-zp_mean", dtype => "float" }, 84 { name => "zp_stdev", type => "rms", flag => "-zp_stdev", dtype => "float" }, 85 { name => "fwhm_major", type => "mean", flag => "-fwhm_major", dtype => "float" }, 86 { name => "fwhm_minor", type => "mean", flag => "-fwhm_minor", dtype => "float" }, 87 { name => "dtime_detrend", type => "sum", flag => "-dtime_detrend", dtype => "float" }, 88 { name => "dtime_photom", type => "sum", flag => "-dtime_photom", dtype => "float" }, 89 { name => "dtime_astrom", type => "sum", flag => "-dtime_astrom", dtype => "float" }, 90 { name => "n_stars", type => "sum", flag => "-n_stars", dtype => "int" }, 91 { name => "n_extended", type => "sum", flag => "-n_extended", dtype => "int" }, 92 { name => "n_cr", type => "sum", flag => "-n_cr", dtype => "int" }, 93 { name => "n_astrom", type => "sum", flag => "-n_astrom", dtype => "int" }, 94 94 95 95 96 96 # these are not defined for the database table camProcessedExp 97 ];97 ]; 98 98 my $chipStats = PS::IPP::Metadata::Stats->new($CHIPSTATS); # Stats parser 99 99 … … 108 108 my $addstar = can_run('addstar') or (warn "Can't find addstar" and $missing_tools = 1); 109 109 110 if ($missing_tools) { 110 if ($missing_tools) { 111 111 warn("Can't find required tools."); 112 exit($PS_EXIT_CONFIG_ERROR); 113 } 114 115 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files112 exit($PS_EXIT_CONFIG_ERROR); 113 } 114 115 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 116 116 117 117 # Get list of component files 118 my $files; # Array of component files118 my $files; # Array of component files 119 119 { 120 120 my $command = "$camtool -pendingimfile -cam_id $cam_id"; # Command to run 121 121 $command .= " -dbname $dbname" if defined $dbname; 122 122 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 123 run(command => $command, verbose => $verbose);123 run(command => $command, verbose => $verbose); 124 124 unless ($success) { 125 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);126 &my_die("Unable to perform camtool: $error_code", $cam_id, $error_code);125 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 126 &my_die("Unable to perform camtool: $error_code", $cam_id, $error_code); 127 127 } 128 128 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 129 &my_die("Unable to parse metadata config doc", $cam_id, $PS_EXIT_PROG_ERROR);129 &my_die("Unable to parse metadata config doc", $cam_id, $PS_EXIT_PROG_ERROR); 130 130 131 131 # extract the metadata for the files into a hash list 132 132 $files = parse_md_list($metadata) or 133 &my_die("Unable to parse metadata list", $cam_id, $PS_EXIT_PROG_ERROR);133 &my_die("Unable to parse metadata list", $cam_id, $PS_EXIT_PROG_ERROR); 134 134 135 135 # extract the stats from the metadata 136 136 unless ($chipStats->parse($metadata)) { 137 &my_die("Unable to find all values in statistics output.\n", $cam_id, $PS_EXIT_PROG_ERROR);137 &my_die("Unable to find all values in statistics output.\n", $cam_id, $PS_EXIT_PROG_ERROR); 138 138 } 139 139 } … … 145 145 146 146 # XXX we perform astrometry iff photometry output exists 147 my $chipObjects; 147 my $chipObjects; 148 148 my $chipObjectsExist = 0; 149 149 foreach my $file (@$files) { … … 160 160 # if any of the output chip photometry files exist, we can run psastro / addstar below 161 161 if ($ipprc->file_exists($chipObjects)) { 162 $chipObjectsExist = 1;162 $chipObjectsExist = 1; 163 163 } 164 164 } … … 171 171 172 172 # the camera configurations should define the psastro output to be a single file (MEF), regardless of the inputs 173 my $jpeg1 = $ipprc->filename("PPIMAGE.JPEG1", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR);174 my $jpeg2 = $ipprc->filename("PPIMAGE.JPEG2", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR);173 my $jpeg1 = $ipprc->filename("PPIMAGE.JPEG1", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR); 174 my $jpeg2 = $ipprc->filename("PPIMAGE.JPEG2", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR); 175 175 my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR); 176 176 my $traceDest = $ipprc->filename("TRACE.EXP", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR); 177 my $logDest = $ipprc->filename("LOG.EXP", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR);177 my $logDest = $ipprc->filename("LOG.EXP", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR); 178 178 179 179 # convert supplied DVO database name to UNIX filename … … 190 190 # Make the jpeg for binning 1 191 191 { 192 my $command = "$ppImage -list $list1Name $outroot -recipe PPIMAGE $recipe1"; # Command to run193 $command .= " -dbname $dbname" if defined $dbname;194 195 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =196 run(command => $command, verbose => $verbose);197 unless ($success) {198 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);199 &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code);200 }201 &my_die("Unable to find expected output file: $jpeg1", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($jpeg1);192 my $command = "$ppImage -list $list1Name $outroot -recipe PPIMAGE $recipe1"; # Command to run 193 $command .= " -dbname $dbname" if defined $dbname; 194 195 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 196 run(command => $command, verbose => $verbose); 197 unless ($success) { 198 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 199 &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code); 200 } 201 &my_die("Unable to find expected output file: $jpeg1", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($jpeg1); 202 202 } 203 203 204 204 # Make the jpeg for binning 2 205 205 { 206 my $command = "$ppImage -list $list2Name $outroot -recipe PPIMAGE $recipe2"; # Command to run207 $command .= " -dbname $dbname" if defined $dbname;208 209 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =210 run(command => $command, verbose => $verbose);211 unless ($success) {212 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);213 &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code);214 }215 &my_die("Unable to find expected output file: $jpeg2", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($jpeg2);206 my $command = "$ppImage -list $list2Name $outroot -recipe PPIMAGE $recipe2"; # Command to run 207 $command .= " -dbname $dbname" if defined $dbname; 208 209 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 210 run(command => $command, verbose => $verbose); 211 unless ($success) { 212 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 213 &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code); 214 } 215 &my_die("Unable to find expected output file: $jpeg2", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($jpeg2); 216 216 } 217 217 218 218 # only run psastro / addstar if any of the output chip astrometry files exist (should we test for successful astrometry?) 219 219 if ($chipObjectsExist) { 220 # run psastro on the chipObjects, producing fpaObjects221 # XXX add a ppStats call which will collect the astrometry stats222 my $command;223 $command = "$psastro -list $list3Name $outroot";224 $command .= " -tracedest $traceDest -log $logDest";225 $command .= " -dbname $dbname" if defined $dbname;226 227 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =228 run(command => $command, verbose => $verbose);229 unless ($success) {230 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);231 &my_die("Unable to perform psastro: $error_code", $cam_id, $error_code);232 }233 # XXX do we want to give an error if astrometry fails here?234 &my_die("Unable to find expected output file: $fpaObjects", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($fpaObjects);235 236 # run addstar on the output fpaObjects (if a DVO database is defined)237 if (defined $dvodbReal) {238 # XXX this construct requires the user to have a valid .ptolemyrc 239 # XXX which in turn points at ippconfig/dvo.site240 # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default)241 # XXX this needs to be converted to addstar_client...242 243 my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar244 my $command;245 $command = "$addstar -D CAMERA $camdir -update";246 $command .= " -D CATDIR $dvodbReal";247 248 my $realFile = $ipprc->file_resolve($fpaObjects);249 $command .= " $realFile";250 251 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =252 run(command => $command, verbose => $verbose);253 unless ($success) {254 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);255 &my_die("Unable to perform addstar: $error_code", $cam_id, $error_code);256 }257 }220 # run psastro on the chipObjects, producing fpaObjects 221 # XXX add a ppStats call which will collect the astrometry stats 222 my $command; 223 $command = "$psastro -list $list3Name $outroot"; 224 $command .= " -tracedest $traceDest -log $logDest"; 225 $command .= " -dbname $dbname" if defined $dbname; 226 227 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 228 run(command => $command, verbose => $verbose); 229 unless ($success) { 230 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 231 &my_die("Unable to perform psastro: $error_code", $cam_id, $error_code); 232 } 233 # XXX do we want to give an error if astrometry fails here? 234 &my_die("Unable to find expected output file: $fpaObjects", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($fpaObjects); 235 236 # run addstar on the output fpaObjects (if a DVO database is defined) 237 if (defined $dvodbReal) { 238 # XXX this construct requires the user to have a valid .ptolemyrc 239 # XXX which in turn points at ippconfig/dvo.site 240 # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default) 241 # XXX this needs to be converted to addstar_client... 242 243 my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar 244 my $command; 245 $command = "$addstar -D CAMERA $camdir -update"; 246 $command .= " -D CATDIR $dvodbReal"; 247 248 my $realFile = $ipprc->file_resolve($fpaObjects); 249 $command .= " $realFile"; 250 251 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 252 run(command => $command, verbose => $verbose); 253 unless ($success) { 254 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 255 &my_die("Unable to perform addstar: $error_code", $cam_id, $error_code); 256 } 257 } 258 258 } 259 259 } … … 263 263 $fpaCommand .= " -uri UNKNOWN"; 264 264 $fpaCommand .= " -path_base $outroot"; 265 $fpaCommand .= " -hostname $host" if defined $host; 265 266 $fpaCommand .= " -dbname $dbname" if defined $dbname; 266 267 $fpaCommand .= $chipStats->cmdflags(); … … 269 270 unless ($no_update) { 270 271 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 271 run(command => $fpaCommand, verbose => $verbose);272 run(command => $fpaCommand, verbose => $verbose); 272 273 unless ($success) { 273 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);274 warn("Unable to add result to database: $error_code\n");275 exit($error_code);274 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 275 warn("Unable to add result to database: $error_code\n"); 276 exit($error_code); 276 277 } 277 278 } else { … … 288 289 carp($msg); 289 290 if (defined $cam_id and not $no_update) { 290 my $command = "$camtool -addprocessedexp -cam_id $cam_id -uri UNKNOWN -code $exit_code"; 291 $command .= " -dbname $dbname" if defined $dbname; 291 my $command = "$camtool -addprocessedexp -cam_id $cam_id -uri UNKNOWN -code $exit_code"; 292 $command .= " -hostname $host" if defined $host; 293 $command .= " -dbname $dbname" if defined $dbname; 292 294 system ($command); 293 295 }
Note:
See TracChangeset
for help on using the changeset viewer.
