IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41460 for trunk


Ignore:
Timestamp:
Dec 18, 2020, 5:46:57 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

    r41459 r41460  
    514514# check the status of exposures:
    515515if (1) {
    516     if ($report) { print "Exposure overview:\n"; }
     516    if ($report) { print "General exposure overview:\n"; }
     517    if ($report) { print "Distribution is split between clean=0/1 (fullbundles vs catalog)\n"; }
    517518
    518519    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(*)";
     
    525526    my $result = &mysql_select ($query);
    526527
    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    if ($report) { printf "%8s | %12s | %30s | %7s | %7s | %7s | %9s %9s | %9s %13s |\n", "exp_type", "obs_mode","comment", "N(raw)", "N(chip)", "N(cam)", "N(wrp)", "N(wrpdist)", "N(WSdiff)", "N(WSdiffdist)"; }
    528529    while (@row = $result->fetchrow_array()) {
    529530        #query chip stage
     
    544545        $query .= " FROM rawExp join chipRun using (exp_id)";
    545546        $query .= " JOIN camRun using (chip_id)";
     547        $query .= " JOIN camProcessedExp USING (cam_id)";
    546548        $query .= " WHERE dateobs LIKE '$date%'";
    547549        $query .= " AND exp_id > $refExpID"; #REF
     
    550552            $query .= " AND comment LIKE BINARY '$row[2]%'";
    551553        }   
     554        $query .= " AND (camProcessedExp.quality IS NULL OR camProcessedExp.quality = 0)";
    552555
    553556        my $result3 = &mysql_select ($query);
     
    555558
    556559        #query warp stage
    557         my $query = "SELECT exp_type, obs_mode, warpRun.state, count(*)";
     560        my $query = "SELECT exp_type, obs_mode, warpRun.state, count(DISTINCT warpRun.warp_id) AS Nwarp,count(if(distRun.state LIKE 'full' and distRun.stage LIKE 'warp' and distRun.clean = 0,1,NULL)) AS Ndist0,count(if(distRun.state LIKE 'full' and distRun.stage LIKE 'warp' and distRun.clean = 1,1,NULL)) AS Ndist1";
    558561        $query .= " FROM rawExp";
    559562        $query .= " JOIN chipRun using (exp_id)";
     
    562565        $query .= " JOIN fakeRun using (cam_id)";
    563566        $query .= " JOIN warpRun using (fake_id)";
     567        $query .= " LEFT JOIN distRun ON (warp_id = stage_id)";
    564568        $query .= " WHERE dateobs LIKE '$date%'";
    565569        $query .= " AND exp_id > $refExpID"; #REF
     
    568572            $query .= " AND comment LIKE '$row[2]%'";
    569573        }   
    570         $query .= " AND (camProcessedExp.quality IS NULL OR camProcessedExp.quality = 0)";
    571 
    572574        my $result4 = &mysql_select ($query);
    573575        @row4 = $result4->fetchrow_array();
    574576
    575         #query warp-stack diff stage and publish status
     577        #query warp-stack diff stage and distribution status
    576578        my $query = "SELECT diff_id,warp1,stack1,warp2,stack2";
    577579        $query .= " FROM diffInputSkyfile";
    578         $query .= " JOIN warpRun ON (warp1=warp_id OR warp2=warp_id)";
     580        $query .= " JOIN warpRun ON warp1=warp_id";
    579581        $query .= " JOIN fakeRun USING (fake_id)";
    580582        $query .= " JOIN camRun USING (cam_id)";
     
    582584        $query .= " JOIN chipRun USING (chip_id)";
    583585        $query .= " JOIN rawExp USING (exp_id)";
     586        #$query .= " LEFT JOIN distRun ON (diffRun.diff_id = stage_id)";
    584587        $query .= " WHERE rawExp.dateobs LIKE '$date%'";
    585588        $query .= " AND exp_id > $refExpID"; #REF
     589        $query .= " AND stack2 > 0";
    586590        $query .= " AND obs_mode LIKE BINARY '$row[1]'";
    587591        if ($row[2] ne "") {
     
    590594        $query .= " GROUP BY diff_id";
    591595        my $result5 = &mysql_select ($query);
     596        #@row5 = $result5->fetchrow_array();
    592597
    593598        my $NWSdiffgood = 0;
    594599        my $NWSdiffbad = 0;
    595         my $NWSdiffpub = 0;
    596         my %wrpcnt = ();
     600        my $NWSdiffdist0 = 0;
     601        my $NWSdiffdist1 = 0;
     602        my %dfcnt = ();
    597603
    598604        while (@row5 = $result5->fetchrow_array()) {
    599605              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";
     606                  #find the total number of skycell and the number of skycell with a bad quality flag as well as the full dist state
     607                  my $query2 = "SELECT count(DISTINCT diffSkyfile.skycell_id) AS Ndiff,count(if(diffSkyfile.quality > 0,1,NULL)) AS Ndiffbad,count(if(distRun.state LIKE 'full' and distRun.clean = 0,1,NULL)) AS Ndist0,count(if(distRun.state LIKE 'full' and distRun.clean = 1,1,NULL)) AS Ndist1 FROM ";
     608                  $query2 .= " diffRun JOIN diffSkyfile USING (diff_id) LEFT JOIN distRun ON (diffRun.diff_id = stage_id)";
     609                  $query2 .= " WHERE diff_id='$row5[0]' AND distRun.stage LIKE 'diff' GROUP BY diffRun.diff_id";
    604610                  my $result6 = &mysql_select ($query2);
    605611                  while (@row6 = $result6->fetchrow_array()) {
     
    607613                      if ($row6[1]<$row6[0]) {$NWSdiffgood ++;}
    608614                      if ($row6[1]==$row6[0]) {$NWSdiffbad ++;}
    609                       if ($row6[2]==$row6[0]) {$NWSdiffpub ++;}
     615                      if ($row6[2]==$row6[0]) {$NWSdiffdist0 ++;}
     616                      if ($row6[3]==$row6[0]) {$NWSdiffdist1 ++;}
    610617
    611618                      #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
     619                      $dfcnt{$row5[0]}++;  # record the presence of diff_id
    613620                  }
    614621              }
    615622        }
    616623        #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 ; }
     624        $Ndiffs = keys %dfcnt;
     625
     626        if ($report) { printf "%8s | %12s | %30s | %7d | %7d | %7d | %9d %4d%1s%4d | %9d %6d%1s%6d |\n", $row[0], $row[1], $row[2], $row[4], $row2[3], $row3[3], $row4[3],$row4[4],'/',$row4[5],$Ndiffs,$NWSdiffdist0,'/',$NWSdiffdist1 ; }
    620627    }
    621628    print "\n";
Note: See TracChangeset for help on using the changeset viewer.