- Timestamp:
- Aug 26, 2010, 9:18:39 AM (16 years ago)
- Location:
- branches/sc_branches/trunkTest
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/automate_stacks.pl (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/sc_branches/trunkTest
- Property svn:mergeinfo changed
-
branches/sc_branches/trunkTest/ippScripts/scripts/automate_stacks.pl
r28916 r29060 46 46 my ( $check_stacks, $queue_stacks, $check_sweetspot, $queue_sweetspot, $check_diffs, $queue_diffs, $clean_old); 47 47 my ( $check_detrends, $queue_detrends, $check_dqstats, $queue_dqstats); 48 my ( $confirm_stacks, $check_confirm_stacks ); 48 49 49 50 GetOptions( … … 70 71 'check_stacks' => \$check_stacks, 71 72 'queue_stacks' => \$queue_stacks, 73 'confirm_stacks' => \$confirm_stacks, 74 'check_confirm_stacks' => \$check_confirm_stacks, 72 75 'check_sweetspot' => \$check_sweetspot, 73 76 'queue_sweetspot' => \$queue_sweetspot, … … 120 123 defined $queue_chips or defined $queue_stacks or $queue_sweetspot or $queue_detrends or $queue_dqstats or 121 124 defined $check_chips or defined $check_stacks or $check_sweetspot or $check_detrends or $check_dqstats or 122 defined $test_mode or defined $clean_old or defined $check_mode; 125 defined $test_mode or defined $clean_old or defined $check_mode or 126 defined $confirm_stacks; 123 127 124 128 # Configurable parameters from our config file. … … 132 136 my %stackable_list = (); 133 137 my %reduction_class = (); 138 my %macro_formats = (); 134 139 my @unrecoverable_quality = (); 135 140 my @detrend_list = (); … … 181 186 elsif (${ $entry }{name} eq 'UNRECOVERABLE_QUALITY') { 182 187 push @unrecoverable_quality, ${ $entry }{value}; 188 } 189 elsif (${ $entry }{name} eq 'MACRO_DEFINITIONS') { 190 my @macro_data = @{ ${ $entry }{value} }; 191 my $this_mode = ''; 192 foreach my $mentry (@macro_data) { 193 if (${ $mentry }{name} eq 'PROC_MODE') { 194 $this_mode = ${ $mentry }{value}; 195 } 196 elsif (${ $mentry }{name} eq 'MACRO') { 197 $macro_formats{$this_mode} = ${ $mentry }{value}; 198 } 199 } 183 200 } 184 201 elsif (${ $entry }{name} eq 'TARGETS') { … … 306 323 print "CLEAN: $z $clean_commands{$z} $clean_retention{$z}\n"; 307 324 } 325 foreach $z (keys (%macro_formats)) { 326 print "MACROS: $z $macro_formats{$z}\n"; 327 } 308 328 309 329 } … … 385 405 $metadata_out{nsState} = 'STACKING_POSSIBLE_ERROR'; 386 406 } 407 return_metadata($date); 408 exit(0); 409 } 410 411 if (defined($check_confirm_stacks) || defined($test_mode) || defined($check_mode)) { 412 $metadata_out{nsState} = 'CONFIRM_STACKING'; 413 &confirm_stacks($date,"pretend"); 414 return_metadata($date); 415 unless (defined($test_mode) || defined($check_mode)) { exit(0); } 416 } 417 if (defined($confirm_stacks)) { 418 $metadata_out{nsState} = 'CONFIRM_STACKING'; 419 &confirm_stacks($date); 387 420 return_metadata($date); 388 421 exit(0); … … 582 615 $metadata_out{btN} = $N - 1; 583 616 $metadata_out{btNCounter} = 0; 584 617 add_to_macro_list('define_burntool',1,$date); 585 618 return(0); 586 619 } … … 589 622 # Chips 590 623 ################################################################################ 624 591 625 592 626 sub construct_chiptool_cmd { … … 680 714 } 681 715 $metadata_out{nsState} = 'TOWARP'; 716 682 717 return(0); 683 718 } … … 696 731 if ($Nexposures == 0) { 697 732 print STDERR "execute_chips: Target $target on $date had no exposures.\n"; 698 next;733 # next; 699 734 } 700 735 if ($Nalready != 0) { 701 736 print STDERR "execute_chips: Not queueing $target on $date due to already existing exposures.\n"; 702 next;737 # next; 703 738 } 704 739 if ($Nimfiles != $Nburntooled) { … … 712 747 chip_queue($date,$target); 713 748 } 749 if (defined($pretend)) { 750 add_to_macro_list('check_chips',$stackable_list{$target},$date,$target); 751 } 752 else { 753 add_to_macro_list('queue_chips',$stackable_list{$target},$date,$target); 754 } 755 714 756 } 715 757 if ($exposures == 0) { … … 717 759 } 718 760 } 761 719 762 720 763 # … … 742 785 my $date = shift; 743 786 744 # my $db = init_gpc_db();745 # my $trunc_date = $date; $trunc_date =~ s/-//g;746 747 # my $where = " label LIKE '%.nightlyscience' AND data_group' ";748 # my $chip_sth = "SELECT * from chipRun WHERE (state = 'full' OR state = 'new' OR state = 'cleaned') AND $where ";749 # my $cam_sth = "SELECT * from camRun WHERE state = 'full' AND $where ";750 751 # my $chip_ref = $db->selectall_arrayref( $chip_sth );752 # my $cam_ref = $db->selectall_arrayref( $cam_sth );753 754 787 my $command = construct_dqstats_cmd($date) . ' -pretend '; 755 788 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 762 795 my @input_exposures = split /\n/, (join '', @$stdout_buf); 763 796 764 return($#input_exposures + 1,1,1); # $#{ $chip_ref } + 1, $#{ $cam_ref } + 1);797 return($#input_exposures + 1,1,1); 765 798 } 766 799 … … 791 824 unless(defined($pretend)) { 792 825 dqstats_queue($date); 826 } 827 if (defined($pretend)) { 828 add_to_macro_list('check_dqstats',1,$date); 829 } 830 else { 831 add_to_macro_list('queue_dqstats',1,$date); 793 832 } 794 833 } … … 887 926 detrend_queue($date,$target); 888 927 } 928 if (defined($pretend)) { 929 add_to_macro_list('check_detrends',1,$date,$target,"dettool"); 930 } 931 else { 932 add_to_macro_list('queue_detrends',1,$date,$target,"dettool"); 933 } 889 934 } 890 935 if ($exposures == 0) { … … 1023 1068 $metadata_out{nsState} = 'SS_DONE'; 1024 1069 sweetspot_queue($date); 1070 } 1071 if (defined($pretend)) { 1072 add_to_macro_list('check_sweetspot',1,$date); 1073 } 1074 else { 1075 add_to_macro_list('queue_sweetspot',1,$date); 1025 1076 } 1026 1077 } … … 1173 1224 stack_queue($date,$target,$filter); 1174 1225 } 1226 if (defined($pretend)) { 1227 add_to_macro_list('check_stacks',$stackable_list{$target},$date,$target,$filter); 1228 } 1229 else { 1230 add_to_macro_list('queue_stacks',$stackable_list{$target},$date,$target,$filter); 1231 } 1175 1232 } 1176 1233 } … … 1181 1238 1182 1239 } 1240 1241 sub post_stack_queue { 1242 my $date = shift; 1243 my $target = shift; 1244 1245 my ($label,$workdir,$obs_mode,$object,$comment,$tess_id,$dist_group,$data_group,$reduction) = get_tool_parameters($date,$target); 1246 # check warp stage == chip stage 1247 my $db = init_gpc_db(); 1248 1249 my $trunc_date = $date; $trunc_date =~ s/-//g; 1250 1251 my $where = " label = '$label' AND data_group = '$data_group' "; 1252 1253 my $stack_full_sth = "SELECT * from stackRun where $where "; 1254 my $stack_done_sth = "SELECT * from stackRun LEFT JOIN stackSumSkyfile USING(stack_id) WHERE $where "; 1255 $stack_done_sth .= " AND ((state = 'full') OR (state = 'new' && fault != 0)) "; 1256 1257 my $stack_full_ref = $db->selectall_arrayref( $stack_full_sth ); 1258 my $stack_done_ref = $db->selectall_arrayref( $stack_done_sth ); 1259 1260 return($#{ $stack_full_ref } + 1, $#{ $stack_done_ref } + 1); 1261 } 1262 1263 sub confirm_stacks { 1264 my $date = shift; 1265 my $pretend = shift; 1266 1267 foreach my $target (@target_list) { 1268 if ($stackable_list{$target} == 1) { 1269 my ($Nstacks, $Nattempted) = post_stack_queue($date,$target); 1270 if ($Nstacks != $Nattempted) { 1271 if ($debug == 1) { 1272 print STDERR "confirm_stacks: Target $target on $date is not done stacking. $Nstacks $Nattempted\n" 1273 } 1274 if ($metadata_out{nsState} eq 'CONFIRM_STACKING') { 1275 $metadata_out{nsState} = 'STACKING'; 1276 } 1277 1278 next; 1279 } 1280 if ($metadata_out{nsState} eq 'CONFIRM_STACKING') { 1281 if (defined($pretend)) { 1282 add_to_macro_list('check_confirm_stacks',$stackable_list{$target},$date,$target); 1283 } 1284 else { 1285 add_to_macro_list('confirm_stacks',$stackable_list{$target},$date,$target); 1286 } 1287 } 1288 } 1289 } 1290 } 1183 1291 1184 1292 # … … 1233 1341 1234 1342 foreach my $mode (@mode_list) { 1235 # if ((exists($clean_alternate{$mode})) && ($clean_alternate{$mode} eq 'A')) { 1236 # my ($cleaning_date,$command) = construct_cleantool_args($date,"",$mode); 1237 # if ($cleaning_date eq 'no clean') { 1238 # next; 1239 # } 1240 # print STDERR "$command\n"; 1241 # if (!(defined($pretend) || $debug == 1)) { 1242 # # print STDERR "BEAR IS DRIVING!?\n"; 1243 # my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 1244 # run ( command => $command, verbose => $verbose ); 1245 # unless ($success) { 1246 # $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 1247 # &my_die("Unable to perform cleantool ($command): $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 1248 # } 1249 # } 1250 # } 1251 # else { 1252 foreach my $target (@target_list) { 1253 if (exists($noclean_list{$target})) { 1254 next; 1343 foreach my $target (@target_list) { 1344 if (exists($noclean_list{$target})) { 1345 next; 1346 } 1347 my ($cleaning_date,$command) = construct_cleantool_args($date,$target,$mode); 1348 if ($cleaning_date eq 'no clean') { 1349 next; 1350 } 1351 print STDERR "$command\n"; 1352 if (!(defined($pretend) || $debug == 1)) { 1353 # print STDERR "BEAR IS DRIVING!?\n"; 1354 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 1355 run ( command => $command, verbose => $verbose ); 1356 unless ($success) { 1357 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 1358 &my_die("Unable to perform cleantool ($command): $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 1255 1359 } 1256 my ($cleaning_date,$command) = construct_cleantool_args($date,$target,$mode); 1257 if ($cleaning_date eq 'no clean') { 1258 next; 1259 } 1260 print STDERR "$command\n"; 1261 if (!(defined($pretend) || $debug == 1)) { 1262 # print STDERR "BEAR IS DRIVING!?\n"; 1263 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 1264 run ( command => $command, verbose => $verbose ); 1265 unless ($success) { 1266 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 1267 &my_die("Unable to perform cleantool ($command): $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 1268 } 1269 } 1270 } 1271 # } 1360 add_to_macro_list('clean_old',1,$date,$target,$mode); 1361 } 1362 } 1272 1363 } 1273 1364 return(0); 1274 1365 } 1275 1276 1277 1278 1366 1279 1367 # … … 1324 1412 my $workdir = 'neb://@HOST@.0/' . $dbname . "/detverify.nt/${workdir_date}/${lc_type}${internal_filter}"; 1325 1413 return($label,$workdir,$det_filter,$exp_type,$det_type,$ref_det_id,$ref_iter,$maxN); 1414 } 1415 1416 sub add_to_macro_list { 1417 my $proc_mode = shift; 1418 my $do_or_do_not = shift; 1419 my $date = shift; 1420 my $target = shift; 1421 my $mode = shift; 1422 1423 if ((defined($macro_formats{$proc_mode}))&&($do_or_do_not)) { 1424 unless (defined($metadata_out{N_MACROS})) { 1425 $metadata_out{N_MACROS} = 0; 1426 } 1427 my $N = $metadata_out{N_MACROS}; 1428 $metadata_out{"ns${N}Macro"} = $macro_formats{$proc_mode}; 1429 print STDERR "WORKING ON A MACRO: ns${N}Macro $proc_mode $macro_formats{$proc_mode}\n"; 1430 if (defined($date)&&(defined($target))) { 1431 1432 my ($label,$workdir,$obs_mode,$object,$comment,$tess_id,$dist_group,$data_group,$reduction) 1433 = get_tool_parameters($date,$target); 1434 $metadata_out{"ns${N}Macro"} =~ s/\@LABEL\@/$label/; 1435 $metadata_out{"ns${N}Macro"} =~ s/\@WORKDIR\@/$workdir/; 1436 $metadata_out{"ns${N}Macro"} =~ s/\@OBS_MODE\@/$obs_mode/; 1437 $metadata_out{"ns${N}Macro"} =~ s/\@OBJECT\@/$object/; 1438 $metadata_out{"ns${N}Macro"} =~ s/\@COMMENT\@/$comment/; 1439 $metadata_out{"ns${N}Macro"} =~ s/\@TESS_ID\@/$tess_id/; 1440 $metadata_out{"ns${N}Macro"} =~ s/\@DIST_GROUP\@/$dist_group/; 1441 $metadata_out{"ns${N}Macro"} =~ s/\@DATA_GROUP\@/$data_group/; 1442 $metadata_out{"ns${N}Macro"} =~ s/\@REDUCTION\@/$reduction/; 1443 } 1444 if (defined($mode)) { 1445 $metadata_out{"ns${N}Macro"} =~ s/\@EXTRA\@/$mode/; 1446 } 1447 if (defined($date)) { 1448 $metadata_out{"ns${N}Macro"} =~ s/\@DATE\@/$date/; 1449 } 1450 $metadata_out{N_MACROS} ++; 1451 } 1326 1452 } 1327 1453
Note:
See TracChangeset
for help on using the changeset viewer.
