Changeset 32422 for trunk/ippScripts/scripts/lap_science.pl
- Timestamp:
- Sep 21, 2011, 11:11:16 AM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/lap_science.pl (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/lap_science.pl
r32195 r32422 200 200 return($exposure); 201 201 } 202 203 sub remake_this_exposure_by_update { 204 my $exposure = shift; 205 206 my @utctime = gmtime(); 207 $utctime[5] += 1900; 208 $utctime[4] += 1; 209 210 my $label = $exposure->{label}; 211 212 my $date = sprintf("%4d%02d%02d",$utctime[5],$utctime[4],$utctime[3]); 213 my $workdir_date = sprintf("%4d/%02d/%02d",$utctime[5],$utctime[4],$utctime[3]); 214 my $workdir = "neb://\@HOST\@.0/${dbname}/${label}/${workdir_date}"; 215 my $data_group = "${label}.${date}"; 216 217 my $chiptool_info_cmd = "chiptool -listrun -exp_id $exposure->{exp_id} -chip_id $exposure->{chip_id} "; 218 $chiptool_info_cmd .= " -dbname $dbname " if defined $dbname; 219 220 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 221 run(command => $chiptool_info_cmd, verbose => $verbose); 222 unless ($success) { 223 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 224 &my_die("Unable to perform chiptool -listrun: $error_code", $exposure->{exp_id}, $data_group); 225 } 226 my $chips = $mdcParser->parse_list(join "", @$stdout_buf) or 227 &my_die("Unable to parse metadata from chiptool -listrun", $exposure->{exp_id}, $data_group); 228 # There should be only one. 229 my $chip = ${ $chips }[0]; 230 my $chip_magicDS_id = 0; 231 if ($chip) { 232 $chip_magicDS_id = $chip->{magic_ds_id}; 233 } 234 if ($chip_magicDS_id == 0) { 235 return(&remake_this_exposure($exposure)); 236 } 237 238 my $warptool_info_cmd = "warptool -listrun -exp_id $exposure->{exp_id} -chip_id $exposure->{chip_id} "; 239 $warptool_info_cmd .= " -dbname $dbname " if defined $dbname; 240 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 241 run(command => $warptool_info_cmd, verbose => $verbose); 242 unless ($success) { 243 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 244 &my_die("Unable to perform warptool -listrun: $error_code", $exposure->{exp_id}, $data_group); 245 } 246 my $warps = $mdcParser->parse_list(join "", @$stdout_buf) or 247 &my_die("Unable to parse metadata from warptool -listrun", $exposure->{exp_id}, $data_group); 248 # There should be only one. 249 my $warp = ${ $warps }[0]; 250 my $warp_id = 0; 251 if ($warp) { 252 $warp_id = $warp->{warp_id}; 253 } 254 else { 255 $exposure->{data_state} = 'drop'; 256 return($exposure); 257 } 258 if ($warp_id == 0) { 259 # Handle this correctly. Probably want to drop the exposure here. 260 $exposure->{data_state} = 'drop'; 261 return($exposure); 262 } 263 264 my $chiptool_update_cmd = "chiptool -setimfiletoupdate -chip_id $exposure->{chip_id} -set_label $label"; 265 $chiptool_update_cmd .= " -dbname $dbname " if defined $dbname; 266 my $magicDS_update_cmd = "magicdstool -setfiletoupdate -magic_ds_id $chip_magicDS_id -set_label $label"; 267 $magicDS_update_cmd .= " -dbname $dbname " if defined $dbname; 268 my $warptool_update_cmd = "warptool -setskyfiletoupdate -warp_id $warp_id -set_label $label"; 269 $warptool_update_cmd .= " -dbname $dbname " if defined $dbname; 270 271 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 272 run(command => $chiptool_update_cmd, verbose => $verbose); 273 unless ($success) { 274 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 275 &my_die("Unable to perform chiptool -setimfiletoupdate: $error_code", $exposure->{exp_id}, $data_group); 276 } 277 278 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 279 run(command => $magicDS_update_cmd, verbose => $verbose); 280 unless ($success) { 281 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 282 &my_die("Unable to perform magicdstool -setfiletoupdate: $error_code", $exposure->{exp_id}, $data_group); 283 } 284 285 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 286 run(command => $warptool_update_cmd, verbose => $verbose); 287 unless ($success) { 288 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 289 &my_die("Unable to perform warptool -setskyfiletoupdate: $error_code", $exposure->{exp_id}, $data_group); 290 } 291 292 $exposure->{active} = 1; 293 return($exposure); 294 } 295 296 sub determine_if_can_update { 297 my $exposure = shift; 298 299 if (S64_IS_NOT_NULL($exposure->{chip_id})) { 300 if (($exposure->{chip_state} eq 'cleaned')|| 301 ($exposure->{chip_state} eq 'error_cleaned')) { 302 return(1); 303 } 304 } 305 306 return(0); 307 } 308 202 309 203 310 # This is the "user level" subroutine. … … 240 347 my $comment = $exposure->{comment}; 241 348 242 # This is a hack to fix old exposures that have no object. 349 my $updateable = determine_if_can_update($exposure); 350 351 # This is a hack to fix old exposures that have no usable object/comment data. 243 352 unless(defined($comment)) { 244 353 $comment = ''; … … 247 356 if ($comment =~ /3pi_/) { 248 357 $object = $comment; 249 $object =~ s/^.*?(3pi_\d\d_\d\d\d\d).*?$/ $1/;358 $object =~ s/^.*?(3pi_\d\d_\d\d\d\d).*?$/F1 $1/; 250 359 } 251 360 elsif ($comment =~ / ps1_/) { 252 361 $object = $comment; 253 $object =~ s/^.*?(ps1_\d\d_\d\d\d\d).*$/$1/; 254 } 255 else { 256 $exposure->{data_state} = 'new'; 362 $object =~ s/^.*?(ps1_\d\d_\d\d\d\d).*$/F2 $1/; 363 } 364 elsif ($comment =~ /ThreePi.*3pi_/) { 365 $object = $comment; 366 $object =~ s/^ThreePi . (\S+? 3pi_\d\d_\d\d\d\d) .*$/F3 $1/; 367 } 368 elsif ($comment =~ /ThreePi.*ps1_/) { 369 $object = $comment; 370 $object =~ s/^ThreePi . (\S+? ps1_\d\d_\d\d\d\d) .*$/F4 $1/; 371 } 372 elsif ($comment =~ /ThreePi /) { 373 $object = $comment; 374 $object =~ s/^ThreePi . (\S+? \d\d\d\d) .*$/F5 $1/; 375 } 376 elsif (($comment =~ /focus/i)|| 377 ($comment =~ /test/i)|| 378 ($comment =~ /hyster/i)|| 379 ($comment =~ /dither/i)|| 380 ($comment =~ /camera/i) 381 ){ 382 # This is junk that shouldn't exist. 383 $object = 'DROP'; 384 $exposure->{data_state} = 'drop'; 257 385 $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++; 386 $exposure->{pair_id} = 9223372036854775807; 387 $exposure->{active} = 0; 388 &update_this_exposure($exposure); 389 $counter++; # To ensure everyone else is consistent 263 390 next; 264 391 } 265 392 } 266 393 394 # Determine the current state of chipRuns for these exposures, and update/remake as needed. 267 395 if (S64_IS_NOT_NULL($chip_id)) { # We already have a defined chip_id 268 396 if (($pairwise) && !($pair_id)) { … … 270 398 &my_die("Exposure $exp_id for $lap_id is declared pairwise without a defined pair", $lap_id); 271 399 } 400 $exposure->{data_state} = 'exists'; 401 if ($updateable) { # We know about this run, but the data needs to be regenerated. 402 $exposure->{data_state} = 'update'; 403 $exposure = remake_this_exposure_by_update($exposure); 404 } 405 &update_this_exposure($exposure); 272 406 $matching{$object}{$comment} = $exp_id; 273 407 $indexing{$exp_id} = $counter; 274 408 $counter++; 275 next;276 409 } 277 410 else { # We do not already have a chip_id. 278 411 # Make a chipRun, and update the exposure. 412 $exposure->{data_state} = 'run'; 279 413 $exposure = remake_this_exposure($exposure); 280 281 414 # Save our information for diff pairing. 415 &update_this_exposure($exposure); 282 416 $matching{$object}{$comment} = $exp_id; 283 417 $indexing{$exp_id} = $counter; 284 418 $counter++; 285 419 } 420 286 421 if ($verbose) { 287 422 print "ZZ: $exp_id $object $comment $matching{$object}{$comment}\n"; … … 296 431 print "$object $comment $matching{$object}{$comment} $indexing{$matching{$object}{$comment}} $exp_ids_to_diff[-1]\n"; 297 432 } 298 @exp_ids_to_diff = sort { $indexing{$a} <=> $indexing{$b} } @exp_ids_to_diff; 433 @exp_ids_to_diff = sort { $indexing{$a} <=> $indexing{$b} } @exp_ids_to_diff; # This is effectively a sort by dateobs. 299 434 300 435 if (( $#exp_ids_to_diff + 1) % 2 != 0) { # We have an odd number of exposures, even after comment filtering … … 310 445 print "$exp_A $exp_B $exp_id_A $exp_id_B $indexing{$exp_id_A} $indexing{$exp_id_B}\n"; 311 446 $exp_A->{pairwise} = 1; 312 $exp_A->{private} = 0;313 447 $exp_A->{pair_id} = $exp_B->{chip_id}; 314 448 315 449 $exp_B->{pairwise} = 1; 316 $exp_B->{private} = 0;317 450 $exp_B->{pair_id} = $exp_A->{chip_id}; 318 451 … … 331 464 $exposure->{pairwise} = 0; # We marked it for pairwise diffs, but didn't match it. Probably an error. 332 465 } 333 if (!($exposure->{pairwise})) { 334 $exposure->{private} = 1; # If this isn't being pairwise diffed, it needs to be private 335 } 336 466 337 467 update_this_exposure($exposure); 338 468 } … … 457 587 # Things I want to know before I'm through 458 588 # my $needs_qstack = 0; 459 my $needs_something_remade = 0; 460 my $needs_something_private = 0; 589 my $needs_something_remade = 0; # I never need something remade, because we're committed to one-exp=one-chip 590 my $needs_something_private = 0; # I never need something private, as that is calculated by the difference engine. 461 591 # my $can_qstack = 0; 462 592 my $have_diff = 0; … … 480 610 else { # We claimed to be pairwise, but do not have a valid pair_id. 481 611 $exposure->{pairwise} = 0; 482 $exposure->{private} = 1;483 612 &update_this_exposure($exposure); 484 613 } … … 487 616 if ($exposure->{data_state} eq 'drop') { # This exposure is impossible, so fudge the counts so we get through. 488 617 $are_warped++; 489 # $can_qstack ++;490 618 $can_diff ++; 491 619 $have_diff ++; 492 620 $are_magicked ++; 493 # $can_fstack ++;494 621 next; 495 622 } 496 623 497 624 if ($exposure->{private}) { # I've declared this exposure private to this lapRun. 498 # $needs_qstack++;499 625 push @lonely_exposures, $exposure; 500 # $lonely_exposures++;501 626 } 502 627 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 }628 # if ($exposure->{needs_remade}) { # This does the check that private = false for other lapRun 629 # $needs_something_remade = 1; 630 # $exposure = remake_this_exposure($exposure); 631 # } 507 632 # Do quality checks here 508 633 my $is_bad_quality = 0; … … 536 661 ($exposure->{diffRun_state} eq 'full')) { 537 662 $are_warped++; 538 # $needs_qstack++;539 $needs_something_private = 1;540 663 if ($companion) { 541 $companion->{private} = 1;542 664 $companion->{pairwise} = 0; 543 665 &update_this_exposure($companion); 544 push @lonely_exposures, $companion; 545 # $lonely_exposures++; 666 # push @lonely_exposures, $companion; 546 667 } 547 $exposure->{private} = 1;548 668 $exposure->{pairwise} = 0; 549 669 } … … 558 678 # $can_qstack ++; 559 679 $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 ++; 680 $exposure->{data_state} = 'to_diff'; 565 681 } 566 682 if (($exposure->{diff_id})&&(&S64_IS_NOT_NULL($exposure->{diff_id}))) { 567 683 $have_diff ++; 568 } 684 $exposure->{data_state} = 'to_magic'; 685 } 686 if (($exposure->{magicked})&& 687 ($exposure->{warpRun_state})&& 688 ($exposure->{warpRun_state} eq 'full')&& 689 (&S64_IS_NOT_NULL($exposure->{magicked}))) { # This exposure has been magicked, so it is through with diff. 690 $are_magicked++; 691 $exposure->{data_state} = 'full'; 692 # $can_fstack ++; 693 } 694 &update_this_exposure($exposure); 569 695 } 570 696 … … 575 701 print "STATUS: HAVE_FSTACK: $have_fstack\n"; 576 702 577 # print "STATUS: NEEDS_QSTACK: $needs_qstack\n";578 703 print "STATUS: NEEDS_REMADE: $needs_something_remade\n"; 579 704 print "STATUS: NEEDS PRIVATIZE: $needs_something_private\n"; 580 705 print "STATUS: ARE WARPED: $are_warped\n"; 581 706 print "STATUS: ARE MAGICKED: $are_magicked\n"; 582 # print "STATUS: CAN_QSTACK: $can_qstack\n";583 707 print "STATUS: CAN_DIFF: $can_diff\n"; 584 708 print "STATUS: HAVE_DIFF: $have_diff\n"; 585 # print "STATUS: CAN_FSTACK: $can_fstack\n";586 709 587 710 print "STATUS: TOTAL_EXPOSURES: $total_exposures\n"; … … 924 1047 next; 925 1048 } 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.1049 if ($exposure->{diff_id}&&S64_IS_NOT_NULL($exposure->{diff_id})) { # This happens when we inherit a complete exposure. 927 1050 next; 928 1051 } … … 964 1087 } 965 1088 else { # warp-qstack 1089 # We need to decide if we can make a warp-stack diff: 1090 if (&can_warp_stack_diff_be_made($exposure)) { 966 1091 # next; 967 1092 # $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; 1093 $command .= " -definewarpstack -available -good_frac 0.2 "; 1094 $command .= " -warp_id $exposure->{warp_id} -stack_label ${label} "; 1095 $already_queued{$exposure->{warp_id}} = 1; 1096 $exposure->{private} = 0; 1097 &update_this_exposure($exposure); 1098 } 1099 else { 1100 $exposure->{private} = 1; 1101 $exposure->{data_state} = 'drop'; 1102 $already_queued{$exposure->{warp_id}} = 1; 1103 &update_this_exposure($exposure); 1104 next; 1105 } 971 1106 } 972 1107 … … 1006 1141 } 1007 1142 1143 sub can_warp_stack_diff_be_made { 1144 my $exposure = shift; 1145 my $lap_id = $exposure->{lap_id}; 1146 my $warp_id = $exposure->{warp_id}; 1147 1148 my $command = "$laptool -diffcheck -lap_id $lap_id -warp_id $warp_id"; 1149 $command .= " -dbname $dbname " if defined $dbname; 1150 1151 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 1152 run(command => $command, verbose => $verbose); 1153 unless ($success) { 1154 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 1155 &my_die("Unable to perform laptool -diffcheck: $error_code", $lap_id, $warp_id); 1156 } 1157 if (@$stdout_buf == 0) { 1158 return(0); 1159 } 1160 my $skycells = $mdcParser->parse_list(join "", @$stdout_buf) or 1161 &my_die("Unable to parse metadata from laptool -diffcheck", $lap_id, $warp_id); 1162 foreach my $skycell (@$skycells) { 1163 if ($skycell->{stack_state} ne 'full') { 1164 return(0); 1165 } 1166 if ($skycell->{warp_state} ne 'full') { 1167 return(0); 1168 } 1169 unless (S64_IS_NOT_NULL($skycell->{stack_id})) { 1170 return(0); 1171 } 1172 } 1173 return(1); 1174 } 1175 1176 1008 1177 # Deactivate all exposures in this run. 1009 1178 sub deactivate_exposures { 1010 1179 my $exposures = shift; 1011 1180 foreach my $exposure (@$exposures) { 1012 $exposure->{active} = 0; 1013 update_this_exposure($exposure); 1181 unless ($exposure->{private} == 1) { 1182 $exposure->{active} = 0; 1183 update_this_exposure($exposure); 1184 } 1014 1185 } 1015 1186 } … … 1043 1214 'warptool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -set_label goto_cleaned -label @LABEL@ -warp_id @WARP_ID@', 1044 1215 'difftool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -set_label goto_cleaned -label @LABEL@ -diff_id @DIFF_ID@', 1216 'magictool -dbname @DBNAME@ -updaterun -set_state full -set_label @LABEL@.old -magic_id @MAGIC_ID@', 1045 1217 'magicdstool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -stage chip -stage_id @CHIP_ID@', 1046 1218 'magicdstool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -stage warp -stage_id @WARP_ID@', 1047 1219 'magicdstool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -stage diff -stage_id @DIFF_ID@'); 1220 1048 1221 foreach my $exposure (@$exposures) { 1049 1222 if ($exposure->{is_in_use}) { … … 1077 1250 } 1078 1251 } 1252 if ($command =~ /\@MAGIC_ID\@/) { 1253 if ((S64_IS_NOT_NULL($exposure->{magicked}))&& 1254 ($exposure->{magicked} > 0)) { 1255 $command =~ s/\@MAGIC_ID\@/$exposure->{magicked}/; 1256 } 1257 else { 1258 next; 1259 } 1260 } 1079 1261 $command =~ s/\@LABEL\@/$exposure->{label}/; 1080 1262
Note:
See TracChangeset
for help on using the changeset viewer.
