IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 16, 2020, 12:24:36 PM (6 years ago)
Author:
tdeboer
Message:

new version of night_report that includes general exposure overview

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/night_report.pl

    r41371 r41459  
    466466    }
    467467    if ($summitSkipped || $summitPending) {
    468         print "*** WARNING: $summitSkipped skipped rawExp, $summitPending incomplete rawExp ***\n\n";
     468        if ($verbose) {print "*** WARNING: $summitSkipped skipped rawExp, $summitPending incomplete rawExp ***\n\n";}
    469469
    470470        my $query = "SELECT summitExp.exp_name,exp_type, fault, state";
     
    476476
    477477        my $result = &mysql_select ($query);
    478         printf "%12s %8s %15s %6s\n", "exp_name", "exp_type", "fault", "state";
     478        if ($verbose) {printf "%12s %8s %15s %6s\n", "exp_name", "exp_type", "fault", "state";}
    479479        while (@row = $result->fetchrow_array()) {
    480480            if ($row[3] eq "") { $row[3] = "NULL"; }
    481             printf "%12s %8s %15s %6s\n", $row[0], $row[1], $row[2], $row[3];
     481            if ($verbose) {printf "%12s %8s %15s %6s\n", $row[0], $row[1], $row[2], $row[3];}
    482482        }
    483483    }
     
    512512}
    513513
     514# check the status of exposures:
     515if (1) {
     516    if ($report) { print "Exposure overview:\n"; }
     517
     518    my $query = "SELECT exp_type, obs_mode,(CASE WHEN position(' ' in comment)>1 THEN substr(comment, 1, position(' ' in comment)-1) WHEN position('.' in comment)>1 THEN substr(comment, 1, position('.' in comment)-1) ELSE comment END) as cmt, state, count(*)";
     519    $query .= " FROM rawExp";
     520    $query .= " WHERE dateobs like '$date%'";
     521    $query .= " AND exp_id > $refExpID"; # REF
     522    $query .= " GROUP BY exp_type, obs_mode,cmt";
     523    $query .= " ORDER BY exp_type, obs_mode";
     524
     525    my $result = &mysql_select ($query);
     526
     527    if ($report) { printf "%8s | %12s | %30s | %7s | %7s | %7s | %9s %9s | %9s %12s |\n", "exp_type", "obs_mode","comment", "N(raw)", "N(chip)", "N(cam)", "N(wrp)", "N(wrppub)", "N(wsdiff)", "N(wsdiffpub)"; }
     528    while (@row = $result->fetchrow_array()) {
     529        #query chip stage
     530        my $query = "SELECT exp_type, obs_mode, chipRun.state, count(*)";
     531        $query .= " FROM rawExp";
     532        $query .= " JOIN chipRun using (exp_id)";
     533        $query .= " WHERE dateobs LIKE '$date%'";
     534        $query .= " AND exp_id > $refExpID"; #REF
     535        $query .= " AND obs_mode LIKE '$row[1]'";
     536        if ($row[2] ne "") {
     537            $query .= " AND comment LIKE BINARY '$row[2]%'";
     538        }   
     539        my $result2 = &mysql_select ($query);
     540        @row2 = $result2->fetchrow_array();
     541
     542        #query cam stage
     543        my $query = "SELECT exp_type, obs_mode, camRun.state, count(*)";
     544        $query .= " FROM rawExp join chipRun using (exp_id)";
     545        $query .= " JOIN camRun using (chip_id)";
     546        $query .= " WHERE dateobs LIKE '$date%'";
     547        $query .= " AND exp_id > $refExpID"; #REF
     548        $query .= " AND obs_mode LIKE '$row[1]'";
     549        if ($row[2] ne "") {
     550            $query .= " AND comment LIKE BINARY '$row[2]%'";
     551        }   
     552
     553        my $result3 = &mysql_select ($query);
     554        @row3 = $result3->fetchrow_array();
     555
     556        #query warp stage
     557        my $query = "SELECT exp_type, obs_mode, warpRun.state, count(*)";
     558        $query .= " FROM rawExp";
     559        $query .= " JOIN chipRun using (exp_id)";
     560        $query .= " JOIN camRun using (chip_id)";
     561        $query .= " JOIN camProcessedExp using (cam_id)";
     562        $query .= " JOIN fakeRun using (cam_id)";
     563        $query .= " JOIN warpRun using (fake_id)";
     564        $query .= " WHERE dateobs LIKE '$date%'";
     565        $query .= " AND exp_id > $refExpID"; #REF
     566        $query .= " AND obs_mode LIKE BINARY '$row[1]'";
     567        if ($row[2] ne "") {
     568            $query .= " AND comment LIKE '$row[2]%'";
     569        }   
     570        $query .= " AND (camProcessedExp.quality IS NULL OR camProcessedExp.quality = 0)";
     571
     572        my $result4 = &mysql_select ($query);
     573        @row4 = $result4->fetchrow_array();
     574
     575        #query warp-stack diff stage and publish status
     576        my $query = "SELECT diff_id,warp1,stack1,warp2,stack2";
     577        $query .= " FROM diffInputSkyfile";
     578        $query .= " JOIN warpRun ON (warp1=warp_id OR warp2=warp_id)";
     579        $query .= " JOIN fakeRun USING (fake_id)";
     580        $query .= " JOIN camRun USING (cam_id)";
     581        $query .= " JOIN camProcessedExp USING (cam_id)";
     582        $query .= " JOIN chipRun USING (chip_id)";
     583        $query .= " JOIN rawExp USING (exp_id)";
     584        $query .= " WHERE rawExp.dateobs LIKE '$date%'";
     585        $query .= " AND exp_id > $refExpID"; #REF
     586        $query .= " AND obs_mode LIKE BINARY '$row[1]'";
     587        if ($row[2] ne "") {
     588            $query .= " AND comment LIKE '$row[2]%'";
     589        }   
     590        $query .= " GROUP BY diff_id";
     591        my $result5 = &mysql_select ($query);
     592
     593        my $NWSdiffgood = 0;
     594        my $NWSdiffbad = 0;
     595        my $NWSdiffpub = 0;
     596        my %wrpcnt = ();
     597
     598        while (@row5 = $result5->fetchrow_array()) {
     599              if ($row5[4] > 0) {
     600                  #find the total number of skycell and the number of skycell with a bad quality flag as well as the full publish state
     601                  my $query2 = "     SELECT count(diffSkyfile.quality) AS Ndiff,count(if(diffSkyfile.quality > 0,1,NULL)) AS Ndiffbad,count(if(publishRun.state LIKE 'full',1,NULL)) AS Npub FROM ";
     602                  $query2 .= "           diffRun JOIN diffSkyfile USING (diff_id) LEFT JOIN publishRun ON (diffRun.diff_id = stage_id)";
     603                  $query2 .= "           WHERE diff_id='$row5[0]' GROUP BY diffRun.diff_id";
     604                  my $result6 = &mysql_select ($query2);
     605                  while (@row6 = $result6->fetchrow_array()) {
     606                      #if all skycells have bad quality, this is a bad diff. If all the skycells are in a full state in publishRun, it is fully published
     607                      if ($row6[1]<$row6[0]) {$NWSdiffgood ++;}
     608                      if ($row6[1]==$row6[0]) {$NWSdiffbad ++;}
     609                      if ($row6[2]==$row6[0]) {$NWSdiffpub ++;}
     610
     611                      #if this wsdiff is published, record its corresponding warp_ids to see how many unique ones there are
     612                      if ($row6[2]==$row6[0]) {$wrpcnt{$row5[1]}++;}  # record the presence of warp1
     613                  }
     614              }
     615        }
     616        #pull out the unique warp_ids
     617        $Npubwarps = keys %wrpcnt;
     618
     619        if ($report) { printf "%8s | %12s | %30s | %7d | %7d | %7d | %9d %9d | %9d %12d |\n", $row[0], $row[1], $row[2], $row[4], $row2[3], $row3[3], $row4[3],$Npubwarps,$NWSdiffgood,$NWSdiffpub ; }
     620    }
     621    print "\n";
     622}
     623
    514624# check the status of raw exposures:
    515625if (1) {
     
    540650    }
    541651    if ($expSkipped || $expPending) { print "*** WARNING: $expSkipped skipped rawExp, $expPending incomplete rawExp ***\n\n"; } else { if ($verbose) { print "\n"; }}
     652
    542653}
    543654   
Note: See TracChangeset for help on using the changeset viewer.