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