Changeset 40530 for trunk/ippScripts/scripts/night_report.pl
- Timestamp:
- Sep 26, 2018, 12:13:43 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/night_report.pl (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/night_report.pl
r40461 r40530 12 12 GetOptions( 13 13 'date=s' => \$date, 14 'dbname|d=s' => \$dbname, # Database name 15 'verbose' => \$verbose, # Print to stdout 16 'very-verbose' => \$verbose2, # Print to stdout 14 'dbname|d=s' => \$dbname, # Database name 15 'verbose' => \$verbose, # Print to stdout 16 'report' => \$report, # Formatted for ps-obs report 17 'very-verbose' => \$verbose2, # Print to stdout 17 18 ) or pod2usage( 2 ); 18 19 … … 45 46 my $dbh = DBI->connect( $dsn, $dbuser, $dbpass ) or die "Unable to connect to database: $DBI::errstr"; 46 47 47 # find a useful exp_id 48 # find a useful exp_id (ALWAYS do this) 48 49 $refExpID = 0; 49 50 if (1) { … … 63 64 print "*** WARNING: no data in period 10-20 days before requested date (query will be slower) **\n"; 64 65 } 65 # print "Reference exp_id: $refExpID\n"; 66 } 66 if ($verbose2) { print "Reference exp_id: $refExpID\n"; } 67 } 68 69 ##################33 70 ### testing the diff grouping -- this does not work for the Euclid data taken 2018.07.29 because the OBJECT 71 ### field is missing 72 if (0) { 73 print "Expected number of WWdiffs excluding camRuns with bad quality:\n"; 74 print "NOTE: multiple exposures with same comment string (xyz visit a) are treated as 1 exposure\n"; 75 76 # my $query = "SELECT Nvisit, count(*) FROM"; 77 # $query .= " ("; 78 # $query .= " SELECT object, filter, chunk, count(*) as Nvisit FROM"; 79 # $query .= " ("; 80 my $query = "SELECT object, filter, comment, 'S', substr(comment, 1, position(' ' in comment)) as chunk, 'E'"; 81 $query .= " FROM rawExp"; 82 $query .= " LEFT JOIN chipRun using (exp_id)"; 83 $query .= " LEFT JOIN camRun using (chip_id)"; 84 $query .= " LEFT JOIN camProcessedExp using (cam_id)"; 85 $query .= " WHERE dateobs LIKE '$date%'"; 86 $query .= " AND exp_id > $refExpID"; #REF 87 $query .= " AND exp_type = 'OBJECT'"; 88 $query .= " AND obs_mode NOT LIKE 'ENGINEERING'"; 89 $query .= " AND (obs_mode like '%SS%' or obs_mode like 'BRIGHT')"; 90 $query .= " AND rawExp.comment like '%visit%'"; 91 $query .= " AND (camProcessedExp.quality IS NULL or camProcessedExp.quality = 0)"; 92 # $query .= " GROUP BY comment, filter, substr(comment, 1, position(' ' in comment))"; 93 # $query .= " ) AS tableChunks GROUP BY object, filter, chunk"; 94 # $query .= " ) AS tableVisits GROUP BY Nvisit"; 95 96 my $result = &mysql_select ($query); 97 &mysql_dump_result ($result); 98 die; 99 100 $diffExpect = 0; 101 while (@row = $result->fetchrow_array()) { 102 # printf "%8s %15s : ", $row[0], $row[1]; # c, count(*) 103 if ($row[0] == 1) { 104 if ($row[1] == 1) { $verb = "tuple has"; } else { $verb = "tuples have"; } 105 printf "%3d %-11s 1 visit, no WWdiffs\n", $row[1], $verb; 106 } elsif ($row[0] == 2) { 107 if ($row[1] == 1) { $verb = "tuple has"; } else { $verb = "tuples have"; } 108 printf "%3d %-11s 2 visits, expect $row[1] WWdiff(s)\n", $row[1], $verb; 109 $diffExpect += $row[1]; 110 } elsif ($row[0] == 3) { 111 if ($row[1] == 1) { $verb = "tuple has"; } else { $verb = "tuples have"; } 112 printf "%3d %-11s 3 visits, expect %d WWdiffs (2 per tuple)\n", $row[1], $verb, 2 * $row[1]; 113 $diffExpect += $row[1]*2; 114 } elsif ($row[0] == 4) { 115 if ($row[1] == 1) { $verb = "tuple has"; } else { $verb = "tuples have"; } 116 printf "%3d %-11s 4 visits, expect %d WWdiffs (2 per tuple)\n", $row[1], $verb, 2 * $row[1]; 117 $diffExpect += $row[1]*2; 118 } else { 119 # print "I don't understand, there are more visits than I expect\n"; 120 if ($row[1] == 1) { $verb = "tuple has"; } else { $verb = "tuples have"; } 121 if ($row[0] % 2) { $Ndiffs = int($row[0] / 2) + 1; } else { $Ndiffs = int($row[0] / 2); } 122 printf "%3d %-11s %d visits, expect %d WWdiffs (2 per quad)\n", $row[1], $verb, $row[0], $Ndiffs; 123 $diffExpect += $Ndiffs; 124 } 125 } 126 print "\n"; 127 print " * $diffExpect diffRuns expected *\n"; 128 if ($verbose) { print "\n"; } 129 130 die; 131 } 132 ###################### 67 133 68 134 # check the status of summit exposures: … … 129 195 # check the status of raw exposures: 130 196 if (1) { 131 if ($verbose ) { print "Exposures in rawExp:\n"; }197 if ($verbose or $report) { print "Exposures in rawExp:\n"; } 132 198 133 199 $expSkipped = 0; … … 144 210 my $result = &mysql_select ($query); 145 211 146 if ($verbose ) { printf "%8s %15s %6s %4s\n", "exp_type", "obs_mode", "state", "N(exp)"; }147 while (@row = $result->fetchrow_array()) { 148 if ($verbose ) { printf "%8s %15s %6s %4d\n", $row[0], $row[1], $row[2], $row[3]; }212 if ($verbose or $report) { printf "%8s %15s %6s %4s\n", "exp_type", "obs_mode", "state", "N(exp)"; } 213 while (@row = $result->fetchrow_array()) { 214 if ($verbose or $report) { printf "%8s %15s %6s %4d\n", $row[0], $row[1], $row[2], $row[3]; } 149 215 if ($row[2] eq "new") { 150 216 $expPending += $row[3]; … … 294 360 # count the number of exposures per chunk, determine expected diffRuns: 295 361 { 296 print "Expected number of WWdiffs excluding camRuns with bad quality:\n"; 297 print "NOTE: multiple exposures with same comment string (xyz visit a) are treated as 1 exposure\n"; 362 if ($report) { 363 print "\n"; 364 } else { 365 print "Expected number of WWdiffs excluding camRuns with bad quality:\n"; 366 print "NOTE: multiple exposures with same comment string (xyz visit a) are treated as 1 exposure\n"; 367 } 298 368 299 369 # my $result = &mysql_select (""); … … 324 394 # printf "%8s %15s : ", $row[0], $row[1]; # c, count(*) 325 395 if ($row[0] == 1) { 326 if ($row[1] == 1) { $verb = " quad has"; } else { $verb = "quads have"; }396 if ($row[1] == 1) { $verb = "tuple has"; } else { $verb = "tuples have"; } 327 397 printf "%3d %-11s 1 visit, no WWdiffs\n", $row[1], $verb; 328 398 } elsif ($row[0] == 2) { 329 if ($row[1] == 1) { $verb = " quad has"; } else { $verb = "quads have"; }399 if ($row[1] == 1) { $verb = "tuple has"; } else { $verb = "tuples have"; } 330 400 printf "%3d %-11s 2 visits, expect $row[1] WWdiff(s)\n", $row[1], $verb; 331 401 $diffExpect += $row[1]; 332 402 } elsif ($row[0] == 3) { 333 if ($row[1] == 1) { $verb = " quad has"; } else { $verb = "quads have"; }334 printf "%3d %-11s 3 visits, expect %d WWdiffs (2 per quad)\n", $row[1], $verb, 2 * $row[1];403 if ($row[1] == 1) { $verb = "tuple has"; } else { $verb = "tuples have"; } 404 printf "%3d %-11s 3 visits, expect %d WWdiffs (2 per tuple)\n", $row[1], $verb, 2 * $row[1]; 335 405 $diffExpect += $row[1]*2; 336 406 } elsif ($row[0] == 4) { 337 if ($row[1] == 1) { $verb = " quad has"; } else { $verb = "quads have"; }338 printf "%3d %-11s 4 visits, expect %d WWdiffs (2 per quad)\n", $row[1], $verb, 2 * $row[1];407 if ($row[1] == 1) { $verb = "tuple has"; } else { $verb = "tuples have"; } 408 printf "%3d %-11s 4 visits, expect %d WWdiffs (2 per tuple)\n", $row[1], $verb, 2 * $row[1]; 339 409 $diffExpect += $row[1]*2; 340 410 } else { 341 print "I don't understand, there are more visits than I expect\n"; 411 # print "I don't understand, there are more visits than I expect\n"; 412 if ($row[1] == 1) { $verb = "tuple has"; } else { $verb = "tuples have"; } 413 if ($row[0] % 2) { $Ndiffs = int($row[0] / 2) + 1; } else { $Ndiffs = int($row[0] / 2); } 414 printf "%3d %-11s %d visits, expect %d WWdiffs (2 per quad)\n", $row[1], $verb, $row[0], $Ndiffs; 415 $diffExpect += $Ndiffs; 342 416 } 343 417 } … … 432 506 print "*** WARNING: Expect $diffExpect diffRuns, complete $diffDone diffRuns: inconsistent ***\n"; 433 507 } else { 434 print " * $diffDone of $diffExpect diffRuns completed *\n";508 if (not $report) { print " * $diffDone of $diffExpect diffRuns completed *\n"; } 435 509 } 436 510 } … … 452 526 453 527 @row = $result->fetchrow_array(); 454 printf " * %d diffRuns can be published * (has at least 1 skycell with quality = 0 or quality is NULL)\n", $row[0];528 if (not $report) { printf " * %d diffRuns can be published * (has at least 1 skycell with quality = 0 or quality is NULL)\n", $row[0]; } 455 529 if ($verbose) { print "\n"; } 456 530 $diffRunsToBePublished = $row[0]; … … 555 629 556 630 while (@row = $result->fetchrow_array()) { 557 if ( $verbose&& $doHeader) {631 if (($verbose or $report) && $doHeader) { 558 632 print "Bad quality camRun exposures:\n"; 559 633 printf "%11s %7s | %15s\n", "exp_name", "quality", "comment"; 560 634 $doHeader = 0; 561 635 } 562 if ($verbose ) { printf "%11s %7d | %15s\n", $row[0], $row[1], $row[2]; } else { $NbadCam ++; }563 } 564 if ( $verbose&& !$doHeader) { print "\n"; }565 if (! $verbose) { print "$NbadCam bad quality camera exposures\n\n"; }636 if ($verbose or $report) { printf "%11s %7d | %15s\n", $row[0], $row[1], $row[2]; } else { $NbadCam ++; } 637 } 638 if (($verbose or $report) && !$doHeader) { print "\n"; } 639 if (!($verbose or $report)) { print "$NbadCam bad quality camera exposures\n\n"; } 566 640 } 567 641 568 642 # check the status of diff runs NOT for Solar System: 569 if ($verbose ) {643 if ($verbose or $report) { 570 644 # my $result = &mysql_select (""); 571 645 my $query = "SELECT * FROM"; … … 595 669 if ($doHeader) { 596 670 print "Chunks which should not generate WWdiffs (not Solar System diffs)\n"; 597 printf "% 8s %8s %8s%8s\n", "Object", "Filter", "Chunk", "N(visit)";671 printf "%16s %-8s %20s | %8s\n", "Object", "Filter", "Chunk", "N(visit)"; 598 672 $doHeader = 0; 599 673 } 600 printf "% 8s %8s %8s%4d\n", $row[0], $row[1], $row[2], $row[3];674 printf "%16s %-8s %20s | %4d\n", $row[0], $row[1], $row[2], $row[3]; 601 675 } 602 676 if (!$doHeader) { print "\n"; }
Note:
See TracChangeset
for help on using the changeset viewer.
