Changeset 32630 for branches/eam_branches/ipp-20110906/ippScripts
- Timestamp:
- Nov 8, 2011, 2:44:12 PM (15 years ago)
- Location:
- branches/eam_branches/ipp-20110906
- Files:
-
- 15 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/camera_exp.pl (modified) (2 diffs)
-
ippScripts/scripts/chip_imfile.pl (modified) (9 diffs)
-
ippScripts/scripts/diff_skycell.pl (modified) (4 diffs)
-
ippScripts/scripts/dist_bundle.pl (modified) (1 diff)
-
ippScripts/scripts/ipp_apply_burntool_single.pl (modified) (1 prop)
-
ippScripts/scripts/lap_science.pl (modified) (22 diffs)
-
ippScripts/scripts/magic_destreak.pl (modified) (8 diffs)
-
ippScripts/scripts/nightly_science.pl (modified) (1 diff)
-
ippScripts/scripts/register_exp.pl (modified) (1 diff)
-
ippScripts/scripts/register_imfile.pl (modified) (3 diffs)
-
ippScripts/scripts/stack_skycell.pl (modified) (3 diffs)
-
ippScripts/scripts/videophot_process.pl (modified) (10 diffs)
-
ippScripts/scripts/warp_overlap.pl (modified) (1 diff)
-
ippScripts/scripts/warp_skycell.pl (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110906
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20110906/ippScripts/scripts/camera_exp.pl
r31906 r32630 88 88 89 89 if ($redirect) { 90 $ipprc->redirect_ output($logDest) or my_die( "Unable to redirect output", $cam_id, $PS_EXIT_SYS_ERROR );90 $ipprc->redirect_to_logfile($logDest) or my_die( "Unable to redirect output", $cam_id, $PS_EXIT_SYS_ERROR ); 91 91 print "\n\n"; 92 92 print "Starting script $0 on $host\n\n"; … … 404 404 $ipprc->file_exists($file); 405 405 406 # Funpack to confirm we've really made things correctly 407 my $diskfile = $ipprc->file_resolve($file); 408 if ($diskfile =~ /fits/) { 409 my $funpack = can_run('funpack') or &my_die ("Can't find funpack", $cam_id, $PS_EXIT_SYS_ERROR); 410 my $check_command = "$funpack -S $diskfile > /dev/null"; 411 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 412 run(command => $check_command, verbose => $verbose); 413 if (!$success) { 414 &my_die("Output file not a valid fits file: $file", $cam_id, $PS_EXIT_SYS_ERROR); 415 } 416 } 417 ##### 418 419 406 420 my $scheme = file_scheme($file); 407 421 if ($replicate and $scheme and (file_scheme($file) eq 'neb')) { -
branches/eam_branches/ipp-20110906/ippScripts/scripts/chip_imfile.pl
r32355 r32630 34 34 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 35 35 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 36 my $nebrepair = can_run('neb-repair') or (warn "Can't find neb-repair" and $missing_tools = 1); 37 36 38 if ($missing_tools) { 37 39 warn("Can't find required tools."); … … 44 46 my ( $exp_id, $chip_id, $class_id, $chip_imfile_id, $uri, $camera, $outroot, $dbname, $run_state, $reduction, $threads, $verbose, 45 47 $no_update, $save_temps, $no_op, $redirect, $magicked, $deburned ); 46 47 my $zaplog = 0;48 48 49 49 GetOptions( … … 65 65 'no-op' => \$no_op, # Don't do any operations? 66 66 'redirect-output' => \$redirect, 67 'zaplog' => \$zaplog,68 67 'save-temps' => \$save_temps, # Save temporary files? 69 68 ) or pod2usage( 2 ); … … 92 91 } 93 92 94 my ($log Dest, $traceDest);93 my ($logRule, $traceDest); 95 94 if ($run_state eq 'new') { 96 $log Dest = prepare_output("LOG.IMFILE", $outroot, $class_id, $zaplog);95 $logRule = "LOG.IMFILE"; 97 96 $traceDest = prepare_output("TRACE.IMFILE", $outroot, $class_id, 1); 98 97 } else { 99 $log Dest = prepare_output("LOG.IMFILE.UPDATE", $outroot, $class_id, 1);98 $logRule = "LOG.IMFILE.UPDATE"; 100 99 $traceDest = prepare_output("TRACE.IMFILE.UPDATE", $outroot, $class_id, 1); 101 100 } 102 101 103 102 if ($redirect) { 104 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR ); 103 my $logDest = $ipprc->filename($logRule, $outroot, $class_id); 104 105 $ipprc->redirect_to_logfile($logDest) or my_die( "Unable to redirect output", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR ); 106 105 107 print STDOUT "\n\n"; 106 108 print STDOUT "Starting script $0 on $host\n\n"; … … 330 332 # get the UNIX version of the (possible) neb: or path: filename 331 333 my $uriReal = $ipprc->file_resolve( $uri ); 334 # Catch errors here 335 if (!$uriReal) { 336 my $repair_cmd = "$nebrepair $uri"; 337 my ($repair_success, $repair_error_code, $repair_full_buf, $repair_stdout_buf, $repair_stderr_buf ) = run(command => $repair_cmd, verbose => $verbose); 338 unless ($repair_success) { 339 &my_die("Unable to attempt repair: $uri $repair_error_code", $exp_id,$chip_id, $class_id, $PS_EXIT_SYS_ERROR); 340 } 341 $uriReal = $ipprc->file_resolve( $uri ); 342 } 343 332 344 &my_die("Unable to resolve $uri on $host", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) if !$uriReal; 333 345 … … 336 348 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $funpack_cmd, verbose => $verbose); 337 349 unless ($success) { 350 # Catch errors here 351 my $repair_cmd = "$nebrepair $uri"; 352 my ($repair_success, $repair_error_code, $repair_full_buf, $repair_stdout_buf, $repair_stderr_buf ) = run(command => $repair_cmd, verbose => $verbose); 353 unless ($repair_success) { 354 &my_die("Unable to attempt repair: $uri $repair_error_code", $exp_id,$chip_id, $class_id, $PS_EXIT_SYS_ERROR); 355 } 356 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $funpack_cmd, verbose => $verbose); 357 } 358 unless ($success) { 338 359 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 339 360 &my_die("Unable to perform funpack: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR); … … 348 369 $burntoolTable_uri =~ s/fits$/burn.tbl/; 349 370 $burntoolTable_uriReal = $ipprc->file_resolve( $burntoolTable_uri ); 371 if ((!$burntoolTable_uriReal)||(!($ipprc->file_exists($burntoolTable_uri)))) { 372 my $repair_cmd = "$nebrepair $burntoolTable_uri"; 373 my ($repair_success, $repair_error_code, $repair_full_buf, $repair_stdout_buf, $repair_stderr_buf ) = run(command => $repair_cmd, verbose => $verbose); 374 unless ($repair_success) { 375 &my_die("Unable to attempt repair: $uri $repair_error_code", $exp_id,$chip_id, $class_id, $PS_EXIT_SYS_ERROR); 376 } 377 $burntoolTable_uriReal = $ipprc->file_resolve( $burntoolTable_uri ); 378 } 350 379 unless ($ipprc->file_exists($burntoolTable_uri)) { 380 # Catch errors here 351 381 &my_die("Couldn't find burntool table: $burntoolTable_uri",$exp_id,$chip_id,$class_id, $PS_EXIT_SYS_ERROR); 352 382 } … … 451 481 $command .= " -image_id $chip_imfile_id" if defined $chip_imfile_id; 452 482 $command .= " -source_id $source_id" if defined $source_id; 453 $command .= " -tracedest $traceDest -log $logDest";483 $command .= " -tracedest $traceDest"; 454 484 $command .= " -dbname $dbname" if defined $dbname; 455 485 … … 727 757 &my_die("Couldn't find expected output file: $file", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR); 728 758 } 759 # Funpack to confirm we've really made things correctly 760 my $diskfile = $ipprc->file_resolve($file); 761 if ($diskfile =~ /fits/) { 762 my $funpack = can_run('funpack') or &my_die ("Can't find funpack", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR); 763 my $check_command = "$funpack -S $diskfile > /dev/null"; 764 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 765 run(command => $check_command, verbose => $verbose); 766 if (!$success) { 767 &my_die("Output file not a valid fits file: $file", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR); 768 } 769 } 770 ##### 729 771 730 772 if ($replicate and $neb) { -
branches/eam_branches/ipp-20110906/ippScripts/scripts/diff_skycell.pl
r31941 r32630 40 40 my ($skycell_id, $diff_skyfile_id); 41 41 my ($use_convolved); 42 my $zaplog = 0;43 42 44 43 GetOptions( … … 57 56 'no-op' => \$no_op, # Don't do any operations? 58 57 'redirect-output' => \$redirect, 59 'zaplog' => \$zaplog, # delete any previous log file60 58 ) or pod2usage( 2 ); 61 59 … … 79 77 80 78 # XXX camera is not known here; cannot use filerules... 81 # bills 2011-03-07 This is unfortunate because it prevents us from using prepare_output ...82 # my $logDest = $ipprc->filename("LOG.EXP", $outroot);83 79 my $logDest = "$outroot.log"; 84 80 if ($run_state eq 'update') { 85 81 $logDest .= '.update'; 86 # ... well we can just do the dirty work here 87 $ipprc->kill_file($logDest); 88 } elsif ($zaplog) { 89 $ipprc->kill_file($logDest); 90 } 91 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR ) if $redirect; 82 } 83 $ipprc->redirect_to_logfile($logDest) or my_die( "Unable to redirect output", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR ) if $redirect; 92 84 93 85 my $source_id = $ipprc->source_id($dbname, $PS_TABLE_ID_DIFF); … … 468 460 &my_die("Couldn't find expected output file: $file", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file); 469 461 462 # Funpack to confirm we've really made things correctly 463 my $diskfile = $ipprc->file_resolve($file); 464 if ($diskfile =~ /fits/) { 465 my $funpack = can_run('funpack') or &my_die ("Can't find funpack", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR); 466 my $check_command = "$funpack -S $diskfile > /dev/null"; 467 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 468 run(command => $check_command, verbose => $verbose); 469 if (!$success) { 470 &my_die("Output file not a valid fits file: $file", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR); 471 } 472 } 473 ##### 474 475 470 476 if ($replicate and $neb) { 471 477 $ipprc->replicate_file($file) or &my_die("failed to replicate: $file\n", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR); -
branches/eam_branches/ipp-20110906/ippScripts/scripts/dist_bundle.pl
r31572 r32630 636 636 $file{file_rule} = $key; 637 637 $file{name} = $val; 638 if ($val eq "STDERR" or $val eq "STDOUT") { 639 print STDERR "Skipping $key because filename is $val\n"; 640 next; 641 } 638 642 push @file_list, \%file; 639 643 } -
branches/eam_branches/ipp-20110906/ippScripts/scripts/ipp_apply_burntool_single.pl
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/eam_branches/ipp-20110906/ippScripts/scripts/lap_science.pl
r32195 r32630 27 27 my ( $camera, $dbname); 28 28 my ( $lap_id ); 29 my ( $queue_list ); 29 30 my ( $chip_mode, $monitor_mode, $cleanup_mode); 30 31 … … 44 45 45 46 'lap_id=s' => \$lap_id, 47 'queue_list=s' => \$queue_list, 46 48 47 49 'chip_mode' => \$chip_mode, … … 200 202 return($exposure); 201 203 } 204 205 sub remake_this_exposure_by_update { 206 my $exposure = shift; 207 208 my @utctime = gmtime(); 209 $utctime[5] += 1900; 210 $utctime[4] += 1; 211 212 my $label = $exposure->{label}; 213 214 my $date = sprintf("%4d%02d%02d",$utctime[5],$utctime[4],$utctime[3]); 215 my $workdir_date = sprintf("%4d/%02d/%02d",$utctime[5],$utctime[4],$utctime[3]); 216 my $workdir = "neb://\@HOST\@.0/${dbname}/${label}/${workdir_date}"; 217 my $data_group = "${label}.${date}"; 218 219 my $chiptool_info_cmd = "chiptool -listrun -exp_id $exposure->{exp_id} -chip_id $exposure->{chip_id} "; 220 $chiptool_info_cmd .= " -dbname $dbname " if defined $dbname; 221 222 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 223 run(command => $chiptool_info_cmd, verbose => $verbose); 224 unless ($success) { 225 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 226 &my_die("Unable to perform chiptool -listrun: $error_code", $exposure->{exp_id}, $data_group); 227 } 228 my $chips = $mdcParser->parse_list(join "", @$stdout_buf) or 229 &my_die("Unable to parse metadata from chiptool -listrun", $exposure->{exp_id}, $data_group); 230 # There should be only one. 231 my $chip = ${ $chips }[0]; 232 my $chip_magicDS_id = 0; 233 if ($chip) { 234 $chip_magicDS_id = $chip->{magic_ds_id}; 235 } 236 if ($chip_magicDS_id == 0) { 237 # return(&remake_this_exposure($exposure)); 238 } 239 240 my $warptool_info_cmd = "warptool -listrun -exp_id $exposure->{exp_id} -chip_id $exposure->{chip_id} "; 241 $warptool_info_cmd .= " -dbname $dbname " if defined $dbname; 242 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 243 run(command => $warptool_info_cmd, verbose => $verbose); 244 unless ($success) { 245 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 246 &my_die("Unable to perform warptool -listrun: $error_code", $exposure->{exp_id}, $data_group); 247 } 248 my $warps = $mdcParser->parse_list(join "", @$stdout_buf) or 249 &my_die("Unable to parse metadata from warptool -listrun", $exposure->{exp_id}, $data_group); 250 # There should be only one. 251 my $warp = ${ $warps }[0]; 252 my $warp_id = 0; 253 if ($warp) { 254 $warp_id = $warp->{warp_id}; 255 } 256 else { 257 $exposure->{data_state} = 'drop'; 258 return($exposure); 259 } 260 if ($warp_id == 0) { 261 # Handle this correctly. Probably want to drop the exposure here. 262 $exposure->{data_state} = 'drop'; 263 return($exposure); 264 } 265 266 if (($chip->{state} eq 'goto_cleaned')|| 267 ($warp->{state} eq 'goto_cleaned')|| 268 ($chip->{dsRun_state} eq 'goto_cleaned')) { 269 $exposure->{data_state} = 'pending_update'; 270 &update_this_exposure($exposure); 271 return($exposure); 272 } 273 274 275 my $chiptool_update_cmd = "chiptool -setimfiletoupdate -chip_id $exposure->{chip_id} -set_label $label"; 276 $chiptool_update_cmd .= " -dbname $dbname " if defined $dbname; 277 my $magicDS_update_cmd = "magicdstool -setfiletoupdate -magic_ds_id $chip_magicDS_id -set_label $label"; 278 $magicDS_update_cmd .= " -dbname $dbname " if defined $dbname; 279 my $warptool_update_cmd = "warptool -setskyfiletoupdate -warp_id $warp_id -set_label $label"; 280 $warptool_update_cmd .= " -dbname $dbname " if defined $dbname; 281 282 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 283 run(command => $chiptool_update_cmd, verbose => $verbose); 284 unless ($success) { 285 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 286 &my_die("Unable to perform chiptool -setimfiletoupdate: $error_code", $exposure->{exp_id}, $data_group); 287 } 288 if ($chip_magicDS_id != 0) { 289 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 290 run(command => $magicDS_update_cmd, verbose => $verbose); 291 unless ($success) { 292 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 293 &my_die("Unable to perform magicdstool -setfiletoupdate: $error_code", $exposure->{exp_id}, $data_group); 294 } 295 } 296 297 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 298 run(command => $warptool_update_cmd, verbose => $verbose); 299 unless ($success) { 300 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 301 &my_die("Unable to perform warptool -setskyfiletoupdate: $error_code", $exposure->{exp_id}, $data_group); 302 } 303 304 $exposure->{active} = 1; 305 return($exposure); 306 } 307 308 sub determine_if_can_update { 309 my $exposure = shift; 310 311 if (S64_IS_NOT_NULL($exposure->{chip_id})) { 312 if (($exposure->{chip_state} eq 'cleaned')|| 313 ($exposure->{chip_state} eq 'goto_cleaned')|| 314 ($exposure->{chip_state} eq 'error_cleaned')) { 315 return(1); 316 } 317 } 318 319 return(0); 320 } 321 202 322 203 323 # This is the "user level" subroutine. … … 240 360 my $comment = $exposure->{comment}; 241 361 242 # This is a hack to fix old exposures that have no object. 362 my $updateable = determine_if_can_update($exposure); 363 364 # This is a hack to fix old exposures that have no usable object/comment data. 243 365 unless(defined($comment)) { 244 366 $comment = ''; … … 247 369 if ($comment =~ /3pi_/) { 248 370 $object = $comment; 249 $object =~ s/^.*?(3pi_\d\d_\d\d\d\d).*?$/ $1/;371 $object =~ s/^.*?(3pi_\d\d_\d\d\d\d).*?$/F1 $1/; 250 372 } 251 373 elsif ($comment =~ / ps1_/) { 252 374 $object = $comment; 253 $object =~ s/^.*?(ps1_\d\d_\d\d\d\d).*$/$1/; 254 } 255 else { 256 $exposure->{data_state} = 'new'; 375 $object =~ s/^.*?(ps1_\d\d_\d\d\d\d).*$/F2 $1/; 376 } 377 elsif ($comment =~ /ThreePi.*3pi_/) { 378 $object = $comment; 379 $object =~ s/^ThreePi . (\S+? 3pi_\d\d_\d\d\d\d) .*$/F3 $1/; 380 } 381 elsif ($comment =~ /ThreePi.*ps1_/) { 382 $object = $comment; 383 $object =~ s/^ThreePi . (\S+? ps1_\d\d_\d\d\d\d) .*$/F4 $1/; 384 } 385 elsif ($comment =~ /ThreePi /) { 386 $object = $comment; 387 $object =~ s/^ThreePi . (\S+? \d\d\d\d) .*$/F5 $1/; 388 } 389 elsif (($comment =~ /focus/i)|| 390 ($comment =~ /test/i)|| 391 ($comment =~ /hyster/i)|| 392 ($comment =~ /dither/i)|| 393 ($comment =~ /camera/i) 394 ){ 395 # This is junk that shouldn't exist. 396 $object = 'DROP'; 397 $exposure->{data_state} = 'drop'; 257 398 $exposure->{pairwise} = 0; 258 $exposure->{private} = 1; 259 $exposure->{pair_id} = 9223372036854775807; 260 update_this_exposure($exposure); 261 $exposure = remake_this_exposure($exposure); 262 $counter++; 399 $exposure->{pair_id} = 9223372036854775807; 400 $exposure->{active} = 0; 401 &update_this_exposure($exposure); 402 $counter++; # To ensure everyone else is consistent 263 403 next; 264 404 } 265 405 } 266 406 407 # Determine the current state of chipRuns for these exposures, and update/remake as needed. 267 408 if (S64_IS_NOT_NULL($chip_id)) { # We already have a defined chip_id 268 409 if (($pairwise) && !($pair_id)) { … … 270 411 &my_die("Exposure $exp_id for $lap_id is declared pairwise without a defined pair", $lap_id); 271 412 } 413 $exposure->{data_state} = 'exists'; 414 if ($updateable) { # We know about this run, but the data needs to be regenerated. 415 $exposure->{data_state} = 'update'; 416 $exposure = remake_this_exposure_by_update($exposure); 417 } 418 &update_this_exposure($exposure); 272 419 $matching{$object}{$comment} = $exp_id; 273 420 $indexing{$exp_id} = $counter; 274 421 $counter++; 275 next;276 422 } 277 423 else { # We do not already have a chip_id. 278 424 # Make a chipRun, and update the exposure. 425 $exposure->{data_state} = 'run'; 279 426 $exposure = remake_this_exposure($exposure); 280 281 427 # Save our information for diff pairing. 428 &update_this_exposure($exposure); 282 429 $matching{$object}{$comment} = $exp_id; 283 430 $indexing{$exp_id} = $counter; 284 431 $counter++; 285 432 } 433 286 434 if ($verbose) { 287 435 print "ZZ: $exp_id $object $comment $matching{$object}{$comment}\n"; … … 296 444 print "$object $comment $matching{$object}{$comment} $indexing{$matching{$object}{$comment}} $exp_ids_to_diff[-1]\n"; 297 445 } 298 @exp_ids_to_diff = sort { $indexing{$a} <=> $indexing{$b} } @exp_ids_to_diff; 446 @exp_ids_to_diff = sort { $indexing{$a} <=> $indexing{$b} } @exp_ids_to_diff; # This is effectively a sort by dateobs. 299 447 300 448 if (( $#exp_ids_to_diff + 1) % 2 != 0) { # We have an odd number of exposures, even after comment filtering … … 309 457 my $exp_B = ${ $exposures }[$indexing{$exp_id_B}]; 310 458 print "$exp_A $exp_B $exp_id_A $exp_id_B $indexing{$exp_id_A} $indexing{$exp_id_B}\n"; 311 $exp_A->{pairwise} = 1; 312 $exp_A->{private} = 0; 313 $exp_A->{pair_id} = $exp_B->{chip_id}; 314 315 $exp_B->{pairwise} = 1; 316 $exp_B->{private} = 0; 317 $exp_B->{pair_id} = $exp_A->{chip_id}; 318 319 if ($verbose) { 320 print "LAP_DIFFS: $object: $exp_A->{exp_id} and $exp_B->{exp_id} are a pair\n"; 459 if ($exp_A->{diff_id} == $exp_B->{diff_id}) { 460 $exp_A->{pairwise} = 1; 461 $exp_A->{pair_id} = $exp_B->{chip_id}; 462 463 $exp_B->{pairwise} = 1; 464 $exp_B->{pair_id} = $exp_A->{chip_id}; 465 if ($verbose) { 466 print "LAP_DIFFS: $object: $exp_A->{exp_id} and $exp_B->{exp_id} are a pair\n"; 467 } 468 } 469 else { 470 $exp_A->{pairwise} = 0; 471 $exp_B->{pairwise} = 0; 321 472 } 322 473 } … … 331 482 $exposure->{pairwise} = 0; # We marked it for pairwise diffs, but didn't match it. Probably an error. 332 483 } 333 if (!($exposure->{pairwise})) { 334 $exposure->{private} = 1; # If this isn't being pairwise diffed, it needs to be private 335 } 336 484 337 485 update_this_exposure($exposure); 338 486 } … … 457 605 # Things I want to know before I'm through 458 606 # my $needs_qstack = 0; 459 my $needs_something_remade = 0; 460 my $needs_something_private = 0; 607 my $needs_something_remade = 0; # I never need something remade, because we're committed to one-exp=one-chip 608 my $needs_something_private = 0; # I never need something private, as that is calculated by the difference engine. 461 609 # my $can_qstack = 0; 462 610 my $have_diff = 0; … … 480 628 else { # We claimed to be pairwise, but do not have a valid pair_id. 481 629 $exposure->{pairwise} = 0; 482 $exposure->{private} = 1;483 630 &update_this_exposure($exposure); 484 631 } … … 487 634 if ($exposure->{data_state} eq 'drop') { # This exposure is impossible, so fudge the counts so we get through. 488 635 $are_warped++; 489 # $can_qstack ++;490 636 $can_diff ++; 491 637 $have_diff ++; 492 638 $are_magicked ++; 493 # $can_fstack ++; 639 next; 640 } 641 642 if ($exposure->{data_state} eq 'pending_update') { 643 $exposure->{data_state} = 'update'; 644 $exposure = &remake_this_exposure_by_update($exposure); 645 &update_this_exposure($exposure); 494 646 next; 495 647 } 496 648 497 649 if ($exposure->{private}) { # I've declared this exposure private to this lapRun. 498 # $needs_qstack++;499 650 push @lonely_exposures, $exposure; 500 # $lonely_exposures++;501 651 } 502 652 503 if ($exposure->{needs_remade}) { # This does the check that private = false for other lapRun504 $needs_something_remade = 1;505 $exposure = remake_this_exposure($exposure);506 }653 # if ($exposure->{needs_remade}) { # This does the check that private = false for other lapRun 654 # $needs_something_remade = 1; 655 # $exposure = remake_this_exposure($exposure); 656 # } 507 657 # Do quality checks here 508 658 my $is_bad_quality = 0; … … 536 686 ($exposure->{diffRun_state} eq 'full')) { 537 687 $are_warped++; 538 # $needs_qstack++;539 $needs_something_private = 1;540 688 if ($companion) { 541 $companion->{private} = 1;542 689 $companion->{pairwise} = 0; 543 690 &update_this_exposure($companion); 544 push @lonely_exposures, $companion; 545 # $lonely_exposures++; 546 } 547 $exposure->{private} = 1; 691 # push @lonely_exposures, $companion; 692 } 548 693 $exposure->{pairwise} = 0; 549 694 } 550 695 $exposure->{data_state} = 'drop'; 551 696 &update_this_exposure($exposure); 697 next; 552 698 } 553 699 … … 558 704 # $can_qstack ++; 559 705 $can_diff ++; 560 } 561 if (($exposure->{magicked}&& 562 &S64_IS_NOT_NULL($exposure->{magicked}))) { # This exposure has been magicked, so it is through with diff. 563 $are_magicked++; 564 # $can_fstack ++; 706 $exposure->{data_state} = 'to_diff'; 565 707 } 566 708 if (($exposure->{diff_id})&&(&S64_IS_NOT_NULL($exposure->{diff_id}))) { 567 709 $have_diff ++; 568 } 710 $exposure->{data_state} = 'to_magic'; 711 } 712 if (($exposure->{magicked})&& 713 ($exposure->{warpRun_state})&& 714 ($exposure->{warpRun_state} eq 'full')&& 715 (&S64_IS_NOT_NULL($exposure->{magicked}))) { # This exposure has been magicked, so it is through with diff. 716 $are_magicked++; 717 $exposure->{data_state} = 'full'; 718 # $can_fstack ++; 719 } 720 &update_this_exposure($exposure); 569 721 } 570 722 … … 575 727 print "STATUS: HAVE_FSTACK: $have_fstack\n"; 576 728 577 # print "STATUS: NEEDS_QSTACK: $needs_qstack\n";578 729 print "STATUS: NEEDS_REMADE: $needs_something_remade\n"; 579 730 print "STATUS: NEEDS PRIVATIZE: $needs_something_private\n"; 580 731 print "STATUS: ARE WARPED: $are_warped\n"; 581 732 print "STATUS: ARE MAGICKED: $are_magicked\n"; 582 # print "STATUS: CAN_QSTACK: $can_qstack\n";583 733 print "STATUS: CAN_DIFF: $can_diff\n"; 584 734 print "STATUS: HAVE_DIFF: $have_diff\n"; 585 # print "STATUS: CAN_FSTACK: $can_fstack\n";586 735 587 736 print "STATUS: TOTAL_EXPOSURES: $total_exposures\n"; … … 924 1073 next; 925 1074 } 926 if ($exposure->{diff_id}&&S64_IS_NOT_NULL($exposure->{diff_id})) { # Not sure how this would happen, but still. ##This happens when we inherit a complete exposure.1075 if ($exposure->{diff_id}&&S64_IS_NOT_NULL($exposure->{diff_id})) { # This happens when we inherit a complete exposure. 927 1076 next; 928 1077 } … … 964 1113 } 965 1114 else { # warp-qstack 1115 # We need to decide if we can make a warp-stack diff: 1116 if (&can_warp_stack_diff_be_made($exposure)) { 966 1117 # next; 967 1118 # $command .= '-pretend'; 968 $command .= " -definewarpstack -available -good_frac 0.2 "; 969 $command .= " -warp_id $exposure->{warp_id} -stack_label ${label} "; 970 $already_queued{$exposure->{warp_id}} = 1; 1119 $command .= " -definewarpstack -available -good_frac 0.2 "; 1120 $command .= " -warp_id $exposure->{warp_id} -stack_label ${label} "; 1121 $already_queued{$exposure->{warp_id}} = 1; 1122 $exposure->{private} = 0; 1123 &update_this_exposure($exposure); 1124 } 1125 else { 1126 $exposure->{private} = 1; 1127 $exposure->{data_state} = 'drop'; 1128 $already_queued{$exposure->{warp_id}} = 1; 1129 &update_this_exposure($exposure); 1130 next; 1131 } 971 1132 } 972 1133 … … 1006 1167 } 1007 1168 1169 sub can_warp_stack_diff_be_made { 1170 my $exposure = shift; 1171 my $lap_id = $exposure->{lap_id}; 1172 my $warp_id = $exposure->{warp_id}; 1173 1174 my $command = "$laptool -diffcheck -lap_id $lap_id -warp_id $warp_id"; 1175 $command .= " -dbname $dbname " if defined $dbname; 1176 1177 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 1178 run(command => $command, verbose => $verbose); 1179 unless ($success) { 1180 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 1181 &my_die("Unable to perform laptool -diffcheck: $error_code", $lap_id, $warp_id); 1182 } 1183 if (@$stdout_buf == 0) { 1184 return(0); 1185 } 1186 my $skycells = $mdcParser->parse_list(join "", @$stdout_buf) or 1187 &my_die("Unable to parse metadata from laptool -diffcheck", $lap_id, $warp_id); 1188 foreach my $skycell (@$skycells) { 1189 unless (defined($skycell->{stack_state})) { 1190 return(0); 1191 } 1192 if ($skycell->{stack_state} ne 'full') { 1193 return(0); 1194 } 1195 if ($skycell->{warp_state} ne 'full') { 1196 return(0); 1197 } 1198 unless (S64_IS_NOT_NULL($skycell->{stack_id})) { 1199 return(0); 1200 } 1201 } 1202 return(1); 1203 } 1204 1205 1008 1206 # Deactivate all exposures in this run. 1009 1207 sub deactivate_exposures { 1010 1208 my $exposures = shift; 1011 1209 foreach my $exposure (@$exposures) { 1012 $exposure->{active} = 0; 1013 update_this_exposure($exposure); 1210 if ($exposure->{private} == 1) { # This can probably be relaxed since we can update an undestreaked warp. 1211 $exposure->{active} = 1; 1212 } 1213 else { 1214 $exposure->{active} = 0; 1215 } 1216 update_this_exposure($exposure); 1014 1217 } 1015 1218 } … … 1022 1225 sub cleanup_mode { 1023 1226 my $lap_id = shift; 1227 1228 if (defined($queue_list)) { 1229 my $successful = 1; 1230 open(Q,$queue_list) or ($successful = 0); 1231 if ($successful == 1) { 1232 while(<Q>) { 1233 chomp; 1234 my $cmd = $_; 1235 my ($projection_cell,$seq_id,$filter,$label); 1236 $projection_cell = $cmd; 1237 $projection_cell =~ s/.*?-projection_cell (skycell.\w+?) .*/$1/; 1238 $seq_id = $cmd; 1239 $seq_id =~ s/.*-seq_id (\d+?) .*/$1/; 1240 $filter = $cmd; 1241 $filter =~ s/.*-filter (\w\.00000) .*/$1/; 1242 if ($filter =~ /\s+?/) { 1243 $filter =~ s/.*-filter (\w\.00000)$/$1/; 1244 } 1245 $label = $cmd; 1246 $label =~ s/.*-label (.+?) .*/$1/; 1247 1248 my $response; 1249 chomp($response = 1250 `laptool -dbname gpc1 -listrun -projection_cell $projection_cell -seq_id $seq_id -filter $filter -label $label -simple`); 1251 my $state = (split /\s+/, $response)[5]; 1252 1253 unless (defined($state)) { 1254 if ($verbose) { 1255 print "Queuing: $cmd\n"; 1256 } 1257 system($cmd); 1258 1259 my $i = 0; 1260 do { 1261 sleep(5); 1262 chomp($response = 1263 `laptool -dbname gpc1 -listrun -projection_cell $projection_cell -seq_id $seq_id -filter $filter -label $label -simple`); 1264 $state = (split /\s+/, $response)[5]; 1265 $i++; 1266 unless(defined($state)) { 1267 $successful = 0; 1268 } 1269 } while (($state ne 'run')&&($i < 20)&&($successful)); 1270 last; 1271 } 1272 } 1273 close(Q); 1274 } 1275 } 1276 1024 1277 my $command = "$laptool -inactiveexp -lap_id $lap_id "; 1025 1278 $command .= " -dbname $dbname " if defined $dbname; … … 1043 1296 'warptool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -set_label goto_cleaned -label @LABEL@ -warp_id @WARP_ID@', 1044 1297 'difftool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -set_label goto_cleaned -label @LABEL@ -diff_id @DIFF_ID@', 1298 'magictool -dbname @DBNAME@ -updaterun -set_state full -set_label @LABEL@.old -magic_id @MAGIC_ID@', 1045 1299 'magicdstool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -stage chip -stage_id @CHIP_ID@', 1046 1300 'magicdstool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -stage warp -stage_id @WARP_ID@', 1047 1301 'magicdstool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -stage diff -stage_id @DIFF_ID@'); 1302 1048 1303 foreach my $exposure (@$exposures) { 1049 1304 if ($exposure->{is_in_use}) { … … 1072 1327 if (S64_IS_NOT_NULL($exposure->{diff_id})) { 1073 1328 $command =~ s/\@DIFF_ID\@/$exposure->{diff_id}/; 1329 } 1330 else { 1331 next; 1332 } 1333 } 1334 if ($command =~ /\@MAGIC_ID\@/) { 1335 if ((S64_IS_NOT_NULL($exposure->{magicked}))&& 1336 ($exposure->{magicked} > 0)) { 1337 $command =~ s/\@MAGIC_ID\@/$exposure->{magicked}/; 1074 1338 } 1075 1339 else { … … 1139 1403 &my_die("Unable to perform laptool -updaterun: $error_code", $lap_id); 1140 1404 } 1141 1405 return(0); 1142 1406 } 1143 1407 -
branches/eam_branches/ipp-20110906/ippScripts/scripts/magic_destreak.pl
r31435 r32630 35 35 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 36 36 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 37 my $dvoImageOverlaps = can_run('dvoImageOverlaps') or (warn "Can't find dvoImageOverlaps" and $missing_tools = 1); 37 38 if ($missing_tools) { 38 39 warn("Can't find required tools."); … … 45 46 my ($outroot, $recoveryroot, $magicked); 46 47 my ($replace, $release); 48 my ($diff_tess_id, $mismatched_tess); 47 49 my ($dbname, $save_temps, $verbose, $no_update, $no_op, $logfile); 48 50 … … 60 62 'stage_id=s' => \$stage_id, # exp_id, chip_id, warp_id, or diff_id 61 63 'component=s' => \$component, # the class_id or skycell_id 64 'mismatched_tess'=> \$mismatched_tess, # true if tess_id of input does not match tess_id of the diff used for magic 65 'diff_tess_id=s' => \$diff_tess_id, # tess_id of diffRun used to compute the streaks 62 66 'uri=s' => \$uri, # uri of the input image 63 67 'path_base=s' => \$path_base, # path_base of the input … … 106 110 if (($stage eq "raw") or ($stage eq "chip") or $stage eq "chip_bg") { 107 111 $class_id = $component; 108 $skycell_args = " -class_id $component";112 $skycell_args = " -class_id"; 109 113 } elsif ($stage eq "warp" or $stage eq "warp_bg") { 110 114 $skycell_id = $component; 111 $skycell_args = " -skycell_id $component";115 $skycell_args = " -skycell_id"; 112 116 } elsif ($stage eq "diff") { 113 117 $skycell_id = $component; … … 215 219 my ($sfh, $skycell_list); 216 220 if ($skycell_args) { 217 my $command = "$magicdstool -magic_ds_id $magic_ds_id -getskycells $skycell_args"; 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 magicdstool -diffskyfile $skycell_args: $error_code", $magic_ds_id, $component, $error_code); 224 } 225 226 my $getskycells_output = join "", @$stdout_buf; 227 if ($getskycells_output) { 228 my $metadata = $mdcParser->parse($getskycells_output) or 229 &my_die("Unable to parse metadata config doc", $magic_ds_id, $component, $PS_EXIT_PROG_ERROR); 230 231 my $skycells = parse_md_list($metadata) or 232 &my_die("Unable to parse metadata list", $magic_ds_id, $component, $PS_EXIT_PROG_ERROR); 233 234 ($sfh, $skycell_list) = tempfile( "/tmp/skycell_list.XXXX", UNLINK => !$save_temps); 235 236 foreach my $skycell (@$skycells) { 237 my $skycell_uri; 238 if ($skycell->{data_state} eq "full" and $skycell->{quality} = 0) { 239 $skycell_uri = $ipprc->filename("PPSUB.OUTPUT", $skycell->{path_base}); 240 } else { 241 # diff run must have been cleaned up, need to create this skycell file on the fly 242 if (!defined $temp_dir ) { 243 $temp_dir = tempdir( CLEANUP => !$save_temps); 221 my $command = "$magicdstool -magic_ds_id $magic_ds_id -getskycells"; 222 $command .= " $skycell_args"; 223 my @diff_components; 224 if ($mismatched_tess) { 225 # tessellation for this skycell does not match the tessellation used for the magic analysis 226 # used to calculate the streaks file 227 @diff_components = get_overlaps($path_base, $component, $diff_tess_id); 228 } else { 229 @diff_components = ($component); 230 } 231 232 # hash of uris by skycell. 233 my %diff_skycells; 234 foreach my $component (@diff_components) { 235 my $this_command = "$command $component"; 236 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 237 run(command => $this_command, verbose => $verbose); 238 unless ($success) { 239 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 240 &my_die("Unable to perform magicdstool -diffskyfile $skycell_args: $error_code", $magic_ds_id, $component, $error_code); 241 } 242 243 my $getskycells_output = join "", @$stdout_buf; 244 if ($getskycells_output) { 245 my $metadata = $mdcParser->parse($getskycells_output) or 246 &my_die("Unable to parse metadata config doc", $magic_ds_id, $component, $PS_EXIT_PROG_ERROR); 247 248 my $skycells = parse_md_list($metadata) or 249 &my_die("Unable to parse metadata list", $magic_ds_id, $component, $PS_EXIT_PROG_ERROR); 250 251 foreach my $skycell (@$skycells) { 252 my $skycell_uri; 253 if ($skycell->{data_state} eq "full" and $skycell->{quality} == 0) { 254 $skycell_uri = $ipprc->filename("PPSUB.OUTPUT", $skycell->{path_base}); 255 $diff_skycells{$skycell_id} = $skycell_uri; 256 } else { 257 # diff run must have been cleaned up, need to create this skycell file on the fly 258 if (!defined $temp_dir ) { 259 $temp_dir = tempdir( CLEANUP => !$save_temps); 260 } 261 my $skycell_id = $skycell->{skycell_id}; 262 if (!$diff_skycells{$skycell_id}) { 263 $skycell_uri = "$temp_dir/$skycell_id"; 264 $ipprc->skycell_file($skycell->{tess_id}, $skycell_id, $skycell_uri, $verbose) or 265 &my_die("failed to create skycell file for $skycell_id", $magic_ds_id, $component, $PS_EXIT_PROG_ERROR); 266 } 267 $diff_skycells{$skycell_id} = $skycell_uri; 244 268 } 245 my $skycell_id = $skycell->{skycell_id};246 $skycell_uri = "$temp_dir/$skycell_id";247 $ipprc->skycell_file($skycell->{tess_id}, $skycell_id, $skycell_uri, $verbose) or248 &my_die("failed to create skycell file for $skycell_id", $magic_ds_id, $component, $PS_EXIT_PROG_ERROR);249 269 } 250 print $sfh "$skycell_uri\n"; 251 } 252 close $sfh 253 } 270 } 271 } 272 # write the skycell list file 273 ($sfh, $skycell_list) = tempfile( "/tmp/skycell_list.XXXX", UNLINK => !$save_temps); 274 foreach my $skycell_id (keys %diff_skycells) { 275 print $sfh $diff_skycells{$skycell_id} . "\n"; 276 } 277 close $sfh 254 278 } 255 279 … … 360 384 $command .= " -chip_mask $ch_mask" if defined $ch_mask; 361 385 $command .= " -weight $weight" if defined $weight; 362 if ((defined($sources))&&($ipprc->file_exists($sources))) { 363 $command .= " -sources $sources" if defined $sources; 364 } 365 else { 366 print "Did not add sources because they do not appear to exist. This may be an error.\n"; 367 } 386 $command .= " -sources $sources" if defined $sources; 368 387 $command .= " -skycelllist $skycell_list" if defined $skycell_list; 369 388 $command .= " -replace" if $replace; … … 475 494 476 495 my $statsFlags; 477 if ( $stage ne "camera") {496 if (!$no_op and $stage ne "camera") { 478 497 file_check($statsFile); 479 498 { … … 595 614 } 596 615 616 # @diff_components = get_overlaps($path_base, $component, $tess_id, $diff_tess_id); 617 sub get_overlaps { 618 my $path_base = shift; 619 my $component = shift; 620 my $diff_tess_id = shift; 621 622 my $tess_dir = $ipprc->tessellation_catdir( $diff_tess_id ); 623 my $catdir = $ipprc->convert_filename_absolute($tess_dir); 624 625 my $cmf = $ipprc->file_resolve("$path_base.cmf"); 626 &my_die("Unable to resolve $path_base.$cmf", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR) unless $cmf; 627 628 my $command = "$dvoImageOverlaps -D CATDIR $catdir -accept-astrom $cmf"; 629 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 630 run(command => $command, verbose => $verbose); 631 unless ($success) { 632 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 633 &my_die("Unable to perform dvoImageOverlaps $error_code", $magic_ds_id, $component, 634 $error_code); 635 } 636 my @list; 637 my $output = join "\n", @$stdout_buf; 638 if ($output) { 639 foreach my $line (split "\n", $output) { 640 my (undef, undef, $skycell_id) = split " ", $line; 641 push @list, $skycell_id; 642 } 643 } 644 return @list 645 } 646 597 647 598 648 sub my_die -
branches/eam_branches/ipp-20110906/ippScripts/scripts/nightly_science.pl
r31906 r32630 1708 1708 $cmd .= "-input_label $label -template_label $label "; 1709 1709 $cmd .= "-set_workdir $workdir -set_dist_group $new_dist_group -set_data_group $new_data_group "; 1710 $cmd .= " -mintimediff 40000 "; 1710 1711 $cmd .= " -simple -set_label $label -filter $filter "; 1711 1712 $cmd .= " -dateobs_begin ${lunation_start}T00:00:00 -dateobs_end ${lunation_end}T23:59:59 -distance 1.5 "; -
branches/eam_branches/ipp-20110906/ippScripts/scripts/register_exp.pl
r31043 r32630 54 54 55 55 my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $exp_id, $PS_EXIT_CONFIG_ERROR ); 56 $ipprc->redirect_ output($logfile) or my_die( "Unable to redirect output", $exp_id, $PS_EXIT_SYS_ERROR ) if $logfile;56 $ipprc->redirect_to_logfile($logfile) or my_die( "Unable to redirect output", $exp_id, $PS_EXIT_SYS_ERROR ) if $logfile; 57 57 58 58 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; -
branches/eam_branches/ipp-20110906/ippScripts/scripts/register_imfile.pl
r32298 r32630 60 60 61 61 my $ipprc = PS::IPP::Config->new() or my_die_for_add( "Unable to set up", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 62 $ipprc->redirect_ output($logfile) or my_die_for_add( "Unable to redirect output", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_SYS_ERROR ) if $logfile;62 $ipprc->redirect_to_logfile($logfile) or my_die_for_add( "Unable to redirect output", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_SYS_ERROR ) if $logfile; 63 63 64 64 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; … … 404 404 } 405 405 } 406 if ($exp_name =~ /a$/) { 407 return(1); 408 } 406 409 return(0); 407 410 } … … 517 520 518 521 carp($msg); 519 if (defined $exp_id && defined $ tmp_class_id and not $no_update) {522 if (defined $exp_id && defined $class_id and not $no_update) { 520 523 my $command = "$regtool -updateprocessedimfile"; 521 524 $command .= " -exp_id $exp_id"; -
branches/eam_branches/ipp-20110906/ippScripts/scripts/stack_skycell.pl
r31676 r32630 104 104 } 105 105 106 $ipprc->redirect_ output($logDest) or my_die( "Unable to redirect output", $stack_id, $PS_EXIT_SYS_ERROR ) if $redirect;106 $ipprc->redirect_to_logfile($logDest) or my_die( "Unable to redirect output", $stack_id, $PS_EXIT_SYS_ERROR ) if $redirect; 107 107 108 108 my $neb; … … 243 243 print $listFile "END\n\n"; 244 244 } 245 close($listFile); 245 246 246 247 print "I've checked everything: $stack_id\n"; … … 491 492 &my_die("Couldn't find expected output file: $file", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file); 492 493 494 # Funpack to confirm we've really made things correctly 495 my $diskfile = $ipprc->file_resolve($file); 496 if ($diskfile =~ /fits/) { 497 my $funpack = can_run('funpack') or &my_die ("Can't find funpack", $stack_id, $PS_EXIT_SYS_ERROR); 498 my $check_command = "$funpack -S $diskfile > /dev/null"; 499 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 500 run(command => $check_command, verbose => $verbose); 501 if (!$success) { 502 &my_die("Output file not a valid fits file: $file", $stack_id, $PS_EXIT_SYS_ERROR); 503 } 504 } 505 ##### 506 493 507 if ($replicate and $neb) { 494 508 $ipprc->replicate_file($file) or &my_die("failed to replicate: $file\n", $stack_id, $PS_EXIT_SYS_ERROR); -
branches/eam_branches/ipp-20110906/ippScripts/scripts/videophot_process.pl
r32125 r32630 8 8 my $host = hostname(); 9 9 my $date = `date`; 10 print "\n\n";11 print "Starting script $0 on $host at $date\n\n";12 13 10 use DateTime; 14 11 my $mjd_start = DateTime->now->mjd; # MJD of starting script … … 25 22 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 26 23 use Pod::Usage qw( pod2usage ); 24 use File::Temp qw( tempfile ); 25 use File::Basename qw( basename ); 27 26 28 27 # Look for programs we need 29 28 my $missing_tools; 30 29 my $vptool = can_run('vptool') or (warn "Can't find vptool" and $missing_tools = 1); 31 my $regtool = can_run('regtool') or (warn "Can't find regtool" and $missing_tools = 1);32 30 my $psvideophot = can_run('psvideophot') or (warn "Can't find psvideophot" and $missing_tools = 1); 31 my $dumpvideo = can_run('dumpvideo') or (warn "Can't find dumpvideo" and $missing_tools = 1); 33 32 my $listvideocells = can_run('listvideocells.pl') or (warn "Can't find listvideocells.pl" and $missing_tools = 1); 33 my $dsreg = can_run('dsreg') or (warn "Can't find dsreg" and $missing_tools = 1); 34 34 if ($missing_tools) { 35 35 warn("Can't find required tools."); 36 36 exit($PS_EXIT_CONFIG_ERROR); 37 37 } 38 my ($vp_id, $exp_id, $camera, $outroot, $dbname, $verbose, $no_update, $no_op, $redirect); 38 my ($vp_id, $camera, $outroot, $dest_id, $dbname, $verbose, $no_update, $no_op, $redirect, $save_temps); 39 my ($product, $ds_dbname, $ds_dbhost); 39 40 40 41 GetOptions( 41 42 'vp_id=s' => \$vp_id, 42 'exp_id=s' => \$exp_id,43 43 'camera=s' => \$camera, 44 44 'outroot=s' => \$outroot, 45 'dest_id=s' => \$dest_id, 46 'product=s' => \$product, 47 'ds_dbname=s' => \$ds_dbname, 48 'ds_dbhost=s' => \$ds_dbhost, 45 49 'dbname|d=s' => \$dbname, 46 50 'verbose' => \$verbose, 51 'save-temps' => \$save_temps, 47 52 'no-update' => \$no_update, # Don't update the database? 48 53 'no-op' => \$no_op, # Don't do any operations? … … 52 57 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 53 58 pod2usage( 54 -msg => "Required options: --vp_id -- exp_id --outroot --camera",59 -msg => "Required options: --vp_id --outroot --camera", 55 60 -exitval => 3, 56 61 ) unless defined $vp_id 57 and defined $exp_id58 62 and defined $camera 59 63 and defined $outroot; 60 64 65 pod2usage( 66 -msg => " --product -ds_dbname and --dsdbhost are required if --dest_id", 67 -exitval => 3, 68 ) if ($dest_id and !( defined $product and defined $ds_dbname and defined $ds_dbhost)); 69 61 70 62 71 $no_update = 1 if $no_op; 63 64 my $ipprc = PS::IPP::Config->new($camera) or my_die( "Unable to set up", $vp_id, 'nochip', 'nocell', $PS_EXIT_CONFIG_ERROR ); # IPP configuration 72 $vptool .= " -dbname $dbname" if $dbname; 73 74 my $ipprc = PS::IPP::Config->new($camera) or my_die( "Unable to set up", $vp_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 65 75 66 76 my $logDest = $ipprc->filename("LOG.EXP", $outroot); 67 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $vp_id, 'nochip', 'nocell', $PS_EXIT_SYS_ERROR ) if $redirect; 68 69 my $source_id = $ipprc->source_id($dbname, $PS_TABLE_ID_DIFF); 70 71 # Get list of components for subtraction 77 if ($redirect) { 78 $ipprc->redirect_to_logfile($logDest) or my_die( "Unable to redirect output", $vp_id, $PS_EXIT_SYS_ERROR ); 79 80 print "\n\n"; 81 print "Starting script $0 on $host at $date\n\n"; 82 } 83 84 # Get list of chips with pending video cells 72 85 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 73 86 my $files; 74 87 { 75 # my $command = "$vptool -pendingimfile -vp_id $vp_id"; 76 # $command .= " -dbname $dbname" if defined $dbname; 77 my $command = "$regtool -processedimfile -video_cells -exp_id $exp_id"; 78 $command .= " -dbname $dbname" if defined $dbname; 79 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 80 run(command => $command, verbose => $verbose); 81 unless ($success) { 82 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 83 &my_die("Unable to perform vptool -pendingimfile: $error_code", $vp_id, 'nochip', 'nocell', $error_code); 84 } 85 86 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 87 &my_die("Unable to parse metadata config doc", $vp_id, 'nochip', 'nocell', $PS_EXIT_PROG_ERROR); 88 $files = parse_md_list($metadata) or 89 &my_die("Unable to parse metadata list", $vp_id, 'nochip', 'nocell', $PS_EXIT_PROG_ERROR); 90 } 88 my $command = "$vptool -pendingimfile -vp_id $vp_id"; 89 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 90 run(command => $command, verbose => $verbose); 91 unless ($success) { 92 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 93 &my_die("Unable to perform vptool -pendingimfile: $error_code", $vp_id, $error_code); 94 } 95 96 my $output = join "", @$stdout_buf; 97 if ($output) { 98 my $metadata = $mdcParser->parse($output) or 99 &my_die("Unable to parse metadata config doc", $vp_id, $PS_EXIT_PROG_ERROR); 100 $files = parse_md_list($metadata) or 101 &my_die("Unable to parse metadata list", $vp_id, $PS_EXIT_PROG_ERROR); 102 } 103 } 104 91 105 92 106 foreach my $file (@$files) { … … 95 109 96 110 my $resolved = $ipprc->file_resolve($uri); 97 &my_die("Unable to resolve $uri", $vp_id, $ class_id, 'nocell', $PS_EXIT_UNKNOWN_ERROR) unless $resolved;111 &my_die("Unable to resolve $uri", $vp_id, $PS_EXIT_UNKNOWN_ERROR) unless $resolved; 98 112 99 113 my $command = "$listvideocells --file $resolved"; … … 102 116 unless ($success) { 103 117 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 104 &my_die("Unable to perform $command: $error_code", $vp_id, $class_id, 105 'nocell', $error_code); 118 &my_die("Unable to perform $command: $error_code", $vp_id, $error_code); 106 119 } 107 120 108 121 my @video_cells = split "\n", (join "", @$stdout_buf); 109 &my_die("No video cells found in $uri", $vp_id, $class_id, 110 'nocell', $PS_EXIT_UNKNOWN_ERROR) unless scalar @video_cells; 122 &my_die("No video cells found in $uri", $vp_id, $PS_EXIT_UNKNOWN_ERROR) unless scalar @video_cells; 111 123 112 124 foreach my $cell_id (@video_cells) { 113 my $command = "$psvideophot $outroot"; 125 my $path_base = "$outroot.$class_id.$cell_id"; 126 my $output = $ipprc->filename("PSVIDEOPHOT.OUTPUT", $path_base); 127 my $command = "$psvideophot $output"; 114 128 $command .= " -file $uri"; 129 $command .= " -class_id $class_id"; 115 130 $command .= " -cell_id $cell_id"; 116 $command .= " -dbname $dbname" if defined $dbname;131 my $vpstart = DateTime->now->mjd; 117 132 unless ($no_op) { 118 133 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 120 135 unless ($success) { 121 136 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 122 &my_die("Unable to perform p pSub: $error_code", $vp_id, $class_id, $cell_id, $error_code);137 &my_die("Unable to perform psvideophot: $error_code", $vp_id, $error_code); 123 138 } 124 125 # check_output($outputStats, 1);126 139 } else { 127 140 print "Not executing: $command\n"; 128 141 } 142 # dump the video cell and the video table to a file 143 unless ($no_op) { 144 my $output = $path_base . ".fits"; 145 my $extname = "$cell_id"; 146 my $command = "$dumpvideo $uri $extname $output -includetable"; 147 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 148 run(command => $command, verbose => $verbose); 149 unless ($success) { 150 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 151 &my_die("Unable to perform dumpvideo: $error_code", $vp_id, $error_code); 152 } 153 } else { 154 print "Not executing: $command\n"; 155 } 156 129 157 unless ($no_update) { 130 my $command = "$vptool -add vpcell -vp_id $vp_id -class_id $class_id -cell_id $cell_id";131 $command .= " -path_base $ outroot";132 133 $command .= " -d bname $dbname" if defined $dbname;158 my $command = "$vptool -addprocessedcell -vp_id $vp_id -class_id $class_id -cell_id $cell_id"; 159 $command .= " -path_base $path_base"; 160 $command .= " -hostname $host"; 161 $command .= " -dtime_photom " . ((DateTime->now->mjd - $vpstart) * 86400); 134 162 135 163 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 138 166 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 139 167 my $err_message = "Unable to perform vptool -addvpcell"; 140 &my_die("$err_message: $error_code", $vp_id, $ class_id, $cell_id, $error_code);168 &my_die("$err_message: $error_code", $vp_id, $error_code); 141 169 } 142 170 } 171 } 172 } 173 if ($dest_id) { 174 my $command = "$vptool -processedcell -vp_id $vp_id"; 175 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 176 run(command => $command, verbose => $verbose); 177 unless ($success) { 178 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 179 &my_die("Unable to perform vptool -pendingimfile: $error_code", $vp_id, $error_code); 180 } 181 182 my $output = join "", @$stdout_buf; 183 my $cells; 184 if ($output) { 185 my $metadata = $mdcParser->parse($output) or 186 &my_die("Unable to parse metadata config doc", $vp_id, $PS_EXIT_PROG_ERROR); 187 $cells = parse_md_list($metadata) or 188 &my_die("Unable to parse metadata list", $vp_id, $PS_EXIT_PROG_ERROR); 189 } 190 my ($reglist, $reglistName) = tempfile("/tmp/filelist.$vp_id.XXXX", UNLINK => !$save_temps); 191 192 if ($redirect) { 193 print $reglist "$logDest|||text|\n"; 194 } 195 my @exts = qw( vpt fits ); 196 my @types = qw( table fits ); 197 foreach my $cell (@$cells) { 198 my $path_base = $cell->{path_base}; 199 for (my $i = 0; $i < scalar @exts; $i++) { 200 my $file = "$path_base.$exts[$i]"; 201 my $type = $types[$i]; 202 203 print $reglist "$file|||$type|\n"; 204 } 205 206 } 207 close $reglist or &my_die("failed to close $reglistName", $vp_id, $PS_EXIT_UNKNOWN_ERROR); 208 unless ($no_update or $no_op) { 209 my $fileset = basename($outroot); 210 my $command = "$dsreg --add $fileset --product $product --type dump --list $reglistName"; 211 $command .= " --abspath --link"; 212 $command .= " --dbname $ds_dbname --dbhost $ds_dbhost"; 213 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 214 run(command => $command, verbose => $verbose); 215 unless ($success) { 216 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 217 &my_die("Unable to perform $command error_code: $error_code", $vp_id, $error_code); 218 } 219 } 220 } 221 222 unless ($no_update) { 223 my $command = "$vptool -updaterun -vp_id $vp_id -set_state full"; 224 $command .= " -set_outroot $outroot"; 225 $command .= " -set_hostname $host"; 226 $command .= " -set_dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400); 227 228 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 229 run(command => $command, verbose => $verbose); 230 unless ($success) { 231 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 232 my $err_message = "Unable to perform vptool -updaterun"; 233 &my_die("$err_message: $error_code", $vp_id, $error_code); 143 234 } 144 235 } … … 149 240 { 150 241 my $msg = shift; # Warning message on die 151 my $vp_id = shift; 152 my $class_id = shift; # chip identifier 153 my $cell_id = shift; # chip identifier 242 my $vp_id = shift; # vpRun id 154 243 my $exit_code = shift; # Exit code to add 155 244 … … 157 246 158 247 warn($msg); 159 if (defined $vp_id and defined $class_id and not $no_update) { 160 my $command = "$vptool -vp_id $vp_id -class_id $class_id -cell_id -fault $exit_code"; 161 $command .= " -addvpcell"; 162 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 163 $command .= " -hostname $host" if defined $host; 164 $command .= " -path_base $outroot" if defined $outroot; 165 $command .= " -dbname $dbname" if defined $dbname; 248 if (defined $vp_id and not $no_update) { 249 my $command = "$vptool -vp_id $vp_id"; 250 $command .= " -updaterun"; 251 $command .= " -set_fault $exit_code"; 252 $command .= " -set_hostname $host" if defined $host; 253 $command .= " -set_outroot $outroot" if defined $outroot; 254 $command .= " -set_dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400); 255 166 256 run(command => $command, verbose => $verbose); 167 257 } … … 169 259 } 170 260 171 END {172 my $exit = $?;173 system("sync") == 0 or die "failed to execute sync: $!";174 $? = $exit;175 }176 177 261 __END__ -
branches/eam_branches/ipp-20110906/ippScripts/scripts/warp_overlap.pl
r27718 r32630 57 57 58 58 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $warp_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 59 $ipprc->redirect_ output($logfile) or my_die( "Unable to redirect output", $warp_id, $PS_EXIT_SYS_ERROR ) if $logfile;59 $ipprc->redirect_to_logfile($logfile) or my_die( "Unable to redirect output", $warp_id, $PS_EXIT_SYS_ERROR ) if $logfile; 60 60 61 61 &my_die("Tessellation identifier not provided: $tess_dir", $warp_id, $PS_EXIT_SYS_ERROR) unless $tess_dir ne "NULL"; -
branches/eam_branches/ipp-20110906/ippScripts/scripts/warp_skycell.pl
r31941 r32630 38 38 39 39 my ($warp_id, $skycell_id, $warp_skyfile_id, $tess_dir, $reduction, $camera, $dbname, $outroot, $threads, $run_state, $magicked, $verbose, $no_update, $no_op, $redirect, $save_temps); 40 my $zaplog = 0;41 40 42 41 GetOptions( … … 55 54 'no-update' => \$no_update, # Don't update the database? 56 55 'no-op' => \$no_op, # Don't do any operations? 57 'zaplog' => \$zaplog, # delete previous logfile58 56 'redirect-output' => \$redirect, 59 57 'save-temps' => \$save_temps, # Save temporary files? … … 77 75 my $do_stats; 78 76 if ($run_state eq 'new') { 79 $logDest = prepare_output("LOG.EXP", $outroot, $skycell_id, $zaplog);77 $logDest = $ipprc->filename("LOG.EXP", $outroot, $skycell_id); 80 78 $traceDest = prepare_output("TRACE.EXP", $outroot, $skycell_id, 1); 81 79 $do_stats = 1; 82 80 } elsif ($run_state eq 'update') { 83 $logDest = prepare_output("LOG.EXP.UPDATE", $outroot, $skycell_id, 1);81 $logDest = $ipprc->filename("LOG.EXP.UPDATE", $outroot, $skycell_id); 84 82 $traceDest = prepare_output("TRACE.EXP.UPDATE", $outroot, $skycell_id, 1); 85 83 } else { … … 93 91 } 94 92 95 $ipprc->redirect_ output($logDest) or my_die( "Unable to redirect output", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR ) if $redirect;93 $ipprc->redirect_to_logfile($logDest) or my_die( "Unable to redirect output", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR ) if $redirect; 96 94 97 95 # Recipes to use based on reduction class … … 333 331 } 334 332 } 335 333 print "Quality: $quality\n"; 336 334 unless ($no_update) { 337 335 # XXX change -tess_id to -tess_dir when db is updated … … 358 356 } 359 357 } else { 358 359 my $quality = 0; 360 361 unless ($ipprc->file_exists($outputPSF)) { 362 $quality = 8006; # bad data. 363 } 364 # if (!$quality) { 365 # check_output($outputImage, 0); 366 # check_output($outputMask, 0); 367 # check_output($outputWeight, 0); 368 # check_output($outputSources, 1); 369 # check_output($outputPSF, 1) if metadataLookupBool($recipe, 'PSF') ; 370 # } 371 print "Quality: $quality\n"; 372 360 373 # $run_state eq 'update' 361 374 unless ($no_update) { … … 364 377 $command .= " -skycell_id $skycell_id"; 365 378 $command .= " -set_magicked $magicked" if $magicked; 379 $command .= " -set_quality $quality" if $quality; 366 380 $command .= " -dbname $dbname" if defined $dbname; 367 381 … … 407 421 408 422 &my_die("Couldn't find expected output file: $file", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file); 423 424 # Funpack to confirm we've really made things correctly 425 my $diskfile = $ipprc->file_resolve($file); 426 if ($diskfile =~ /fits/) { 427 my $funpack = can_run('funpack') or &my_die ("Can't find funpack", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR); 428 my $check_command = "$funpack -S $diskfile > /dev/null"; 429 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 430 run(command => $check_command, verbose => $verbose); 431 if (!$success) { 432 &my_die("Output file not a valid fits file: $file", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR); 433 } 434 } 435 ##### 409 436 410 437 if ($replicate and $neb) {
Note:
See TracChangeset
for help on using the changeset viewer.
