IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42040 for trunk/ippMonitor


Ignore:
Timestamp:
Feb 15, 2022, 1:09:27 PM (4 years ago)
Author:
tdeboer
Message:

added data quality plots to ippMonitor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippMonitor/raw/czartool_labels.php

    r41731 r42040  
    376376}
    377377
     378# data quality timeseries
     379echo getDataQuality($projectdb);
    378380# storage timeseries
    379381echo getSpaces($czardb);
     
    17991801    echo "<center>loading in $total_time seconds<br></center>";
    18001802}
     1803
     1804
     1805###########################################################################
     1806#
     1807# Gets data quality status
     1808#
     1809###########################################################################
     1810function getDataQuality($db) {
     1811    // timer start
     1812    $time = microtime();
     1813    $time = explode(' ', $time);
     1814    $time = $time[1] + $time[0];
     1815    $start = $time;
     1816
     1817    #Query for the needed data
     1818    $DQarray = array();
     1819
     1820    $sql = "SELECT subtime(dateobs,'10:00:00') as time,iq_fwhm_major,iq_fwhm_minor,zpt_obs,zpt_stdev,rawExp.filter,rawExp.exp_time,rawExp.comment FROM rawExp JOIN chipRun using (exp_id) JOIN camRun using (chip_id) JOIN camProcessedExp using (cam_id)";
     1821#    $sql.= " WHERE (rawExp.dateobs > utc_date() - INTERVAL 14 hour) and (rawExp.dateobs < utc_date() + INTERVAL 10 hour)";
     1822    $sql.= " WHERE (rawExp.dateobs > utc_date())";
     1823    $sql.= " AND exp_type = 'OBJECT' AND camRun.state like 'full' ORDER BY dateobs asc;";
     1824    if ($debug) {echo "$sql<br>";}
     1825    $qry = $db->query($sql);
     1826    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
     1827    while ($qry->fetchInto($row)) {
     1828        $DQarray[] = $row;
     1829    }
     1830
     1831    #also find the median zeropoint
     1832    foreach($DQarray as $row) {
     1833        $zpt[]    = $row[3];
     1834    }
     1835
     1836    sort($zpt);
     1837    $count = sizeof($zpt);   // cache the count
     1838    $index = floor($count/2);  // cache the index
     1839    $zpt_med = $zpt[$index];
     1840
     1841    #echo "<script type=\"text/javascript\" src=\"https://www.gstatic.com/charts/loader.js\"></script>";
     1842    echo "<script type=\"text/javascript\" src=\"loader.js\"></script>";
     1843    echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 640; height:400\">";
     1844    echo "  <div id=\"dq_div\" style=\"width:640; \"></div>";
     1845    echo "  <div class=\"overlay\" style=\"position: absolute; width: 400px; bottom: 60px; left: 85px;\">";
     1846    echo "  </div>";
     1847    echo "</div>";
     1848
     1849    echo "<script type=\"text/javascript\">";
     1850    echo "google.charts.load('current', {packages: ['corechart']});";
     1851    echo "google.charts.setOnLoadCallback(drawChart);";
     1852    echo "function drawChart() {";
     1853    echo "  var data = new google.visualization.DataTable();";
     1854    echo "        data.addColumn('datetime', 'Time');";
     1855    echo "        data.addColumn('number', 'FWHM_maj');";
     1856    echo "        data.addColumn({'type': 'string', 'role': 'tooltip', 'p': {'html': true}});";
     1857    echo "        data.addColumn('number', 'FWHM_min');";
     1858    echo "        data.addColumn({'type': 'string', 'role': 'tooltip', 'p': {'html': true}});";
     1859    echo "        data.addColumn('number', 'seeing=1');";
     1860    echo "        data.addColumn('number', 'seeing=1.5');";
     1861    echo "   data.addRows([";
     1862
     1863    foreach($DQarray as $row) {
     1864        $tsp = explode(' ', $row[0]);
     1865        $dat = explode('-', $tsp[0]);
     1866        $tm = explode(':', $tsp[1]);
     1867        $timestamp = $row[0];
     1868        $fwhm_maj    = $row[1];
     1869        $fwhm_min = $row[2];
     1870
     1871        $tt_string1 = sprintf('time: %s\n FWHM_major: %s\n filter: %s\n exp_time: %s\n comment: %s', $timestamp, $fwhm_maj,$row[5],$row[6],$row[7]);
     1872        $tt_string2 = sprintf('time: %s\n FWHM_minor: %s\n filter: %s\n exp_time: %s\n comment: %s', $timestamp, $fwhm_min,$row[5],$row[6],$row[7]);
     1873#       new Date(Year, Month, Day, Hours, Minutes, Seconds, Milliseconds)
     1874       echo "[new Date($dat[0], $dat[1]-1, $dat[2], $tm[0], $tm[1]), $fwhm_maj,'$tt_string1',$fwhm_min,'$tt_string2',3.85,5.76],";
     1875    }
     1876   echo "  ]);";
     1877   echo "   var options = {";
     1878   echo "      chart: {"; 
     1879   echo "               position: 'center', " ;
     1880   echo "              },";
     1881   echo "     title: 'FWHM overview during the last night',";
     1882   echo "     titleTextStyle: {color: 'black', fontSize: 15},";
     1883   echo "     width: '100%',";
     1884   echo "     height: 400,";
     1885   echo "     legend: { position: 'top',";
     1886   echo "               alignment: 'center',";
     1887   echo "              },";
     1888   echo "     lineWidth: 2, ";
     1889   echo "     series: {";
     1890   echo "         0: { color: '#0000ff', lineWidth: 3 },      ";
     1891   echo "         1: { color: '#33a532', lineWidth: 3 },      ";
     1892   echo "         2: { color: 'red', lineWidth: 2 },      ";
     1893   echo "         3: { color: 'red', lineWidth: 2, lineDashStyle: [8, 4] },      ";
     1894   echo "              },";
     1895   echo "     hAxis: {  ";
     1896   echo "             title: 'Date/Time (HST)',";
     1897   echo "             format: 'HH:mm',";
     1898   echo "            gridlines: {count: -1},";
     1899   echo "     },";
     1900   echo "     vAxis: {  ";
     1901   echo "                  title: 'FWHM (pixels)',";
     1902   echo "     },";
     1903   echo "     chartArea: {left:80, top:50, right:20, bottom:50},";
     1904   echo "     fontSize: 12,";
     1905   echo "   };";
     1906   echo "   var chart = new google.visualization.LineChart(document.getElementById('dq_div'));";
     1907   echo "   chart.draw(data, options);";
     1908   echo " }";
     1909   echo "</script>";
     1910
     1911#   ---------------------------------------
     1912#   Also the zeropoint
     1913
     1914    #echo "<script type=\"text/javascript\" src=\"https://www.gstatic.com/charts/loader.js\"></script>";
     1915    echo "<script type=\"text/javascript\" src=\"loader.js\"></script>";
     1916    echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 640; height:400\">";
     1917    echo "  <div id=\"dqzp_div\" style=\"width:640; \"></div>";
     1918    echo "  <div class=\"overlay\" style=\"position: absolute; width: 400px; bottom: 60px; left: 85px;\">";
     1919    echo "  </div>";
     1920    echo "</div>";
     1921
     1922    echo "<script type=\"text/javascript\">";
     1923    echo "google.charts.load('current', {packages: ['corechart']});";
     1924    echo "google.charts.setOnLoadCallback(drawChart);";
     1925    echo "function drawChart() {";
     1926    echo "  var data = new google.visualization.DataTable();";
     1927    echo "        data.addColumn('datetime', 'Time');";
     1928    echo "        data.addColumn('number', 'zeropoint');";
     1929    echo "        data.addColumn({'type': 'string', 'role': 'tooltip', 'p': {'html': true}});";
     1930    echo "        data.addColumn({id:'i0', type:'number', role:'interval'});";
     1931    echo "        data.addColumn({id:'i0', type:'number', role:'interval'});";
     1932    echo "   data.addRows([";
     1933    foreach($DQarray as $row) {
     1934        $tsp = explode(' ', $row[0]);
     1935        $dat = explode('-', $tsp[0]);
     1936        $tm = explode(':', $tsp[1]);
     1937        $timestamp = $row[0];
     1938        $zp    = $row[3];
     1939        $zp_stdev = $row[4];
     1940        $zp_low = $zp-$zp_stdev;
     1941        $zp_high = $zp+$zp_stdev;
     1942
     1943        $tt_string1 = sprintf('time: %s\n zeropoint: %s\n filter: %s\n exp_time: %s\n comment: %s', $timestamp, $zp,$row[5],$row[6],$row[7]);
     1944#       new Date(Year, Month, Day, Hours, Minutes, Seconds, Milliseconds)
     1945       echo "[new Date($dat[0], $dat[1]-1, $dat[2], $tm[0], $tm[1]), $zp,'$tt_string1', $zp_low, $zp_high],";
     1946    }
     1947
     1948   echo "  ]);";
     1949   echo "   var options = {";
     1950   echo "      chart: {"; 
     1951   echo "               position: 'center', " ;
     1952   echo "              },";
     1953   echo "     title: 'Zeropoint overview during the last night',";
     1954   echo "     titleTextStyle: {color: 'black', fontSize: 15},";
     1955   echo "     width: '100%',";
     1956   echo "     height: 400,";
     1957   echo "     legend: { position: 'top',";
     1958   echo "               alignment: 'center',";
     1959   echo "              },";
     1960   echo "     lineWidth: 2, ";
     1961   echo "     series: {";
     1962   echo "         0: { color: '#0000ff', lineWidth: 3 },      ";
     1963   echo "              },";
     1964   echo "     intervals: { 'style':'line' },  ";
     1965   echo "     hAxis: {  ";
     1966   echo "             title: 'Date/Time (HST)',";
     1967   echo "             format: 'HH:mm',";
     1968   echo "            gridlines: {count: -1},";
     1969   echo "     },";
     1970   echo "     vAxis: {  ";
     1971   echo "                  title: 'Zeropoint (mag)',";
     1972   echo "     },";
     1973   echo "     chartArea: {left:80, top:50, right:20, bottom:50},";
     1974   echo "     fontSize: 12,";
     1975   echo "   };";
     1976   echo "   var chart = new google.visualization.LineChart(document.getElementById('dqzp_div'));";
     1977   echo "   chart.draw(data, options);";
     1978   echo " }";
     1979   echo "</script>";
     1980
     1981#   ---------------------------------------
     1982#   And a fixed zoom in on the zeropoint to see details
     1983
     1984    #echo "<script type=\"text/javascript\" src=\"https://www.gstatic.com/charts/loader.js\"></script>";
     1985    echo "<script type=\"text/javascript\" src=\"loader.js\"></script>";
     1986    echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 640; height:400\">";
     1987    echo "  <div id=\"dqzp_zoom_div\" style=\"width:640; \"></div>";
     1988    echo "  <div class=\"overlay\" style=\"position: absolute; width: 400px; bottom: 60px; left: 85px;\">";
     1989    echo "  </div>";
     1990    echo "</div>";
     1991
     1992    echo "<script type=\"text/javascript\">";
     1993    echo "google.charts.load('current', {packages: ['corechart']});";
     1994    echo "google.charts.setOnLoadCallback(drawChart);";
     1995    echo "function drawChart() {";
     1996    echo "  var data = new google.visualization.DataTable();";
     1997    echo "        data.addColumn('datetime', 'Time');";
     1998    echo "        data.addColumn('number', 'zeropoint');";
     1999    echo "        data.addColumn({'type': 'string', 'role': 'tooltip', 'p': {'html': true}});";
     2000    echo "        data.addColumn({id:'i0', type:'number', role:'interval'});";
     2001    echo "        data.addColumn({id:'i0', type:'number', role:'interval'});";
     2002    echo "   data.addRows([";
     2003    foreach($DQarray as $row) {
     2004        $tsp = explode(' ', $row[0]);
     2005        $dat = explode('-', $tsp[0]);
     2006        $tm = explode(':', $tsp[1]);
     2007        $timestamp = $row[0];
     2008        $zp    = $row[3];
     2009        $zp_stdev = $row[4];
     2010        $zp_low = $zp-$zp_stdev;
     2011        $zp_high = $zp+$zp_stdev;
     2012
     2013        $tt_string1 = sprintf('time: %s\n zeropoint: %s\n filter: %s\n exp_time: %s\n comment: %s', $timestamp, $zp,$row[5],$row[6],$row[7]);
     2014#       new Date(Year, Month, Day, Hours, Minutes, Seconds, Milliseconds)
     2015       echo "[new Date($dat[0], $dat[1]-1, $dat[2], $tm[0], $tm[1]), $zp,'$tt_string1', $zp_low, $zp_high],";
     2016    }
     2017
     2018   echo "  ]);";
     2019   echo "   var options = {";
     2020   echo "      chart: {"; 
     2021   echo "               position: 'center', " ;
     2022   echo "              },";
     2023   echo "     title: 'Zeropoint zoom-in during the last night',";
     2024   echo "     titleTextStyle: {color: 'black', fontSize: 15},";
     2025   echo "     width: '100%',";
     2026   echo "     height: 400,";
     2027   echo "     legend: { position: 'top',";
     2028   echo "               alignment: 'center',";
     2029   echo "              },";
     2030   echo "     lineWidth: 2, ";
     2031   echo "     series: {";
     2032   echo "         0: { color: '#0000ff', lineWidth: 3 },      ";
     2033   echo "              },";
     2034   echo "     intervals: { 'style':'line' },  ";
     2035   echo "     hAxis: {  ";
     2036   echo "             title: 'Date/Time (HST)',";
     2037   echo "             format: 'HH:mm',";
     2038   echo "            gridlines: {count: -1},";
     2039   echo "     },";
     2040   echo "     vAxis: {  ";
     2041   echo "                  title: 'Zeropoint (mag)',";
     2042   echo "     viewWindow: {   min: $zpt_med-0.2, max: $zpt_med+0.2    },  ";
     2043   echo "     },";
     2044   echo "     chartArea: {left:80, top:50, right:20, bottom:50},";
     2045   echo "     fontSize: 12,";
     2046   echo "   };";
     2047   echo "   var chart = new google.visualization.LineChart(document.getElementById('dqzp_zoom_div'));";
     2048   echo "   chart.draw(data, options);";
     2049   echo " }";
     2050   echo "</script>";
     2051
     2052
     2053
     2054    $time = microtime();
     2055    $time = explode(' ', $time);
     2056    $time = $time[1] + $time[0];
     2057    $finish = $time;
     2058    $total_time = round(($finish - $start), 3);
     2059    $start= $finish;
     2060    echo "<center>loading plot in $total_time seconds<br></center>";
     2061}
     2062
    18012063
    18022064###########################################################################
Note: See TracChangeset for help on using the changeset viewer.