Changeset 31940
- Timestamp:
- Jul 26, 2011, 3:29:36 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tags/ipp-20110622/ippScripts/scripts/lap_science.pl
r31678 r31940 29 29 my ( $lap_id ); 30 30 my ( $chip_mode, $monitor_mode, $cleanup_mode); 31 32 # Global configuration constants that probably should be read from elsewhere. 33 my $qstack_threshold = 0.05; # Only make a quickstack if more than 5% of the exposures require it. 31 34 32 35 GetOptions( … … 85 88 unless (($lapRunInfo{state} eq 'full')|| 86 89 ($lapRunInfo{state} eq 'drop')) { 87 &my_die("Cannot run cleanup_mode if lapRun != done!", $lap_id);90 &my_die("Cannot run cleanup_mode if lapRun != full!", $lap_id); 88 91 } 89 92 my $status = cleanup_mode($lap_id); … … 456 459 my $can_fstack = 0; 457 460 my $total_exposures = 0; 461 my @lonely_exposures = (); 458 462 foreach my $exposure (@$exposures) { 459 463 $total_exposures++; … … 473 477 474 478 if ($exposure->{private}) { # I've declared this exposure private to this lapRun. 475 $needs_qstack = 1; 479 $needs_qstack++; 480 push @lonely_exposures, $exposure; 481 # $lonely_exposures++; 476 482 } 477 483 … … 510 516 unless ((defined($exposure->{diffRun_state}))&& 511 517 ($exposure->{diffRun_state} eq 'full')) { 512 $needs_qstack = 1;518 $needs_qstack++; 513 519 $needs_something_private = 1; 514 520 if ($companion) { … … 516 522 $companion->{pairwise} = 0; 517 523 &update_this_exposure($companion); 524 push @lonely_exposures, $companion; 525 # $lonely_exposures++; 518 526 } 519 527 $exposure->{private} = 1; … … 566 574 exit(0); 567 575 } 568 if (($needs_qstack == 1)&& # Do we need the quick stack?576 if (($needs_qstack > 0)&& # Do we need the quick stack? 569 577 ($defined_qstack == 0)&& # Have we not made it already? 570 578 ($can_qstack == $total_exposures)&& # Are all warps done? 571 579 ($needs_something_remade == 0) # Do we need to wait for a stolen exposure? 572 580 ) { 573 print "STATUS: Will now queue quickstacks\n"; 574 &queue_quickstack($exposures); 581 if ($needs_qstack < $total_exposures * $qstack_threshold) { # Drop any exposures that are requiring the qstack 582 print "STATUS: Insufficient unpaired exposures to justify quickstack. Dropping unpaired exposures\n"; 583 foreach my $exposure (@lonely_exposures) { 584 $exposure->{data_state} = 'drop'; 585 &update_this_exposure($exposure); 586 } 587 } 588 else { 589 print "STATUS: Will now queue quickstacks\n"; 590 &queue_quickstack($exposures); 591 } 575 592 } 576 593 … … 623 640 my $warps = ''; 624 641 foreach $exposure (@$exposures) { 625 if (($exposure->{data_state} !='drop')&&642 if (($exposure->{data_state} ne 'drop')&& 626 643 (S64_IS_NOT_NULL($exposure->{warp_id}))) { 627 644 $warps .= " -warp_id $exposure->{warp_id} "; … … 640 657 $command .= " -pretend " if defined $debug; 641 658 $command .= " -dbname $dbname " if defined $dbname; 642 $command .= " -definebyquery -select_label $ label-select_skycell_id ${proj_cell}.% -select_filter $filter ";659 $command .= " -definebyquery -select_label ${label}% -select_skycell_id ${proj_cell}.% -select_filter $filter "; 643 660 $command .= " -set_label ${label} -set_data_group $data_group "; 644 661 $command .= " -set_workdir $workdir -set_dist_group NODIST "; … … 702 719 my $warps = ''; 703 720 foreach $exposure (@$exposures) { 704 if (($exposure->{data_state} !='drop')&&721 if (($exposure->{data_state} ne 'drop')&& 705 722 (S64_IS_NOT_NULL($exposure->{magicked}))&& 706 723 (S64_IS_NOT_NULL($exposure->{warp_id}))) { … … 720 737 $command .= " -pretend " if defined $debug; 721 738 $command .= " -dbname $dbname " if defined $dbname; 722 $command .= " -definebyquery -select_label $ label-select_skycell_id ${proj_cell}.% -select_filter $filter ";739 $command .= " -definebyquery -select_label ${label}% -select_skycell_id ${proj_cell}.% -select_filter $filter "; 723 740 $command .= " -set_label ${label} -set_workdir $workdir -set_data_group $data_group "; 724 741 $command .= " -min_num 2 -set_reduction THREEPI_STACK -set_dist_group $exposure->{dist_group} "; … … 897 914 898 915 my @clean_modes = ( 899 'chiptool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -s tate full -set_label goto_cleaned -label @LABEL@ -chip_id @CHIP_ID@',900 'warptool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -s tate full -set_label goto_cleaned -label @LABEL@ -warp_id @WARP_ID@',901 'difftool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -s tate full -set_label goto_cleaned -label @LABEL@ -diff_id @DIFF_ID@',916 'chiptool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -set_label goto_cleaned -label @LABEL@ -chip_id @CHIP_ID@', 917 'warptool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -set_label goto_cleaned -label @LABEL@ -warp_id @WARP_ID@', 918 'difftool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -set_label goto_cleaned -label @LABEL@ -diff_id @DIFF_ID@', 902 919 'magicdstool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -stage chip -stage_id @CHIP_ID@', 903 920 'magicdstool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -stage warp -stage_id @WARP_ID@', … … 910 927 my $command = $clean_mode; 911 928 $command =~ s/\@DBNAME\@/$dbname/g; 912 $command =~ s/\@CHIP_ID\@/$exposure->{chip_id}/; 913 $command =~ s/\@WARP_ID\@/$exposure->{warp_id}/; 914 $command =~ s/\@DIFF_ID\@/$exposure->{diff_id}/; 929 if ($command =~ /\@CHIP_ID\@/) { 930 if (S64_IS_NOT_NULL($exposure->{chip_id})) { 931 $command =~ s/\@CHIP_ID\@/$exposure->{chip_id}/; 932 } 933 else { 934 next; 935 } 936 } 937 if ($command =~ /\@WARP_ID\@/) { 938 if (S64_IS_NOT_NULL($exposure->{warp_id})) { 939 $command =~ s/\@WARP_ID\@/$exposure->{warp_id}/; 940 } 941 else { 942 next; 943 } 944 } 945 if ($command =~ /\@DIFF_ID\@/) { 946 if (S64_IS_NOT_NULL($exposure->{diff_id})) { 947 $command =~ s/\@DIFF_ID\@/$exposure->{diff_id}/; 948 } 949 else { 950 next; 951 } 952 } 915 953 $command =~ s/\@LABEL\@/$exposure->{label}/; 916 954 … … 925 963 update_this_exposure($exposure); 926 964 } 965 966 # Cleanup quickstacks. 967 $command = "$laptool -stacks -lap_id $lap_id"; 968 $command .= " -dbname $dbname" if defined $dbname; 969 970 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 971 run(command => $command, verbose => $verbose); 972 unless ($success) { 973 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 974 &my_die("Unable to perform laptool -stacks: $error_code", "none", "none"); 975 } 976 if (@$stdout_buf == 0) { 977 # Nothing to do. 978 return(0); 979 } 980 981 my $stacks = $mdcParser->parse_list(join "", @$stdout_buf) or 982 &my_die("Unable to parse metadata from laptool -inactiveexp", $lap_id); 983 984 985 @clean_modes = ( 986 'stacktool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -set_label goto_cleaned -label @LABEL@ -stack_id @STACK_ID@'); 987 foreach my $stack (@$stacks) { 988 if (!S64_IS_NOT_NULL($stack->{quick_stack_id})) { 989 next; 990 } 991 foreach my $clean_mode (@clean_modes) { 992 my $command = $clean_mode; 993 $command =~ s/\@DBNAME\@/$dbname/g; 994 $command =~ s/\@LABEL\@/$stack->{label}/; 995 $command =~ s/\@STACK_ID\@/$stack->{quick_stack_id}/; 996 997 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 998 run(command => $command, verbose => $verbose); 999 unless ($success) { 1000 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 1001 &my_die("Unable to perform cleantool: $command : $error_code", "none", "none"); 1002 } 1003 } 1004 } 1005 1006 $command = "$laptool -updaterun -lap_id $lap_id"; 1007 $command .= " -dbname $dbname " if defined $dbname; 1008 $command .= " -set_state done "; 1009 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 1010 run(command => $command, verbose => $verbose); 1011 unless ($success) { 1012 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 1013 &my_die("Unable to perform laptool -updaterun: $error_code", $lap_id); 1014 } 1015 927 1016 } 928 1017
Note:
See TracChangeset
for help on using the changeset viewer.
