Changeset 30575 for trunk/ippScripts/scripts/nightly_science.pl
- Timestamp:
- Feb 11, 2011, 2:15:44 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/nightly_science.pl (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/nightly_science.pl
r30411 r30575 1266 1266 } 1267 1267 1268 sub multi_date_verify_uniqueness_diff { 1269 my $warp_id_1 = shift; 1270 my $warp_id_2 = shift; 1271 my $date = shift; 1272 my $target = shift; 1273 1274 my $db = init_gpc_db(); 1275 $date =~ s/-//g; 1276 my ($label,$workdir,$obs_mode,$object,$comment,$tess_id,$dist_group,$data_group,$reduction) = get_tool_parameters($date,$target); 1277 1278 my $count = 0; 1279 1280 my $sth = "SELECT DISTINCT diff_id from diffRun JOIN diffInputSkyfile USING(diff_id) where (label = '$label' OR label = 'goto_cleaned') AND warp1 = $warp_id_1 AND warp2 = $warp_id_2"; 1281 my $data_ref = $db->selectall_arrayref( $sth ); 1282 $count += $#{ $data_ref } + 1; 1283 1284 $sth = "SELECT DISTINCT diff_id from diffRun JOIN diffInputSkyfile USING(diff_id) where (label = '$label' OR label = 'goto_cleaned') AND warp1 = $warp_id_2 AND warp2 = $warp_id_1"; 1285 $data_ref = $db->selectall_arrayref( $sth ); 1286 $count += $#{ $data_ref } + 1; 1287 1288 return($count); 1289 } 1290 1268 1291 sub pre_diff_queue { 1269 1292 my $date = shift; … … 1375 1398 $metadata_out{nsDiffState} = 'DIFFING'; 1376 1399 } 1377 1400 if ($metadata_out{nsDiffState} eq 'FINISHED_DIFFS') { 1401 foreach my $target (sort (keys %science_config)) { 1402 if ($science_config{$target}{DIFFABLE} == 1) { 1403 foreach my $filter (@filter_list) { 1404 multi_date_diff_queue($date,$target,$filter,$pretend); 1405 } 1406 } 1407 } 1408 } 1378 1409 # if (($Npotential == $Nnoexp)&&($metadata_out{nsObservingState} eq 'END_OF_NIGHT')&&($is_processing == 0)) { 1379 1410 # $metadata_out{nsDiffState} = 'FINISHED_DIFFS'; … … 1511 1542 1512 1543 } 1544 1545 sub multi_date_diff_queue { 1546 my $date = shift; 1547 my $target = shift; 1548 my $filter = shift; 1549 my $pretend = shift; 1550 my ($label,$workdir,$obs_mode,$object,$comment,$tess_id,$dist_group,$data_group,$reduction) = get_tool_parameters($date,$target); 1551 1552 my $db = init_gpc_db(); 1553 1554 my $obj_sth = "select DISTINCT rawExp.object from warpRun JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) "; 1555 $obj_sth .= " WHERE warpRun.state = 'full' AND warpRun.label = '$label' AND rawExp.filter = '$filter' ORDER BY rawExp.object"; 1556 1557 my $object_ref = $db->selectall_arrayref( $obj_sth ); 1558 1559 my $Npotential = 0; 1560 my $Nqueued = 0; 1561 1562 foreach my $object_row (@{ $object_ref }) { 1563 my $this_object = shift @{ $object_row }; 1564 # my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment from warpRun JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) "; 1565 # $input_sth .= " WHERE warpRun.state = 'full' AND warpRun.label = '$label' AND warpRun.data_group = '$data_group' AND rawExp.filter = '$filter' AND rawExp.object = '$this_object' "; 1566 # $input_sth .= " ORDER BY dateobs "; 1567 1568 my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment,warpRun.state AS warp_state FROM "; 1569 $input_sth .= " rawExp LEFT JOIN chipRun USING (exp_id) LEFT JOIN camRun USING (chip_id) LEFT JOIN fakeRun USING (cam_id) LEFT JOIN warpRun USING (fake_id) "; 1570 $input_sth .= " WHERE warpRun.label = '$label' AND rawExp.filter = '$filter' AND rawExp.object = '$this_object' "; 1571 $input_sth .= " ORDER BY dateobs "; 1572 1573 my $warps = $db->selectall_arrayref( $input_sth ); 1574 1575 # Each comment should only appear once. Therefore, if we see it more than once, we assume the first is extra. 1576 my %comment_hash = (); 1577 foreach my $this_warp (@{ $warps }) { 1578 my $this_comment = ${ $this_warp }[3]; 1579 my $this_exp_id = ${ $this_warp }[0]; 1580 $comment_hash{$this_comment} = $this_exp_id; 1581 } 1582 1583 if (($#{ $warps } + 1) % 2 != 0) { 1584 print STDERR "md_diff_queue: Number of input warps to make diffs is not even for target $target and object $this_object! $#{ $warps } "; 1585 if ($#{ $warps} + 1 == 1) { 1586 print STDERR ": I can do no diffs with only one exposure.\n"; 1587 next; 1588 } 1589 else { 1590 print STDERR ": I should declare an exposure to be faulty.\n"; 1591 my @keep_warps = (); 1592 # print "@{ $warps }\n"; 1593 foreach my $this_warp (@{ $warps }) { 1594 my $this_comment = ${ $this_warp }[3]; 1595 my $this_exp_id = ${ $this_warp }[0]; 1596 if ($comment_hash{$this_comment} == $this_exp_id) { 1597 push @keep_warps, $this_warp; 1598 } 1599 else { 1600 print STDERR "md_diff_queue: excluding $this_exp_id for $this_object\n"; 1601 } 1602 } 1603 @{ $warps } = @keep_warps; 1604 # print "@{ $warps }\n"; 1605 } 1606 } 1607 1608 while ($#{ $warps } > -1) { 1609 my $input_warp = shift @{ $warps }; 1610 my $input_exp_id = ${ $input_warp }[0]; 1611 my $input_comment = ${ $input_warp }[3]; 1612 1613 1614 my $template_warp = shift @{ $warps }; 1615 1616 my $template_exp_id = ${ $template_warp }[0]; 1617 1618 my $input_warp_id = ${ $input_warp }[1]; 1619 my $template_warp_id = ${ $template_warp }[1]; 1620 1621 my $input_warp_state = ${ $input_warp }[4]; 1622 my $template_warp_state = ${ $template_warp }[4]; 1623 1624 unless(defined($template_warp)&& defined($template_exp_id)) { 1625 print STDERR "md_diff received an undef! $input_exp_id $input_comment $this_object T: $template_warp V: @$template_warp\n"; 1626 next; 1627 } 1628 $Npotential++; 1629 1630 unless (defined($input_warp_id) && defined($template_warp_id) && 1631 ($input_warp_state eq 'full')&&($template_warp_state eq 'full')) { 1632 print STDERR "md_Diff for this $date $target $input_exp_id ($input_warp_id $input_warp_state) $template_exp_id ($template_warp_id $template_warp_state) not fully processed\n"; 1633 next; 1634 } 1635 1636 if (multi_date_verify_uniqueness_diff($input_warp_id,$template_warp_id,$date,$target) != 0) { 1637 $Nqueued++; 1638 print STDERR "md_Diffs already queued for this $date $target $input_exp_id $template_exp_id ($input_warp_id $template_warp_id) $this_object $input_comment\n"; 1639 next; 1640 } 1641 1642 my $new_data_group = "${data_group}.multi"; 1643 my $cmd = "$difftool -dbname $dbname -definewarpwarp "; 1644 $cmd .= "-input_label $label -template_label $label "; 1645 $cmd .= "-backwards "; # Needed because difftool assumes a different date sorting. 1646 $cmd .= "-set_workdir $workdir -set_dist_group $dist_group -set_data_group $new_data_group "; 1647 $cmd .= " -simple -set_label $label -exp_id $input_exp_id -template_exp_id $template_exp_id "; 1648 # $cmd .= " -pretend "; 1649 if (defined($pretend)) { 1650 $cmd .= ' -pretend '; 1651 } 1652 if ($debug == 1) { 1653 $cmd .= ' -pretend '; 1654 print STDERR "md_Diffs would like to queue for this $date $target $input_exp_id $template_exp_id ($input_warp_id $template_warp_id) $this_object $input_comment\n"; 1655 print STDERR "md_diff_queue: $cmd\n"; 1656 print STDERR " $input_warp_id $template_warp_id\n"; 1657 } 1658 1659 if (($debug == 0)&&(!defined($pretend))) { 1660 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 1661 run ( command => $cmd, verbose => $verbose ); 1662 unless ($success) { 1663 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 1664 &my_die("Unable to perform difftool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 1665 } 1666 $Nqueued++; 1667 } 1668 } 1669 } 1670 $metadata_out{nsDiffPotential} += $Npotential; 1671 $metadata_out{nsDiffQueued} += $Nqueued; 1672 # if (($metadata_out{nsDiffPotential} == $metadata_out{nsDiffQueued})&&($metadata_out{nsObservingState} eq 'END_OF_NIGHT')) { 1673 # $metadata_out{nsDiffState} = 'FINISHED_DIFFS'; 1674 # } 1675 1676 } 1513 1677 1514 1678
Note:
See TracChangeset
for help on using the changeset viewer.
