Changeset 19561 for trunk/ippScripts/scripts/camera_exp.pl
- Timestamp:
- Sep 15, 2008, 2:24:27 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
r19466 r19561 27 27 28 28 my ( $exp_tag, $cam_id, $camera, $outroot, $recipe, $dbname, $reduction, $dvodb, $verbose, $no_update, 29 $no_op, $redirect, $save_temps );29 $no_op, $redirect, $save_temps, $run_state); 30 30 GetOptions( 31 31 'exp_tag=s' => \$exp_tag, # Exposure identifier … … 37 37 'reduction=s' => \$reduction, # Reduction class 38 38 'dvodb|w=s' => \$dvodb, # output DVO database 39 'run-state=s' => \$run_state, # 'new' or 'update' 39 40 'verbose' => \$verbose, # Print to stdout 40 41 'no-update' => \$no_update, # Update the database? … … 57 58 58 59 my $logDest = $ipprc->filename("LOG.EXP", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR); 60 if ($run_state eq 'update') { 61 $logDest .= '.update'; 62 } 59 63 60 64 $ipprc->redirect_output($logDest) if $redirect; … … 196 200 my $fpaStats = $ipprc->filename("PSASTRO.STATS", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR); 197 201 my $traceDest = $ipprc->filename("TRACE.EXP", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR); 202 my $configuration = $ipprc->filename("PSASTRO.CONFIG", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR); 203 204 if ($run_state eq 'update') { 205 $traceDest .= '.update'; 206 $fpaStats .= '.update'; 207 } 198 208 199 209 # convert supplied DVO database name to UNIX filename … … 210 220 211 221 # Make the jpeg for binning 1 212 {222 if ($run_state eq 'new') { 213 223 my $command = "$ppImage -list $list1Name $outroot -recipe PPIMAGE $recipe1"; # Command to run 214 224 $command .= " -dbname $dbname" if defined $dbname; … … 224 234 225 235 # Make the jpeg for binning 2 226 {236 if ($run_state eq 'new') { 227 237 my $command = "$ppImage -list $list2Name $outroot -recipe PPIMAGE $recipe2"; # Command to run 228 238 $command .= " -dbname $dbname" if defined $dbname; … … 244 254 $command = "$psastro -list $list3Name $outroot"; 245 255 $command .= " -tracedest $traceDest -log $logDest"; 246 $command .= " -stats $fpaStats -recipe PPSTATS CHIPSTATS";247 256 $command .= " -dbname $dbname" if defined $dbname; 257 258 my $do_stats; 259 if ($run_state eq 'new') { 260 $command .= " -stats $fpaStats -recipe PPSTATS CHIPSTATS"; 261 $command .= " -dumpconfig $configuration"; 262 $do_stats = 1; 263 } elsif ($run_state eq 'update') { 264 $command .= " -ipprc $configuration"; 265 } else { 266 &my_die("invalid value for run-state: $run_state", $cam_id, $PS_EXIT_CONFIG_ERROR); 267 } 248 268 249 269 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 255 275 # XXX do we want to give an error if astrometry fails here? 256 276 &my_die("Unable to find expected output file: $fpaObjects", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($fpaObjects); 257 &my_die("Unable to find expected output file: $fpaStats", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($fpaObjects); 258 259 # Get the statistics on the processed image 260 my $statsFile; # File handle 261 open $statsFile, $ipprc->file_resolve($fpaStats) or &my_die("Can't open statistics file $fpaStats: $!", $cam_id, $PS_EXIT_SYS_ERROR); 262 my @contents = <$statsFile>; # Contents of file 263 close $statsFile; 264 265 # parse the statistics MDC file 266 my $mdcParser = PS::IPP::Metadata::Config->new(); # Parser for metadata config files 267 my $metadata = $mdcParser->parse(join "", @contents); 268 unless ($metadata) { 269 &my_die("Unable to parse metadata config doc", $cam_id, $PS_EXIT_PROG_ERROR); 270 } 271 272 # extract the stats from the metadata 273 unless ($camStats->parse($metadata)) { 274 &my_die("Failure extracting metadata from the statistics output file.\n", $cam_id, $PS_EXIT_PROG_ERROR); 277 278 if ($do_stats) { 279 &my_die("Unable to find expected output file: $fpaStats", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($fpaObjects); 280 281 # Get the statistics on the processed image 282 my $statsFile; # File handle 283 open $statsFile, $ipprc->file_resolve($fpaStats) or &my_die("Can't open statistics file $fpaStats: $!", $cam_id, $PS_EXIT_SYS_ERROR); 284 my @contents = <$statsFile>; # Contents of file 285 close $statsFile; 286 287 # parse the statistics MDC file 288 my $mdcParser = PS::IPP::Metadata::Config->new(); # Parser for metadata config files 289 my $metadata = $mdcParser->parse(join "", @contents); 290 unless ($metadata) { 291 &my_die("Unable to parse metadata config doc", $cam_id, $PS_EXIT_PROG_ERROR); 292 } 293 294 # extract the stats from the metadata 295 unless ($camStats->parse($metadata)) { 296 &my_die("Failure extracting metadata from the statistics output file.\n", $cam_id, $PS_EXIT_PROG_ERROR); 297 } 275 298 } 276 299 277 300 # run addstar on the output fpaObjects (if a DVO database is defined) 278 if (defined $dvodbReal ) {301 if (defined $dvodbReal and ($run_state eq 'new')) { 279 302 280 303 ## XXX the camera analysis can either save the full set of … … 319 342 } 320 343 321 my $fpaCommand = "$camtool -addprocessedexp"; 322 $fpaCommand .= " -cam_id $cam_id"; 323 $fpaCommand .= " -uri UNKNOWN"; 324 $fpaCommand .= " -path_base $outroot"; 325 $fpaCommand .= " -hostname $host" if defined $host; 344 345 my $fpaCommand = "$camtool -cam_id $cam_id"; 346 if ($run_state eq 'new') { 347 $fpaCommand .= " -addprocessedexp"; 348 $fpaCommand .= " -uri UNKNOWN"; 349 $fpaCommand .= " -path_base $outroot"; 350 $fpaCommand .= $chipStats->cmdflags(); 351 $fpaCommand .= $camStats->cmdflags(); 352 $fpaCommand .= " -hostname $host" if defined $host; 353 } else { 354 $fpaCommand .= " -updaterun -state full"; 355 } 326 356 $fpaCommand .= " -dbname $dbname" if defined $dbname; 327 $fpaCommand .= $chipStats->cmdflags();328 $fpaCommand .= $camStats->cmdflags();329 357 330 358 # Add the result into the database … … 350 378 carp($msg); 351 379 if (defined $cam_id and not $no_update) { 352 my $command = "$camtool -addprocessedexp"; 353 $command .= " -cam_id $cam_id"; 354 $command .= " -uri UNKNOWN"; 355 $command .= " -code $exit_code"; 356 $command .= " -path_base $outroot"; 380 my $command = "$camtool -cam_id $cam_id"; 381 if ($run_state eq 'new') { 382 $command .= " -addprocessedexp"; 383 $command .= " -uri UNKNOWN"; 384 $command .= " -code $exit_code"; 385 $command .= " -path_base $outroot"; 386 $command .= " -path_base $outroot" if defined $outroot; 387 } else { 388 $command .= " -updateprocessedexp"; 389 $command .= " -code $exit_code"; 390 } 357 391 $command .= " -hostname $host" if defined $host; 358 392 $command .= " -dbname $dbname" if defined $dbname; 359 $command .= " -path_base $outroot" if defined $outroot;360 393 system ($command); 361 394 }
Note:
See TracChangeset
for help on using the changeset viewer.
