Changeset 28427 for trunk/ippScripts/scripts/automate_stacks.pl
- Timestamp:
- Jun 22, 2010, 6:20:00 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/automate_stacks.pl (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/automate_stacks.pl
r28388 r28427 17 17 my $missing_tools = 0; 18 18 my $chiptool = can_run('chiptool') or (warn "Can't find chiptool" and $missing_tools = 1); 19 my $dqstatstool = can_run('dqstatstool') or (warn "Can't find dqstatstool" and $missing_tools = 1); 19 20 my $warptool = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1); 20 21 my $stacktool= can_run('stacktool') or (warn "Can't find stacktool" and $missing_tools = 1); … … 28 29 exit($PS_EXIT_CONFIG_ERROR); 29 30 } 30 31 # my @filter_list = ('g.00000','r.00000','i.00000','z.00000','y.00000');32 # my @target_list = ('CMB','M31','MD01','MD02','MD03','MD04','MD05','MD06','MD07','MD08','MD09','MD10',33 # 'STS','SVS','SweetSpot','ThreePi');34 # my %tessID_list = ('CMB' => 'RINGS.V0', 'M31' => 'M31', 'MD01' => 'MD01', 'MD02' => 'MD02',35 # 'MD03' => 'MD03', 'MD04' => 'MD04', 'MD05' => 'MD05', 'MD06' => 'MD06',36 # 'MD07' => 'MD07', 'MD08' => 'MD08', 'MD09' => 'MD09', 'MD10' => 'MD10',37 # 'STS' => 'STS', 'SVS' => 'RINGS.V0', 'SweetSpot' => 'RINGS.V0', 'ThreePi' => 'RINGS.V0');38 # my %comment_list = ('CMB' => 'CMB_Cold%', 'M31' => 'M31%', 'MD01' => 'MD01%', 'MD02' => 'MD02%',39 # 'MD03' => 'MD03%', 'MD04' => 'MD04%', 'MD05' => 'MD05%', 'MD06' => 'MD06%',40 # 'MD07' => 'MD07%', 'MD08' => 'MD08%', 'MD09' => 'MD09%', 'MD10' => 'MD10%',41 # 'STS' => 'Stellar Transit%', 'SVS' => 'SVS%', 'SweetSpot' => 'Sweetspot%', 'ThreePi' => 'ThreePi%');42 # my %stackable_list = ('CMB' => 0, 'M31' => 1, 'MD01' => 1, 'MD02' => 1,43 # 'MD03' => 1, 'MD04' => 1, 'MD05' => 1, 'MD06' => 1,44 # 'MD07' => 1, 'MD08' => 1, 'MD09' => 1, 'MD10' => 1,45 # 'STS' => 1, 'SVS' => 0, 'SweetSpot' => 0, 'ThreePi' => 0);46 # my $retention_time = 9000; # days.47 48 31 49 32 my $db; … … 60 43 my ( $check_registration, $define_burntool, $queue_burntool, $check_chips, $queue_chips); 61 44 my ( $check_stacks, $queue_stacks, $check_diffs, $queue_diffs, $clean_old); 62 my ( $check_detrends, $queue_detrends );45 my ( $check_detrends, $queue_detrends, $check_dqstats, $queue_dqstats); 63 46 64 47 GetOptions( … … 83 66 'check_stacks' => \$check_stacks, 84 67 'queue_stacks' => \$queue_stacks, 85 'check_detrends' => \$check_detrends, 86 'queue_detrends' => \$queue_detrends, 68 'check_detrends' => \$check_detrends, 69 'queue_detrends' => \$queue_detrends, 70 'check_dqstats' => \$check_dqstats, 71 'queue_dqstats' => \$queue_dqstats, 87 72 'check_diffs' => \$check_diffs, 88 73 'queue_diffs' => \$queue_diffs, … … 111 96 --check_detrends Confirm that detrend verify runs can be built. 112 97 --queue_detrends Issue dettool commands to queue detrend verify runs. 98 --check_dqstats Confirm that dqstats tables can be built. 99 --queue_dqstats Issue dqstatstool commands to queue dqstat tables. 113 100 --check_diffs Confirm that diffs can be done. 114 101 --queue_diffs Issue difftool commands to queue diffs. … … 121 108 ) unless 122 109 defined $check_registration or defined $define_burntool or defined $queue_burntool or 123 defined $queue_chips or defined $queue_stacks or $queue_detrends or 124 defined $check_chips or defined $check_stacks or $check_detrends or 110 defined $queue_chips or defined $queue_stacks or $queue_detrends or $queue_dqstats or 111 defined $check_chips or defined $check_stacks or $check_detrends or $check_dqstats or 125 112 defined $test_mode or defined $clean_old or defined $check_mode; 126 113 … … 132 119 my %object_list = (); 133 120 my %comment_list= (); 121 my %cleanmods_list = (); 134 122 my %stackable_list = (); 135 123 my %reduction_class = (); … … 144 132 my %clean_retention = (); 145 133 my %noclean_list = (); 134 my %clean_alternate = (); 146 135 # Grab the configuration data. 147 136 my $conf_cmd = "$ppConfigDump -dump-recipe NIGHTLY_SCIENCE -"; … … 150 139 unless ($success) { 151 140 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 152 &my_die("Unable to perform ppConfigD Ump: $error_code", $date, $PS_EXIT_SYS_ERROR);141 &my_die("Unable to perform ppConfigDump: $error_code", $date, $PS_EXIT_SYS_ERROR); 153 142 } 154 143 … … 169 158 $clean_retention{$this_mode} = ${ $mentry }{value}; 170 159 } 160 elsif (${ $mentry }{name} eq 'ALTERNATE_CMD') { 161 $clean_alternate{$this_mode} = ${ $mentry }{value}; 162 } 171 163 } 172 164 } … … 202 194 elsif (${ $tentry }{name} eq 'NOCLEAN') { 203 195 $noclean_list{$this_target} = ${ $tentry }{value}; 196 } 197 else { 198 if (exists($clean_commands{ ${ $tentry }{name} })) { 199 $cleanmods_list{$this_target}{${ $tentry }{name} } = ${ $tentry }{value}; 200 } 204 201 } 205 202 } … … 292 289 unless (defined($test_mode) || defined($check_mode)) { exit(0); } 293 290 } 294 if (defined($check_detrends) || defined($test_mode)) { 291 if (defined($check_dqstats) || defined($test_mode)) { 292 $metadata_out{nsState} = 'CHECKDQSTATS'; 293 &execute_dqstats($date,"pretend"); 294 return_metadata($date); 295 unless (defined($test_mode) || defined($check_mode)) { exit(0); } 296 } 297 if (defined($queue_dqstats) || defined($test_mode)) { 298 $metadata_out{nsState} = 'QUEUEDQSTATS'; 299 &execute_dqstats($date); 300 return_metadata($date); 301 unless (defined($test_mode)) { exit(0); } 302 } 303 if (defined($check_detrends) || defined($test_mode) || defined($check_mode)) { 295 304 $metadata_out{nsState} = 'CHECKDETRENDS'; 296 305 &execute_detrends($date,"pretend"); … … 300 309 if (defined($queue_detrends)) { 301 310 $metadata_out{nsState} = 'QUEUEDETRENDS'; 302 &execute_detrends($date ,"pretend");311 &execute_detrends($date); 303 312 return_metadata($date); 304 313 exit(0); … … 613 622 } 614 623 615 616 617 624 sub chip_queue { 618 625 my $date = shift; … … 660 667 } 661 668 669 # 670 # DQstats 671 ################################################################################ 672 673 sub construct_dqstats_cmd { 674 my $date = shift; 675 676 my $select = "-dateobs_end ${date}T23:59:59 "; 677 678 my $cmd = "$dqstatstool"; 679 $cmd .= " -simple -dbname $dbname -definebyquery "; 680 $cmd .= " $select "; 681 $cmd .= " -label %.nightlyscience "; 682 $cmd .= " -set_label dqstats.nightlyscience "; 683 if ($debug == 1) { 684 $cmd .= ' -pretend '; 685 } 686 print STDERR "$cmd\n"; 687 return($cmd); 688 } 689 690 sub pre_dqstats_queue { 691 my $date = shift; 692 693 # my $db = init_gpc_db(); 694 # my $trunc_date = $date; $trunc_date =~ s/-//g; 695 696 # my $where = " label LIKE '%.nightlyscience' AND data_group' "; 697 # my $chip_sth = "SELECT * from chipRun WHERE (state = 'full' OR state = 'new' OR state = 'cleaned') AND $where "; 698 # my $cam_sth = "SELECT * from camRun WHERE state = 'full' AND $where "; 699 700 # my $chip_ref = $db->selectall_arrayref( $chip_sth ); 701 # my $cam_ref = $db->selectall_arrayref( $cam_sth ); 702 703 my $command = construct_dqstats_cmd($date) . ' -pretend '; 704 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 705 run ( command => $command, verbose => $verbose ); 706 unless ($success) { 707 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 708 &my_die("Unable to perform dqstatstool: $error_code",1,1,,$date, $PS_EXIT_SYS_ERROR); 709 } 710 711 my @input_exposures = split /\n/, (join '', @$stdout_buf); 712 713 return($#input_exposures + 1,1,1); # $#{ $chip_ref } + 1, $#{ $cam_ref } + 1); 714 } 715 716 sub dqstats_queue { 717 my $date = shift; 718 719 my $command = construct_dqstatstool_cmd($date); 720 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 721 run ( command => $command, verbose => $verbose ); 722 unless ($success) { 723 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 724 &my_die("Unable to perform dqstatstool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 725 } 726 return(0); 727 728 } 729 sub execute_dqstats { 730 my $date = shift; 731 my $pretend = shift; 732 my ($Nexposures,$Nchips,$Ncams) = pre_dqstats_queue($date); 733 if ($Nexposures == 0) { 734 print STDERR "execute_dqstats: No exposures on date $date.\n"; 735 } 736 elsif ($Ncams != $Nchips) { 737 print STDERR "execute_dqstats: Not done processing data through camera stage.\n"; 738 } 739 else { 740 unless(defined($pretend)) { 741 dqstats_queue($date); 742 } 743 } 744 } 662 745 # 663 746 # Detrend verification … … 735 818 $metadata_out{nsState} = 'DETREND_QUEUED'; 736 819 return(0); 737 } 738 820 821 } 739 822 sub execute_detrends { 740 823 my $date = shift; … … 754 837 if ($exposures == 0) { 755 838 $metadata_out{nsState} = 'DETREND_DROP'; 839 } 840 if (($metadata_out{nsState} eq 'CHECKDETRENDS') && ($exposures > 0)) { 841 $metadata_out{nsState} eq 'QUEUE_DETRENDS'; 756 842 } 757 843 } … … 914 1000 915 1001 my $command = $clean_commands{$mode}; 916 my $retention_time = $clean_retention{$mode}; 1002 my $retention_time; 1003 if (exists($cleanmods_list{$target}{$mode})) { 1004 $retention_time = $cleanmods_list{$target}{$mode}; 1005 } 1006 else { 1007 $retention_time = $clean_retention{$mode}; 1008 } 1009 if ($retention_time <= 0) { 1010 return("no clean","true"); 1011 } 917 1012 918 1013 my ($year,$month,$day) = split /-/,$date; … … 920 1015 hour => 0, minute => 0, second => 0, nanosecond => 0, 921 1016 time_zone => 'Pacific/Honolulu'); 1017 922 1018 $dt->subtract(days => $retention_time); 923 1019 my $cleaning_date = $dt->ymd; … … 925 1021 my ($label,$workdir,$obs_mode,$object,$comment,$tess_id,$dist_group,$data_group,$reduction) = get_tool_parameters($cleaning_date,$target); 926 1022 my $args = $command; 927 $args .= " -dbname $dbname -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -label $label -data_group $data_group "; 1023 if ((exists($clean_alternate{$mode})) && ($clean_alternate{$mode})) { 1024 $args .= " -dbname $dbname -updaterun -set_state goto_cleaned -full -set_label goto_cleaned -time_stamp_end $cleaning_date "; 1025 } 1026 else { 1027 $args .= " -dbname $dbname -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -label $label -data_group $data_group "; 1028 } 928 1029 if ($debug == 1) { 929 1030 $args .= ' -pretend '; … … 936 1037 my $pretend = shift; 937 1038 938 foreach my $mode (keys (%clean_commands)) { 939 foreach my $target (@target_list) { 940 if (exists($noclean_list{$target})) { 1039 foreach my $mode (sort (keys (%clean_commands))) { 1040 if ((exists($clean_alternate{$mode})) && ($clean_alternate{$mode})) { 1041 my ($cleaning_date,$command) = construct_cleantool_args($date,"",$mode); 1042 if ($cleaning_date eq 'no clean') { 941 1043 next; 942 1044 } 943 my ($cleaning_date,$command) = construct_cleantool_args($date,$target,$mode);944 945 1045 print STDERR "$command\n"; 946 1046 if (!(defined($pretend) || $debug == 1)) { … … 951 1051 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 952 1052 &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 1053 } 1054 } 1055 } 1056 else { 1057 foreach my $target (@target_list) { 1058 if (exists($noclean_list{$target})) { 1059 next; 1060 } 1061 my ($cleaning_date,$command) = construct_cleantool_args($date,$target,$mode); 1062 if ($cleaning_date eq 'no clean') { 1063 next; 1064 } 1065 print STDERR "$command\n"; 1066 if (!(defined($pretend) || $debug == 1)) { 1067 # print STDERR "BEAR IS DRIVING!?\n"; 1068 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 1069 run ( command => $command, verbose => $verbose ); 1070 unless ($success) { 1071 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 1072 &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 1073 } 953 1074 } 954 1075 }
Note:
See TracChangeset
for help on using the changeset viewer.
