Changeset 19561
- Timestamp:
- Sep 15, 2008, 2:24:27 PM (18 years ago)
- Location:
- trunk/ippScripts/scripts
- Files:
-
- 4 edited
-
camera_exp.pl (modified) (10 diffs)
-
ipp_cleanup.pl (modified) (8 diffs)
-
stack_skycell.pl (modified) (2 diffs)
-
warp_skycell.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 } -
trunk/ippScripts/scripts/ipp_cleanup.pl
r19397 r19561 50 50 } 51 51 52 my %stages = ( chip => 1, camera => 1, fake => 1, warp => 1, stack => 1, diff => 1); 53 unless ($stages{$stage}) { 54 die "unknown stage $stage for ipp_cleanup.pl\n"; 55 } 56 52 57 $ipprc->define_camera($camera); 53 58 54 59 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 55 56 my $fault = 0;57 60 58 61 # choice of files to delete depends on the stage 59 62 if ($stage eq "chip") { 60 63 64 die "--stage_id required for stage chip\n" if !$stage_id; 61 65 ### select the imfiles for this entry 62 66 … … 85 89 my $class_id = $imfile->{class_id}; 86 90 my $path_base = $imfile->{path_base}; 87 88 # array of actual filenames to delete 89 my @files = (); 90 91 # delete the temporary image datafiles 92 addFilename (\@files, "PPIMAGE.OUTPUT", $path_base, $class_id); 93 addFilename (\@files, "PPIMAGE.OUTPUT.MASK", $path_base, $class_id); 94 addFilename (\@files, "PPIMAGE.OUTPUT.WEIGHT", $path_base, $class_id); 95 addFilename (\@files, "PPIMAGE.CHIP", $path_base, $class_id); 96 addFilename (\@files, "PPIMAGE.CHIP.MASK", $path_base, $class_id); 97 addFilename (\@files, "PPIMAGE.CHIP.WEIGHT", $path_base, $class_id); 98 if ($mode eq "goto_purged") { 99 # additional files to remove for 'purge' mode 100 addFilename (\@files, "PPIMAGE.OUTPUT.FPA1", $path_base, $class_id); 101 addFilename (\@files, "PPIMAGE.OUTPUT.FPA2", $path_base, $class_id); 102 addFilename (\@files, "PPIMAGE.BIN1", $path_base, $class_id); 103 addFilename (\@files, "PPIMAGE.BIN2", $path_base, $class_id); 104 addFilename (\@files, "PPIMAGE.JPEG1", $path_base, $class_id); 105 addFilename (\@files, "PPIMAGE.JPEG", $path_base, $class_id); 106 addFilename (\@files, "PPIMAGE.STATS", $path_base, $class_id); 107 } 91 my $status = 1; 92 93 # don't clean up unless the data needed to update is available 94 if ($mode eq "goto_cleaned") { 95 my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base, $class_id); 96 97 if (!$config_file or ! -e $config_file) { 98 print STDERR "skipping cleanup for chipRun $stage_id $class_id " 99 . " because config file is missing\n"; 100 $status = 0; 101 } 102 } 103 104 if ($status) { 105 # array of actual filenames to delete 106 my @files = (); 107 108 # delete the temporary image datafiles 109 addFilename (\@files, "PPIMAGE.OUTPUT", $path_base, $class_id); 110 addFilename (\@files, "PPIMAGE.OUTPUT.MASK", $path_base, $class_id); 111 addFilename (\@files, "PPIMAGE.OUTPUT.WEIGHT", $path_base, $class_id); 112 addFilename (\@files, "PPIMAGE.CHIP", $path_base, $class_id); 113 addFilename (\@files, "PPIMAGE.CHIP.MASK", $path_base, $class_id); 114 addFilename (\@files, "PPIMAGE.CHIP.WEIGHT", $path_base, $class_id); 115 if ($mode eq "goto_purged") { 116 # additional files to remove for 'purge' mode 117 addFilename (\@files, "PPIMAGE.OUTPUT.FPA1", $path_base, $class_id); 118 addFilename (\@files, "PPIMAGE.OUTPUT.FPA2", $path_base, $class_id); 119 addFilename (\@files, "PPIMAGE.BIN1", $path_base, $class_id); 120 addFilename (\@files, "PPIMAGE.BIN2", $path_base, $class_id); 121 addFilename (\@files, "PPIMAGE.JPEG1", $path_base, $class_id); 122 addFilename (\@files, "PPIMAGE.JPEG", $path_base, $class_id); 123 addFilename (\@files, "PPIMAGE.STATS", $path_base, $class_id); 124 addFilename (\@files, "PPIMAGE.CONFIG", $path_base, $class_id); 125 } 108 126 109 # actual command to delete the files 110 my $status = &delete_files (\@files); 127 # actual command to delete the files 128 $status = &delete_files (\@files); 129 } 111 130 112 131 if ($status) { … … 119 138 $command .= " -dbname $dbname" if defined $dbname; 120 139 121 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose); 140 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 141 run(command => $command, verbose => $verbose); 122 142 unless ($success) { 123 143 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); … … 125 145 } 126 146 } else { 127 my $command = "$chiptool -update imfile -chip_id $stage_id -class_id $class_id -code 1";147 my $command = "$chiptool -updateprocessedimfile -chip_id $stage_id -class_id $class_id -code 1"; 128 148 $command .= " -dbname $dbname" if defined $dbname; 129 149 130 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose); 150 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 151 run(command => $command, verbose => $verbose); 131 152 unless ($success) { 132 153 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 133 154 &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code); 134 155 } 135 $fault = 1;136 156 } 137 157 } 138 158 139 if (0) { 140 # This block is not necessary 141 # chiptool -tocleanedimfile and -topurgedimfile automatically update chipRun when the 142 # last image gets set to purged or cleaned 143 144 if (! $fault) { 145 # set the state of the chipRun entry to "cleaned" or "purged" as needed 146 my $command = "$chiptool -updaterun -chip_id $stage_id"; 147 if ($mode eq "goto_purged") { 148 $command .= " -state purged"; 149 } else { 150 $command .= " -state cleaned"; 151 } 152 $command .= " -dbname $dbname" if defined $dbname; 153 154 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose); 155 unless ($success) { 156 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 157 &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code); 158 } 159 } 160 } 161 exit 0; 162 } 163 164 # choice of files to delete depends on the stage 165 if ($stage eq "camera") { 159 } elsif ($stage eq "camera") { 160 die "--stage_id required for stage camera\n" if !$stage_id; 166 161 # this stage uses 'camtool' 167 162 my $camtool = can_run('camtool') or die "Can't find camtool"; … … 169 164 # Get list of component imfiles 170 165 # XXX may need a different my_die for each stage 171 my $ imfiles; # Array of component files166 my $exps; # Array of component files 172 167 my $command = "$camtool -pendingcleanupexp -cam_id $stage_id"; # Command to run 173 168 $command .= " -dbname $dbname" if defined $dbname; … … 175 170 unless ($success) { 176 171 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 177 &my_die("Unable to perform camtool: $error_code", "cam ", $stage_id, $error_code);172 &my_die("Unable to perform camtool: $error_code", "camera", $stage_id, $error_code); 178 173 } 179 174 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 180 &my_die("Unable to parse metadata config doc", "cam", $stage_id, $PS_EXIT_PROG_ERROR); 181 175 &my_die("Unable to parse metadata config doc", "camera", $stage_id, $PS_EXIT_PROG_ERROR); 176 177 $exps = parse_md_list($metadata) or 178 &my_die("Unable to parse metadata list", "camera", $stage_id, $PS_EXIT_PROG_ERROR); 179 180 my $n_exps = @$exps; 181 &my_die("unexpected number of exposures $n_exps", "camera", $stage_id, $PS_EXIT_PROG_ERROR) 182 if $n_exps != 1; 183 184 my $exp = $exps->[0]; 185 my $path_base = $exp->{path_base}; 186 187 my $status = 1; 188 # don't clean up unless the data needed to update is available 189 if ($mode eq "goto_cleaned") { 190 my $config_file = $ipprc->filename("PSASTRO.CONFIG", $path_base); 191 192 if (!$config_file or ! -e $config_file) { 193 print STDERR "skipping cleanup for camRun $stage_id because config file is missing\n"; 194 $status = 0; 195 } 196 } 197 if ($status) { 198 my @files = (); 199 # delete the temporary image datafiles 200 addFilename (\@files, "PSASTRO.OUTPUT", $path_base); 201 if ($mode eq "goto_purged") { 202 # additional files to remove for 'purge' mode 203 addFilename (\@files, "PPIMAGE.JPEG1", $path_base); 204 addFilename (\@files, "PPIMAGE.JPEG2", $path_base); 205 addFilename (\@files, "PSASTRO.STATS", $path_base); 206 } 207 # actual command to delete the files 208 $status = &delete_files (\@files); 209 } 210 211 if ($status) { 212 my $command = "$camtool -cam_id $stage_id -updaterun"; 213 if ($mode eq "goto_cleaned") { 214 $command .= " -state cleaned"; 215 } else { 216 $command .= " -state purged"; 217 } 218 $command .= " -dbname $dbname" if defined $dbname; 219 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 220 run(command => $command, verbose => $verbose); 221 unless ($success) { 222 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 223 &my_die("Unable to perform camtool: $error_code", "camera", $stage_id, $error_code); 224 } 225 } else { 226 my $command = "$camtool -updateprocessedexp -cam_id $stage_id -code 1"; 227 $command .= " -dbname $dbname" if defined $dbname; 228 229 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 230 run(command => $command, verbose => $verbose); 231 unless ($success) { 232 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 233 &my_die("Unable to perform camtool: $error_code", "camera", $stage_id, $error_code); 234 } 235 exit $PS_EXIT_UNKNOWN_ERROR; 236 } 182 237 exit 0; 183 } 184 238 } elsif ($stage eq "warp") { 239 die "--stage_id required for stage warp\n" if !$stage_id; 240 # this stage uses 'warptool' 241 my $warptool = can_run('warptool') or die "Can't find warptool"; 242 243 # Get list of component imfiles 244 # XXX may need a different my_die for each stage 245 my $skyfiles; # Array of component files 246 my $command = "$warptool -pendingcleanupskyfile -warp_id $stage_id"; # Command to run 247 $command .= " -dbname $dbname" if defined $dbname; 248 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 249 run(command => $command, verbose => $verbose); 250 unless ($success) { 251 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 252 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code); 253 } 254 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 255 &my_die("Unable to parse metadata config doc", "warp", $stage_id, $PS_EXIT_PROG_ERROR); 256 257 $skyfiles = parse_md_list($metadata) or 258 &my_die("Unable to parse metadata list", "warp", $stage_id, $PS_EXIT_PROG_ERROR); 259 260 my @files = (); 261 foreach my $skyfile (@$skyfiles) { 262 my $path_base = $skyfile->{path_base}; 263 my $skycell_id = $skyfile->{skycell_id}; 264 265 my $status = 1; 266 if ($mode eq "goto_cleaned") { 267 my $config_file = $ipprc->filename("PSWARP.CONFIG", $path_base, $skycell_id); 268 269 if (!$config_file or ! -e $config_file) { 270 print STDERR "skipping cleanup for warpRun $stage_id $skycell_id" . 271 " because config file is missing\n"; 272 $status = 0; 273 } 274 } 275 if ($status) { 276 # delete the temporary image datafiles 277 addFilename(\@files, "PSWARP.OUTPUT", $path_base, $skycell_id ); 278 addFilename(\@files, "PSWARP.OUTPUT.MASK", $path_base, $skycell_id); 279 addFilename(\@files, "PSWARP.OUTPUT.WEIGHT", $path_base, $skycell_id); 280 addFilename(\@files, "PSWARP.OUTPUT.SOURCES", $path_base, $skycell_id); 281 282 if ($mode eq "goto_purged") { 283 # additional files to remove for 'purge' mode 284 addFilename(\@files, "PSWARP.BIN1", $path_base, $skycell_id ); 285 addFilename(\@files, "PSWARP.BIN2", $path_base, $skycell_id ); 286 addFilename(\@files, "SKYCELL.STATS", $path_base, $skycell_id ); 287 # addFilename(\@files, "PSPHOT.PSF.SKY.SAVE", $path_base); 288 289 # XXX: do we want to delete these? 290 # addFilename(\@files, "TRACE.EXP", $path_base, $skycell_id); 291 # addFilename(\@files, "PSWARP.CONFIG", $path_base, $skycell_id); 292 } 293 # actual command to delete the files 294 $status = &delete_files (\@files); 295 } 296 297 if ($status) { 298 my $command = "$warptool -warp_id $stage_id -skycell_id $skycell_id"; 299 if ($mode eq "goto_purged") { 300 $command .= " -topurgedskyfile"; 301 } else { 302 $command .= " -tocleanedskyfile"; 303 } 304 $command .= " -dbname $dbname" if defined $dbname; 305 306 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 307 run(command => $command, verbose => $verbose); 308 unless ($success) { 309 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 310 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code); 311 } 312 } else { 313 # XXX: -updateskyfile mode does not exist, need to add it 314 my $command = "$warptool -updateskyfile -warp_id $stage_id -skycell_id $skycell_id -code 1"; 315 $command .= " -dbname $dbname" if defined $dbname; 316 317 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 318 run(command => $command, verbose => $verbose); 319 unless ($success) { 320 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 321 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code); 322 } 323 exit $PS_EXIT_UNKNOWN_ERROR; 324 } 325 } 326 exit 0; 327 } 328 329 # left TODO 185 330 # fake : faketool : -pendingcleanupimfile (loop over imfiles) 186 # warp : warptool : -pendingcleanupskyfile (loop over skyfiles)187 188 die "unknown stage for ipp_cleanup.pl\n"; 189 exit 1;331 # stack: stacktool : -pendingcleanupskyfile (loop over skyfiles) 332 # diff: difftool : -pendingcleanupskyfile 333 334 die "ipp_cleanup.pl -stage $stage not yet implemented\n"; 190 335 191 336 sub delete_files … … 196 341 foreach my $file (@$files) { 197 342 print STDERR "unlinking $file\n"; 343 # XXX: need to handle files in nebulous 198 344 unlink $file; 199 345 } … … 217 363 { 218 364 my $msg = shift; # Warning message on die 219 my $stage = shift; # Chiptool identifier220 my $stage_id = shift; # Chiptoolidentifier221 my $exit_code = shift; # Exit code to add222 # outputImage and outrootare globals365 my $stage = shift; # stage name 366 my $stage_id = shift; # identifier 367 my $exit_code = shift; # Exit code 368 # outputImage and path_base are globals 223 369 224 370 carp($msg); -
trunk/ippScripts/scripts/stack_skycell.pl
r19545 r19561 28 28 use Pod::Usage qw( pod2usage ); 29 29 30 my ($stack_id, $dbname, $outroot, $debug, $ threads, $verbose, $no_update, $no_op, $redirect, $save_temps);30 my ($stack_id, $dbname, $outroot, $debug, $run_state, $threads, $verbose, $no_update, $no_op, $redirect, $save_temps); 31 31 GetOptions( 32 32 'stack_id|d=s' => \$stack_id, # Stack identifier 33 33 'dbname|d=s' => \$dbname, # Database name 34 34 'outroot=s' => \$outroot, # Output root name 35 'run-state=s' => \$run_state, 35 36 'debug' => \$debug, # Print to stdout 36 37 'threads=s' => \$threads, # Number of threads to use for ppStack … … 44 45 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 45 46 pod2usage( 46 -msg => "Required options: --stack_id --outroot ",47 -msg => "Required options: --stack_id --outroot --run-state", 47 48 -exitval => 3, 48 49 ) unless defined $stack_id 49 and defined $outroot; 50 and defined $outroot 51 and defined $run_state; 50 52 51 53 # XXX camera is not known here; cannot use filerules... -
trunk/ippScripts/scripts/warp_skycell.pl
r19396 r19561 25 25 my $ipprc = PS::IPP::Config->new(); # IPP configuration 26 26 27 my ($warp_id, $skycell_id, $tess_dir, $camera, $dbname, $outroot, $threads, $ verbose, $no_update, $no_op, $redirect, $save_temps);27 my ($warp_id, $skycell_id, $tess_dir, $camera, $dbname, $outroot, $threads, $run_state, $verbose, $no_update, $no_op, $redirect, $save_temps); 28 28 GetOptions( 29 29 'warp_id|i=s' => \$warp_id, # Warp identifier … … 33 33 'dbname|d=s' => \$dbname, # Database name 34 34 'outroot=s' => \$outroot, # Output root name 35 'threads=s' => \$threads, # Number of threads to use for ppImage 35 'threads=s' => \$threads, # Number of threads to use for pswarp 36 'run-state=s' => \$run_state, # 'new' or 'update' 36 37 'verbose' => \$verbose, # Print to stdout 37 38 'no-update' => \$no_update, # Don't update the database? … … 43 44 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 44 45 pod2usage( 45 -msg => "Required options: --warp_id --skycell_id --tess_dir --camera --outroot ",46 -msg => "Required options: --warp_id --skycell_id --tess_dir --camera --outroot --run-state", 46 47 -exitval => 3, 47 48 ) unless defined $warp_id … … 49 50 and defined $tess_dir 50 51 and defined $camera 51 and defined $outroot; 52 and defined $outroot 53 and defined $run_state; 52 54 53 55 $ipprc->define_camera($camera); 54 56 55 57 my $logDest = $ipprc->filename("LOG.EXP", $outroot, $skycell_id); 58 $logDest .= ".update" if ($run_state eq 'update'); 56 59 57 60 $ipprc->redirect_output($logDest) if $redirect; … … 127 130 my $configuration = $ipprc->filename("PSWARP.CONFIG", $outroot, $skycell_id); 128 131 132 if ($run_state eq 'update') { 133 $traceDest .= ".update"; 134 $outputStats .= ".update"; 135 } 136 129 137 my $skyFile = $ipprc->filename("SKYCELL.TEMPLATE", $outroot, $skycell_id ); 130 138 $ipprc->skycell_file( $tess_dir, $skycell_id, $skyFile, $verbose ) or &my_die("Unable to generate template skycell", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR); … … 170 178 # Run pswarp 171 179 my $accept = 1; # Accept the skycell? 180 my $do_stats; 172 181 unless ($no_op) { 173 182 my $command = "$pswarp"; … … 177 186 $command .= " -astromlist $astromName"; 178 187 $command .= " $outroot $skyFile"; 179 $command .= " -stats $outputStats";180 $command .= " -recipe PPSTATS WARPSTATS";181 188 $command .= " -F PSPHOT.PSF.SAVE PSPHOT.PSF.SKY.SAVE"; 182 189 $command .= " -F PSPHOT.OUTPUT PSPHOT.OUT.CMF.MEF"; … … 185 192 $command .= " -tracedest $traceDest -log $logDest"; 186 193 $command .= " -threads $threads" if defined $threads; 187 $command .= " -dumpconfig $configuration";188 194 $command .= " -dbname $dbname" if defined $dbname; 195 if ($run_state eq 'new') { 196 $command .= " -dumpconfig $configuration"; 197 $do_stats = 1; 198 } else { 199 $command .= " -ipprc $configuration"; 200 } 201 if ($do_stats) { 202 $command .= " -recipe PPSTATS WARPSTATS"; 203 $command .= " -stats $outputStats"; 204 } 189 205 190 206 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 195 211 } 196 212 197 # Check first for the stats file, and if the ACCEPT flag is set. 198 &my_die("Couldn't find expected output file: $outputStats", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStats); 199 # Get the statistics on the warped image 200 my $statsFile; # File handle 201 open $statsFile, $ipprc->file_resolve($outputStats) or die "Can't open statistics file $outputStats: $!\n"; 202 my @contents = <$statsFile>; # Contents of file 203 close $statsFile; 204 my $contents = join "", @contents; 205 206 my $metadata = $mdcParser->parse($contents) 207 or &my_die("Unable to parse metadata config", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_PROG_ERROR); 208 $accept = metadataLookupBool($metadata, "ACCEPT"); 209 210 # $accept is set above based on the fraction of lit pixels 211 # XXX for some files, there may not be enough stars to find a good psf. these should be dropped as well 212 if ($accept && !$ipprc->file_exists($outputPSF)) { 213 $accept = 0; 214 } 215 216 if ($accept) { 217 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_PROG_ERROR); 218 219 &my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputImage); 220 &my_die("Couldn't find expected output file: $outputMask", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask); 221 &my_die("Couldn't find expected output file: $outputWeight", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight); 222 &my_die("Couldn't find expected output file: $outputSources", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources); 223 # &my_die("Couldn't find expected output file: $outputPSF", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputPSF); 224 # &my_die("Couldn't find expected output file: $outputBin1", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputBin1); 225 # &my_die("Couldn't find expected output file: $outputBin2", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputBin2); 226 } 227 } 228 229 unless ($no_update) { 230 # XXX change -tess_id to -tess_dir when db is updated 231 my $command = "$warptool -addwarped"; 232 $command .= " -warp_id $warp_id"; 233 $command .= " -skycell_id $skycell_id"; 234 $command .= " -tess_id $tess_dir"; 235 $command .= " -path_base $outroot"; # needed for logfile lookups 236 $command .= " -ignore" if not $accept; # Completed succesfully, but can't produce product 237 $command .= " -uri $outputImage" if $accept; 238 $command .= $stats->cmdflags() if $accept; 239 $command .= " -hostname $host" if defined $host; 240 $command .= " -dbname $dbname" if defined $dbname; 241 242 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 243 run(command => $command, verbose => $verbose); 244 unless ($success) { 245 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 246 warn("Unable to perform warptool -addwarped: $error_code\n"); 247 exit($error_code); 213 if ($do_stats) { 214 # Check first for the stats file, and if the ACCEPT flag is set. 215 &my_die("Couldn't find expected output file: $outputStats", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStats); 216 # Get the statistics on the warped image 217 my $statsFile; # File handle 218 open $statsFile, $ipprc->file_resolve($outputStats) or die "Can't open statistics file $outputStats: $!\n"; 219 my @contents = <$statsFile>; # Contents of file 220 close $statsFile; 221 my $contents = join "", @contents; 222 223 my $metadata = $mdcParser->parse($contents) 224 or &my_die("Unable to parse metadata config", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_PROG_ERROR); 225 $accept = metadataLookupBool($metadata, "ACCEPT"); 226 227 # $accept is set above based on the fraction of lit pixels 228 # XXX for some files, there may not be enough stars to find a good psf. these should be dropped as well 229 if ($accept && !$ipprc->file_exists($outputPSF)) { 230 $accept = 0; 231 } 232 233 if ($accept) { 234 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_PROG_ERROR); 235 236 &my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputImage); 237 &my_die("Couldn't find expected output file: $outputMask", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask); 238 &my_die("Couldn't find expected output file: $outputWeight", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight); 239 &my_die("Couldn't find expected output file: $outputSources", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources); 240 # &my_die("Couldn't find expected output file: $outputPSF", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputPSF); 241 # &my_die("Couldn't find expected output file: $outputBin1", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputBin1); 242 # &my_die("Couldn't find expected output file: $outputBin2", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputBin2); 243 } 244 245 unless ($no_update) { 246 # XXX change -tess_id to -tess_dir when db is updated 247 my $command = "$warptool -addwarped"; 248 $command .= " -warp_id $warp_id"; 249 $command .= " -skycell_id $skycell_id"; 250 $command .= " -tess_id $tess_dir"; 251 $command .= " -path_base $outroot"; # needed for logfile lookups 252 $command .= " -ignore" if not $accept; # Completed succesfully, but can't produce product 253 $command .= " -uri $outputImage" if $accept; 254 $command .= $stats->cmdflags() if $accept; 255 $command .= " -hostname $host" if defined $host; 256 $command .= " -dbname $dbname" if defined $dbname; 257 258 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 259 run(command => $command, verbose => $verbose); 260 unless ($success) { 261 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 262 warn("Unable to perform warptool -addwarped: $error_code\n"); 263 exit($error_code); 264 } 265 } 266 } else { 267 # $run_state eq 'update' 268 unless ($no_update) { 269 my $command = "$warptool -tofullskyfile"; 270 $command .= " -warp_id $warp_id"; 271 $command .= " -skycell_id $skycell_id"; 272 $command .= " -dbname $dbname" if defined $dbname; 273 274 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 275 run(command => $command, verbose => $verbose); 276 unless ($success) { 277 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 278 warn("Unable to perform warptool -addwarped: $error_code\n"); 279 exit($error_code); 280 } 281 } 248 282 } 249 283 } … … 260 294 if (defined $warp_id and defined $skycell_id and defined $tess_dir and not $no_update) { 261 295 # XXX change -tess_id to -tess_dir when db is updated 262 my $command = "$warptool -addwarped"; 296 my $command = "$warptool"; 297 if ($run_state eq 'new') { 298 $command .= " -addwarped"; 299 $command .= " -tess_id $tess_dir"; 300 $command .= " -path_base $outroot"; 301 $command .= " -hostname $host" if defined $host; 302 } else { 303 $command .= " -updateskyfile"; 304 } 263 305 $command .= " -warp_id $warp_id"; 264 306 $command .= " -skycell_id $skycell_id"; 265 $command .= " -tess_id $tess_dir";266 307 $command .= " -code $exit_code"; 267 $command .= " -path_base $outroot";268 $command .= " -hostname $host" if defined $host;269 308 $command .= " -dbname $dbname" if defined $dbname; 270 309 run(command => $command, verbose => $verbose);
Note:
See TracChangeset
for help on using the changeset viewer.
