IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42736


Ignore:
Timestamp:
Nov 25, 2024, 3:50:12 PM (18 months ago)
Author:
cclin33
Message:

CCL: add plot pointing, airmass, and data quality. and some minor changes

Location:
trunk/ippMonitor
Files:
3 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippMonitor/Makefile.in

    r42384 r42736  
    8989$(DESTWWW)/skycoverage.php \
    9090$(DESTWWW)/ganglia.php \
     91$(DESTWWW)/scatterPlotPointing.php \
     92$(DESTWWW)/scatterPlotAirmassMcal.php \
     93$(DESTWWW)/scatterPlotDataQuality.php \
    9194$(DESTWWW)/loader.js
    9295
  • trunk/ippMonitor/def/addRunRun.d

    r41253 r42736  
    1313FIELD addRun.stage_id,     5, %d,     stageID
    1414FIELD addRun.stage_extra1, 5, %d,     stageExtra1
    15 #FIELD addRun.add_id,       5, %d,     addID
    1615FIELD addRun.state,        5, %s,     state
    1716FIELD addRun.workdir,      5, %s,     workdir
     
    2019FIELD addRun.data_group,   5, %s,     data_group
    2120FIELD addRun.dvodb,        5, %s,     dvodb
    22 FIELD addRun.note,         5, %s,     note
    2321FIELD addRun.image_only,   5, %d,   image_only
    2422FIELD addRun.minidvodb,    5, %d,     minidvodb
     
    2624FIELD addRun.minidvodb_name,  5, %s,     minidvodb_name
    2725FIELD addRun.minidvodb_host,  5, %s,     minidvodb_host
     26FIELD addRun.note,         5, %s,     note
  • trunk/ippMonitor/def/minidvodbRun.d

    r41253 r42736  
    11TABLE minidvodbRun
    2 #TABLE minidvodbRun LEFT JOIN (SELECT count(*) AS addnum, minidvodb_name FROM addRun GROUP BY minidvodb_name) AS sub ON sub.minidvodb_name = minidvodbRun.minidvodb_name
    32TITLE minidvodb Runs
    43FILE  minidvodbRun.php
  • trunk/ippMonitor/def/minidvodbRun_num.d

    r41254 r42736  
    1 #TABLE minidvodbRun
    21TABLE minidvodbRun LEFT JOIN (SELECT count(*) AS addnum, minidvodb_name FROM addRun GROUP BY minidvodb_name) AS sub ON sub.minidvodb_name = minidvodbRun.minidvodb_name
    32TITLE minidvodb Runs
     
    1716#FIELD minidvodbRun.mergedvodb_path,          25, %s,     mergedvodb_path
    1817FIELD state,          5, %s,    State
     18FIELD creation_date,        5, %T,     epoch
    1919FIELD addnum,                          5, %d,     addnum
    20 FIELD creation_date,        5, %T,     epoch
    2120
  • trunk/ippMonitor/raw/czartool_labels.php

    r42276 r42736  
    8989        "pstamp",
    9090        "registration",
    91         "stack",
     91//        "stack",
    9292        "stdscience",
    9393        "summitcopy");
     
    134134}
    135135
    136 
    137136$debug = 0;
    138137$table = "<table bgcolor=\"#FFFFFF\" width=\"100%\" align=\"middle\" border=\"1\" cellspacing=\"0\" cellpadding=\"4\" style=\"font-size:80%\">\n";
     
    183182echo "<table border=\"0\">";
    184183// timer begin for main page
    185 $time = microtime();
    186 $time = explode(' ', $time);
    187 $time = $time[1] + $time[0];
    188 $mainstart = $time;
     184$mainstart = microtime(true);
    189185
    190186# headers
     
    210206$hsttime1 = date("Y-m-d H:i:s", strtotime("$lastUpdateTime"));
    211207$utctime1 = gmdate("Y-m-d H:i:s", strtotime("$lastUpdateTime"));
     208$mjdday = getMJD();
    212209
    213210echo "<br>";
     
    249246          <td>".getNightlyScienceStatus($czardb, $proj)."</td></tr>";
    250247echo "<tr><td>Czardb last update time</td>
    251           <td> $hsttime1 (HST), $utctime1 (UTC)</td></tr>";
     248          <td> $hsttime1 (HST), $utctime1 (UTC), $mjdday (MJD)</td></tr>";
    252249echo "</table><br>";
    253250
     
    258255# XXX EAM : 2017.09.17 : debugging slowness
    259256# CCL : 2019.11.09 : debugging slowness
    260 //createSummitDataTable($projectdb); // this is slow because of the join between summitExp and rawExp, but not the major one
    261 createSummitDataTable2($projectdb, $pass, $proj); // this is slow because of the join between summitExp and rawExp, but not the major one
    262 
    263 createChunkDataTable($projectdb);  // this is another part for slowness during nightly processing
    264 
    265 createDatesTable($czardb, $proj);
     257createSummitDataTable2($projectdb, $pass, $proj, $debug); // this is slow because of the join between summitExp and rawExp, but not the major one
     258
     259createChunkDataTable($projectdb, $debug);  // this is another part for slowness during nightly processing
     260
     261// createDatesTable($czardb, $proj); what is this for?
    266262
    267263// Database status
    268 // timer begin for Database status
    269 $time = microtime();
    270 $time = explode(' ', $time);
    271 $time = $time[1] + $time[0];
    272 $start = $time;
    273 
    274264echo $table;
    275 echo "<tr>";
    276 createTableTitle("Database status (update fix log <a href=\"http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/Replication_Issues\"><font color=\"blue\">here</a>)", 2);
    277  
    278 echo "<tr>";
    279 createTableColumnHeader("Database");
    280 createTableColumnHeader("Status (sec behind master)");
    281 // gpc dbs
    282 showDatabaseStatus($HOST_GPC1, $USER_GPC1, $PASSWORD_GPC1, $LABEL_GPC1);
    283 showReplicationsStatus($REPL_HOST_GPC1, $REPL_USER_GPC1, $REPL_PASSWORD_GPC1, $REPL_LABEL_GPC1);
    284 showReplicationsStatus($REPL_HOST_GPC1_SECONDARY, $REPL_USER_GPC1_SECONDARY, $REPL_PASSWORD_GPC1_SECONDARY, $REPL_LABEL_GPC1_SECONDARY);
    285 showReplicationsStatus($REPL_HOST_GPC1_TERTIARY, $REPL_USER_GPC1_TERTIARY, $REPL_PASSWORD_GPC1_TERTIARY, $REPL_LABEL_GPC1_TERTIARY);
    286 // nebulous dbs
    287 showDatabaseStatus($HOST_NEBULOUS, $USER_NEBULOUS, $PASSWORD_NEBULOUS, $LABEL_NEBULOUS);
    288 //showReplicationsStatus($REPL_HOST_NEBULOUS, $REPL_USER_NEBULOUS, $REPL_PASSWORD_NEBULOUS, $REPL_LABEL_NEBULOUS);
    289 showReplicationsStatus($REPL_HOST_NEBULOUS_SECONDARY, $REPL_USER_NEBULOUS_SECONDARY, $REPL_PASSWORD_NEBULOUS_SECONDARY, $REPL_LABEL_NEBULOUS_SECONDARY);
    290 showReplicationsStatus($REPL_HOST_NEBULOUS_TERTIARY, $REPL_USER_NEBULOUS_TERTIARY, $REPL_PASSWORD_NEBULOUS_TERTIARY, $REPL_LABEL_NEBULOUS_TERTIARY);
    291 showReplicationsStatus($REPL_HOST_NEBULOUS_QUATERNARY, $REPL_USER_NEBULOUS_QUATERNARY, $REPL_PASSWORD_NEBULOUS_QUATERNARY, $REPL_LABEL_NEBULOUS_QUATERNARY);
    292 // other dbs
    293 showDatabaseStatus($HOST_PSTAMP, $USER_PSTAMP, $PASSWORD_PSTAMP, $LABEL_PSTAMP);
    294 showReplicationsStatus($REPL_HOST_DATASTORE, $REPL_USER_DATASTORE, $REPL_PASSWORD_DATASTORE, $REPL_LABEL_DATASTORE);
    295 
    296 // timer finished
    297 echo "<tr><th colspan=2>";
    298 $time = microtime();
    299 $time = explode(' ', $time);
    300 $time = $time[1] + $time[0];
    301 $finish = $time;
    302 $total_time = round(($finish - $start), 3);
    303 echo "loading in $total_time seconds.";
    304 echo "</th></tr>";
     265    // timer begin
     266    $start = microtime(true);
     267    echo "<tr>";
     268    createTableTitle("Database status (update fix log <a href=\"http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/Replication_Issues\"><font color=\"blue\">here</a>)", 2);
     269     
     270    echo "<tr>";
     271    createTableColumnHeader("Database");
     272    createTableColumnHeader("Status (sec behind master)");
     273    // gpc dbs
     274    showDatabaseStatus($HOST_GPC1, $USER_GPC1, $PASSWORD_GPC1, $LABEL_GPC1);
     275    showReplicationsStatus($REPL_HOST_GPC1, $REPL_USER_GPC1, $REPL_PASSWORD_GPC1, $REPL_LABEL_GPC1);
     276    showReplicationsStatus($REPL_HOST_GPC1_SECONDARY, $REPL_USER_GPC1_SECONDARY, $REPL_PASSWORD_GPC1_SECONDARY, $REPL_LABEL_GPC1_SECONDARY);
     277    showReplicationsStatus($REPL_HOST_GPC1_TERTIARY, $REPL_USER_GPC1_TERTIARY, $REPL_PASSWORD_GPC1_TERTIARY, $REPL_LABEL_GPC1_TERTIARY);
     278    // nebulous dbs
     279    showDatabaseStatus($HOST_NEBULOUS, $USER_NEBULOUS, $PASSWORD_NEBULOUS, $LABEL_NEBULOUS);
     280    //showReplicationsStatus($REPL_HOST_NEBULOUS, $REPL_USER_NEBULOUS, $REPL_PASSWORD_NEBULOUS, $REPL_LABEL_NEBULOUS);
     281    showReplicationsStatus($REPL_HOST_NEBULOUS_SECONDARY, $REPL_USER_NEBULOUS_SECONDARY, $REPL_PASSWORD_NEBULOUS_SECONDARY, $REPL_LABEL_NEBULOUS_SECONDARY);
     282    showReplicationsStatus($REPL_HOST_NEBULOUS_TERTIARY, $REPL_USER_NEBULOUS_TERTIARY, $REPL_PASSWORD_NEBULOUS_TERTIARY, $REPL_LABEL_NEBULOUS_TERTIARY);
     283    showReplicationsStatus($REPL_HOST_NEBULOUS_QUATERNARY, $REPL_USER_NEBULOUS_QUATERNARY, $REPL_PASSWORD_NEBULOUS_QUATERNARY, $REPL_LABEL_NEBULOUS_QUATERNARY);
     284    // other dbs
     285    showDatabaseStatus($HOST_PSTAMP, $USER_PSTAMP, $PASSWORD_PSTAMP, $LABEL_PSTAMP);
     286    showReplicationsStatus($REPL_HOST_DATASTORE, $REPL_USER_DATASTORE, $REPL_PASSWORD_DATASTORE, $REPL_LABEL_DATASTORE);
     287   
     288    // end time
     289    echo "<tr><th colspan=2>";
     290    $total_time = round((microtime(true) - $start), 3);
     291    echo "loading in $total_time seconds.";
     292    echo "</th></tr>";
    305293echo "</table><br>";
    306294
    307295
    308296// critical machines status
    309 // timer begin for critical machines
    310 $time = microtime();
    311 $time = explode(' ', $time);
    312 $time = $time[1] + $time[0];
    313 $start = $time;
    314 
    315 $PingStatus = "<font style=\"BACKGROUND-COLOR: yellow\"  color=\"red\">DOWN</font>";
    316297echo $table;
    317 echo "<tr>";
    318 createTableTitle("Critical machine status", 3);
    319 
    320 echo "<tr>";
    321 createTableColumnHeader("Hostname");
    322 createTableColumnHeader("Status");
    323 createTableColumnHeader("Loading time");
    324 showPingStatus($HOST_GATEWAY, $LABEL_GATEWAY);
    325 showPingStatus($HOST_GATEWAY_SECONDARY, $LABEL_GATEWAY_SECONDARY);
    326 showPingStatus($HOST_PROXY, $LABEL_PROXY);
    327 showPingStatus($HOST_APACHE1, $LABEL_APACHE1);
    328 showPingStatus($HOST_APACHE2, $LABEL_APACHE2);
    329 showPingStatus($HOST_APACHE3, $LABEL_APACHE3);
    330 showPingStatus($HOST_APACHE4, $LABEL_APACHE4);
    331 showPingStatus($HOST_APACHE5, $LABEL_APACHE5);
    332 showPingStatus($HOST_APACHE6, $LABEL_APACHE6);
    333 showPingStatus($HOST_APACHE_BACKUP1, $LABEL_APACHE_BACKUP1);
    334 showPingStatus($HOST_APACHE_BACKUP2, $LABEL_APACHE_BACKUP2);
    335 showPingStatus($HOST_HOME, $LABEL_HOME);
    336 showPingStatus($HOST_HOME_BACKUP, $LABEL_HOME_BACKUP);
    337 showPingStatus($HOST_NAGIOS, $LABEL_NAGIOS);
    338 showPingStatus($HOST_SVN, $LABEL_SVN);
    339 showPingStatus($HOST_CONFLUENCE, $LABEL_CONFLUENCE);
    340 showPingStatus($HOST_MAILMAN, $LABEL_MAILMAN);
    341 //  echo "<td>ippc70 (apache node) <td> $PingStatus <td> 0 seconds ";  // comment out if ippc70 is back
    342 // timer finished
    343 echo "<tr><th colspan=3>";
    344 $time = microtime();
    345 $time = explode(' ', $time);
    346 $time = $time[1] + $time[0];
    347 $finish = $time;
    348 $total_time = round(($finish - $start), 3);
    349 echo "loading in $total_time seconds.";
    350 echo "</th></tr>";
     298    // start time
     299    $start = microtime(true);
     300   
     301    $PingStatus = "<font style=\"BACKGROUND-COLOR: yellow\"  color=\"red\">DOWN</font>";
     302
     303    echo "<tr>";
     304    createTableTitle("Critical machine status", 3);
     305   
     306    echo "<tr>";
     307    createTableColumnHeader("Hostname");
     308    createTableColumnHeader("Status");
     309    createTableColumnHeader("Loading time");
     310    showPingStatus($HOST_GATEWAY, $LABEL_GATEWAY);
     311    showPingStatus($HOST_GATEWAY_SECONDARY, $LABEL_GATEWAY_SECONDARY);
     312    showPingStatus($HOST_PROXY, $LABEL_PROXY);
     313    showPingStatus($HOST_APACHE1, $LABEL_APACHE1);
     314    showPingStatus($HOST_APACHE2, $LABEL_APACHE2);
     315    showPingStatus($HOST_APACHE3, $LABEL_APACHE3);
     316    showPingStatus($HOST_APACHE4, $LABEL_APACHE4);
     317    showPingStatus($HOST_APACHE5, $LABEL_APACHE5);
     318    showPingStatus($HOST_APACHE6, $LABEL_APACHE6);
     319    showPingStatus($HOST_APACHE_BACKUP1, $LABEL_APACHE_BACKUP1);
     320    showPingStatus($HOST_APACHE_BACKUP2, $LABEL_APACHE_BACKUP2);
     321    showPingStatus($HOST_HOME, $LABEL_HOME);
     322    showPingStatus($HOST_HOME_BACKUP, $LABEL_HOME_BACKUP);
     323    showPingStatus($HOST_NAGIOS, $LABEL_NAGIOS);
     324    showPingStatus($HOST_SVN, $LABEL_SVN);
     325    showPingStatus($HOST_CONFLUENCE, $LABEL_CONFLUENCE);
     326    showPingStatus($HOST_MAILMAN, $LABEL_MAILMAN);
     327
     328    // end time
     329    echo "<tr><th colspan=3>";
     330    $total_time = round((microtime(true) - $start), 3);
     331    echo "loading in $total_time seconds.";
     332    echo "</th></tr>";
    351333echo "</table><br>";
    352334
    353 createServersTable($pass, $proj,$selectedMode,$czardb, $servers, $selectedLabel, $selectedStage, $plotType); // this was the major slowness part due to large table in czardb
    354 
    355 # pantasks server status, if requested
    356 if ($selectedServer && !$serverCmd) showServerStatus($selectedServer, $proj);
    357 
    358 #2nd table column for space
     335createServersTable($pass, $proj,$selectedMode,$czardb, $servers, $selectedLabel, $selectedStage, $plotType);
     336    # pantasks server status, if requested
     337    if ($selectedServer && !$serverCmd) showServerStatus($selectedServer, $proj);
     338
     339#2nd table column empty contnets
    359340echo "<td style=height:200px;width: 10px;text-align:top;\"><br>";
    360341
     
    362343echo "<td style=height:200px;width:600px;text-align:top;\"><br>";
    363344# plots
    364 if ($selectedStage == "all_stages" & $selectedLabel == "all") {
    365    # with all stages and all labels, the rate query is too slow so I use the old method until it get improved. CCL 20210117
    366    # gnuplots
    367    # time series plot
    368    echo "<img src=\"czartool_getplot.php?mode=$selectedMode&type=t&label=$selectedLabel&proj=$proj&stage=$selectedStage&plottype=linear\"><br><br>";
    369    echo "<img src=\"czartool_getplot.php?mode=$selectedMode&type=t&label=$selectedLabel&proj=$proj&stage=$selectedStage&plottype=log\"><br><br>";
    370    # rate series plot
    371    echo "<img src=\"czartool_getplot.php?mode=$selectedMode&type=rt&label=$selectedLabel&proj=$proj&stage=$selectedStage&plottype=linear\"><br><br>";
    372    #for dev version
    373    # google chart
    374    # time series plot
    375    #echo Gettimeseries($czardb, $selectedMode, $selectedLabel, $proj, $selectedStage);
    376    # rate series plot
    377    #echo Getrate($czardb, $selectedMode, $selectedLabel, $proj, $selectedStage);
     345if ($selectedStage == "all_stages" && $selectedLabel == "all") {
     346    // Use old method with gnuplots as the rate query is slow with all stages and labels
     347    displayImage("t", $selectedMode, $selectedLabel, $proj, $selectedStage, "linear");
     348    displayImage("t", $selectedMode, $selectedLabel, $proj, $selectedStage, "log");
     349    displayImage("rt", $selectedMode, $selectedLabel, $proj, $selectedStage, "linear");
     350
     351    // Uncomment for dev version with Google Charts
     352    // echo Gettimeseries($czardb, $selectedMode, $selectedLabel, $proj, $selectedStage);
     353    //echo Getrate($czardb, $selectedMode, $selectedLabel, $proj, $selectedStage);
    378354} else {
    379    # google chart
    380    # time series plot
    381    echo Gettimeseries($czardb, $selectedMode, $selectedLabel, $proj, $selectedStage);
    382    # rate series plot
    383    echo Getrate($czardb, $selectedMode, $selectedLabel, $proj, $selectedStage);
     355    // Use Google Charts for specific stage and label
     356    echo Gettimeseries($czardb, $selectedMode, $selectedLabel, $proj, $selectedStage);
     357    echo Getrate($czardb, $selectedMode, $selectedLabel, $proj, $selectedStage);
     358}
     359
     360// Helper function to generate image tags for plots
     361function displayImage($type, $mode, $label, $proj, $stage, $plottype) {
     362    $src = "czartool_getplot.php?mode=" . urlencode($mode) .
     363           "&type=" . urlencode($type) .
     364           "&label=" . urlencode($label) .
     365           "&proj=" . urlencode($proj) .
     366           "&stage=" . urlencode($stage) .
     367           "&plottype=" . urlencode($plottype);
     368    echo "<img src=\"$src\"><br><br>";
    384369}
    385370
    386371# data quality timeseries
    387 echo getDataQuality($projectdb);
     372echo getDataQuality2($projectdb); // new version of data quality plots
     373
    388374# storage timeseries
    389375echo getSpaces($czardb);
    390376# storage plot
    391 echo getHosts($czardb);
     377 echo getHosts($czardb);
    392378
    393379# timer for main page end
    394380echo "<tr><th colspan=3>";
    395 $time = microtime();
    396 $time = explode(' ', $time);
    397 $time = $time[1] + $time[0];
    398 $finish = $time;
    399 $total_time = round(($finish - $mainstart), 3);
    400 echo "overall loading in $total_time seconds.";
     381echo "overall loading in " . round((microtime(true) - $mainstart), 3) . " seconds.";
    401382echo "</th></tr>";
    402383echo "</table>";
     
    457438#
    458439###########################################################################
    459 function createChunkDataTable($projectdb) {
     440function createChunkDataTable($projectdb, $debug) {
    460441
    461442    // timer start
    462     $time = microtime();
    463     $time = explode(' ', $time);
    464     $time = $time[1] + $time[0];
    465     $start = $time;
     443    $start = microtime(true);
    466444
    467445    // function begin
    468446    #First find the reference exposure ID to speed up the subsequent queries
     447    $mjdDay  = getMJD();
     448    $expname = "o{$mjdDay}%";
     449
    469450    $date = gmdate("Y-m-d");
    470     $sql = "SELECT MAX(exp_id) FROM rawExp WHERE dateobs >= date_sub('$date', interval 20 day) AND dateobs <= date_sub('$date', interval 10 day)";
     451    $sql = "SELECT MIN(exp_id) FROM rawExp WHERE exp_name like '$expname' ";
     452    if ($debug) {echo "$sql<br>";}
    471453    $qry = $projectdb->query($sql);
     454
    472455    if (dberror($qry)) {
    473         print "*** WARNING: no data in period 10-20 days before requested date (query will be slower) **\n";
    474         $refExpID = 0;
    475     }
    476     $qry->fetchInto($refExpID);
    477     if ($refExpID[0] = 'NULL') {
    478         $refExpID[0] = 0;
    479     }
     456        echo "*** WARNING: No data for tonight **\n";
     457        $refExpID = 0;
     458    } else {
     459        $qry->fetchInto($refExpID);
     460        $refExpID = isset($refExpID[0]) ? $refExpID[0] : 0;
     461    }
     462    // Print the result of the query
     463    if ($debug) {echo "The first exp_id of tonight is: $refExpID<br>";}
    480464
    481465    #do a query of raw/chip/cam/warp counts for this night, split by chunk.
     
    485469    $query .= "    count(if(rawExp.comment LIKE '%visit 2%',1,NULL)) AS Nvis2,count(if(rawExp.comment LIKE '%visit 3%',1,NULL)) AS Nvis3,";
    486470    $query .= "    count(if(rawExp.comment LIKE '%visit 4%',1,NULL)) AS Nvis4, count(if(camProcessedExp.sigma_ra <= 5 AND camProcessedExp.sigma_dec <= 5 AND camProcessedExp.quality = 0,1,NULL)) AS Ncamgood,";
    487     $query .= "    count(if(camProcessedExp.sigma_ra > 5 OR camProcessedExp.sigma_dec > 5 OR camProcessedExp.quality > 0,1,NULL)) AS Ncambad";
     471    $query .= "    count(if(camProcessedExp.fwhm_major > 12 OR camProcessedExp.sigma_ra > 5 OR camProcessedExp.sigma_dec > 5 OR camProcessedExp.quality > 0,1,NULL)) AS Ncambad";
    488472    $query .= "    FROM rawExp LEFT JOIN chipRun USING (exp_id) LEFT JOIN camRun USING (chip_id) JOIN camProcessedExp USING (cam_id) LEFT JOIN fakeRun USING (cam_id) LEFT JOIN warpRun USING (fake_id)";
    489     $query .= "    WHERE dateobs like '$date%' AND exp_id > $refExpID[0] AND exp_type = 'OBJECT' AND rawExp.comment like '%visit%'";
     473    $query .= "    WHERE exp_name like '$expname' AND exp_type = 'OBJECT' AND rawExp.comment like '%visit%'";
    490474    $query .= "    AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%') AND obs_mode NOT LIKE 'ENGINEERING' AND obs_mode NOT LIKE 'MANUAL'";
    491475    $query .= "    GROUP BY chunk ORDER BY dateobs) as suba ";
     
    495479    $query .= "      (SELECT substr(comment, 1, position(' ' in comment)) AS chunk,count(warpSkyfile.quality) AS Nwarpskycell,count(if(warpSkyfile.quality > 0,1,NULL)) AS Nwarpskycellbad";
    496480    $query .= "      FROM 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) JOIN warpSkyfile USING (warp_id)";
    497     $query .= "      WHERE dateobs like '$date%' AND exp_id > $refExpID[0] AND exp_type = 'OBJECT' AND rawExp.comment like '%visit%'";
     481    $query .= "      WHERE exp_name like '$expname' AND exp_type = 'OBJECT' AND rawExp.comment like '%visit%'";
    498482    $query .= "      AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%') AND obs_mode NOT LIKE 'ENGINEERING' AND obs_mode NOT LIKE 'MANUAL'";
    499483    $query .= "      GROUP BY exp_name) as subc";
    500484    $query .= "    GROUP BY chunk) AS subb ";
    501485    $query .= "ON suba.chunk=subb.chunk";
    502 
     486 
     487    if ($debug) {echo "$query<br>";}
    503488    $qry = $projectdb->query($query);
     489
    504490    if (dberror($qry)) {
    505491        echo "<b>error querying SQL table</b><br>\n";
     
    512498    echo $table;
    513499    echo "<tr>";
    514     createTableTitle("Status of last night's chunks", 10);
     500    $mjdday = getMJD();
     501    createTableTitle("Status of night $mjdday chunks", 10);
    515502    echo "<tr>";
    516503    createTableColumnHeader("Chunk");
     
    556543        $query1 = "SELECT suba.chunk, SUM(IF(suba.Nvisits = 2,1,NULL)) as totvis2, SUM(IF(suba.Nvisits = 3 OR suba.Nvisits = 4,2,NULL)) as totvis34 FROM";
    557544        $query1 .= "    (SELECT substr(comment, 1, position(' ' in comment)) AS chunk,count(distinct(comment)) AS Nvisits FROM";
    558         $query1 .= "    rawExp LEFT JOIN chipRun USING (exp_id) LEFT JOIN camRun USING (chip_id) WHERE dateobs like '$date%'";
    559         $query1 .= "    AND exp_id > $refExpID[0] AND exp_type = 'OBJECT' AND rawExp.comment like '%visit%' AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%') AND obs_mode NOT LIKE 'ENGINEERING' AND obs_mode NOT LIKE 'MANUAL'";
     545        $query1 .= "    rawExp LEFT JOIN chipRun USING (exp_id) LEFT JOIN camRun USING (chip_id) ";
     546        $query1 .= "    WHERE exp_name like '$expname'";
     547        $query1 .= "    AND exp_type = 'OBJECT' AND rawExp.comment like '%visit%' AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%') AND obs_mode NOT LIKE 'ENGINEERING' AND obs_mode NOT LIKE 'MANUAL'";
    560548        $query1 .= "    AND substr(comment, 1, position(' ' in comment)) LIKE '$chunkname%' group by object) as suba group by chunk;";
     549
    561550        $qry1 = $projectdb->query($query1);
    562551        while ($qry1->fetchInto($row)) {$NexpWWdiff = $row[1] + $row[2];}
     
    565554        $query2 = "     SELECT diff_id,warp1,stack1,warp2,stack2 FROM ";
    566555        $query2 .= "           diffInputSkyfile JOIN warpRun ON (warp1=warp_id OR warp2=warp_id) JOIN fakeRun USING (fake_id) JOIN camRun USING (cam_id) JOIN camProcessedExp USING (cam_id) JOIN chipRun USING (chip_id) JOIN rawExp USING (exp_id)";
    567         $query2 .= "           WHERE rawExp.dateobs LIKE '$date%' AND exp_id > $refExpID[0] AND exp_type = 'OBJECT' AND rawExp.comment like '%visit%' AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%')";
     556        $query2 .= "           WHERE exp_name like '$expname'";
     557        $query2 .= "           AND exp_type = 'OBJECT' AND rawExp.comment like '%visit%' AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%')";
    568558        $query2 .= "            AND obs_mode NOT LIKE 'ENGINEERING' AND obs_mode NOT LIKE 'MANUAL' AND substr(comment, 1, position(' ' in comment)) LIKE '$chunkname%' GROUP By diff_id";
    569559        $qry2 = $projectdb->query($query2);
     
    670660        $query .= " JOIN camRun USING (chip_id)";
    671661        $query .= " JOIN camProcessedExp USING (cam_id)";
    672         $query .= " WHERE dateobs LIKE '$date%'";
    673         $query .= " AND exp_id > $refExpID[0]";
     662        //$query .= " WHERE dateobs LIKE '$date%' AND exp_id > $refExpID";
     663        $query .= " WHERE exp_name like '$expname'";
    674664        $query .= " AND exp_type = 'OBJECT'";
    675665        $query .= " AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%') AND obs_mode NOT LIKE 'ENGINEERING' AND obs_mode NOT LIKE 'MANUAL'";
    676         $query .= " AND (camProcessedExp.quality > 0 OR camProcessedExp.sigma_ra > 5 OR camProcessedExp.sigma_dec > 5)";
     666        $query .= " AND (camProcessedExp.fwhm_major > 12 OR camProcessedExp.quality > 0 OR camProcessedExp.sigma_ra > 5 OR camProcessedExp.sigma_dec > 5)";
    677667        $query .= " ORDER BY comment";
    678668
     
    710700        $query = "SELECT exp_name,warp_id,count(warpSkyfile.quality) AS Nwarpskycell,count(if(warpSkyfile.quality > 0,1,NULL)) AS Nwarpskycellbad, comment";
    711701        $query .= "      FROM 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) JOIN warpSkyfile USING (warp_id)";
    712         $query .= "      WHERE dateobs like '$date%' AND exp_id > $refExpID[0]";
     702        $query .= "      WHERE exp_name like '$expname'";
    713703        $query .= "      AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%') AND obs_mode NOT LIKE 'ENGINEERING' AND obs_mode NOT LIKE 'MANUAL'";
    714704        $query .= "      GROUP BY exp_name ORDER BY comment";
     
    747737        $query = "     SELECT diff_id,warp1,stack1,warp2,stack2,exp_name,comment FROM ";
    748738        $query .= "           diffInputSkyfile JOIN warpRun ON (warp1=warp_id OR warp2=warp_id) JOIN fakeRun USING (fake_id) JOIN camRun USING (cam_id) JOIN camProcessedExp USING (cam_id) JOIN chipRun USING (chip_id) JOIN rawExp USING (exp_id)";
    749         $query .= "           WHERE rawExp.dateobs LIKE '$date%' AND exp_id > $refExpID[0] AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%') AND obs_mode NOT LIKE 'ENGINEERING' AND obs_mode NOT LIKE 'MANUAL'";
     739        $query .= "           WHERE exp_name like '$expname'";
     740        $query .= "           AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%') AND obs_mode NOT LIKE 'ENGINEERING' AND obs_mode NOT LIKE 'MANUAL'";
    750741        $query .= "           GROUP By diff_id";
     742        if ($debug) {echo "$query<br>";}
     743
    751744        $qry1 = $projectdb->query($query);
    752 
    753745        while ($qry1->fetchInto($row)) {
    754746            #distinguish between WW and WS diffs based on stack2
     
    811803    $query .= " JOIN chipRun USING (exp_id)";
    812804    $query .= " JOIN camRun USING (chip_id)";
    813     $query .= " WHERE dateobs LIKE '$date%'";
    814     $query .= " AND exp_id > $refExpID[0]";
     805    $query .= " WHERE exp_name like '$expname'";
    815806    $query .= " AND exp_type = 'OBJECT'";
    816807    $query .= " AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%') AND obs_mode NOT LIKE 'ENGINEERING' AND obs_mode NOT LIKE 'MANUAL'";
     
    826817            $query .= " JOIN chipRun USING (exp_id)";
    827818            $query .= " JOIN camRun USING (chip_id)";
    828             $query .= " WHERE dateobs LIKE '$date%' AND comment LIKE '$row[1]'";
    829             $query .= " AND exp_id > $refExpID[0]";
     819            $query .= " WHERE exp_name like '$expname'";
     820            $query .= " AND comment LIKE '$row[1]'";
    830821            $query .= " AND exp_type = 'OBJECT'";
    831822            $query .= " AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%') AND obs_mode NOT LIKE 'ENGINEERING' AND obs_mode NOT LIKE 'MANUAL'";
     
    863854
    864855
    865     // timer finished
     856    // End timer
    866857    echo "<tr><th colspan=10>";
    867     $time = microtime();
    868     $time = explode(' ', $time);
    869     $time = $time[1] + $time[0];
    870     $finish = $time;
    871     $total_time = round(($finish - $start), 3);
    872     echo "loading in $total_time seconds.";
    873     $start= $finish;
     858    $total_time = round(microtime(true) - $start, 3);
     859    echo "<center>loading in $total_time seconds<br></center>";
     860
    874861    echo "</th></tr>";
    875862    echo "</table></br>";
     
    914901        $selectedState, $selectedLabel, $selectedStage, $plotType) {
    915902
    916     // timer start
    917     $time = microtime();
    918     $time = explode(' ', $time);
    919     $time = $time[1] + $time[0];
    920     $start = $time;
     903    // Start timer
     904    $start = microtime(true);
     905
    921906
    922907    // function begin
     
    1010995            }
    1011996          }
    1012       // echo "getStateAndFaults $db, $thisLabel, $proj, $selectedState, $stage, $str, $anyFaults<br>";
    1013997      getStateAndFaults($db, $thisLabel, $proj, $selectedState, $stage, $str, $anyFaults);
     998      //echo "getStateAndFaults $db, $thisLabel, $proj, $selectedState, $stage, $str, $anyFaults<br>";
    1014999
    10151000      $cellcolor = 0;
     
    10451030    echo "</tr>\n";
    10461031
    1047     // timer finished
     1032    // End timer
    10481033    echo "<tr><th colspan=11>";
    1049     $time = microtime();
    1050     $time = explode(' ', $time);
    1051     $time = $time[1] + $time[0];
    1052     $finish = $time;
    1053     $total_time = round(($finish - $start), 3);
    1054     echo "loading in $total_time seconds.";
    1055     $start= $finish;
     1034    $total_time = round(microtime(true) - $start, 3);
     1035    echo "<center>loading plot in $total_time seconds<br></center>";
     1036
    10561037    echo "</th></tr>";
    10571038    echo "</table><br>";
     
    12041185
    12051186    // timer start
    1206     $time = microtime();
    1207     $time = explode(' ', $time);
    1208     $time = $time[1] + $time[0];
    1209     $start = $time;
     1187    $start = microtime(true);
    12101188
    12111189    // function begin
     
    12231201
    12241202    // timer finished
    1225 #    echo "<tr><th colspan=11>";
    1226     $time = microtime();
    1227     $time = explode(' ', $time);
    1228     $time = $time[1] + $time[0];
    1229     $finish = $time;
    1230     $total_time = round(($finish - $start), 3);
    1231 #    echo "loading in $total_time seconds.";
    1232     $start= $finish;
    1233 #    echo "</th></tr>";
     1203    echo "<tr><th colspan=11>";
     1204    $total_time = round((microtime(true) - $start), 3);
     1205    echo "loading in $total_time seconds.";
     1206    echo "</th></tr>";
    12341207    echo "</table><br>";
    12351208
     
    12721245###########################################################################
    12731246function createServersTable($pass, $proj, $selectedMode, $db, $servers, $selectedLabel, $selectedStage, $plotType) {
    1274 
    1275     // timer start
    1276     $time = microtime();
    1277     $time = explode(' ', $time);
    1278     $time = $time[1] + $time[0];
    1279     $start = $time;
    1280 
    1281     // function begin
    1282     // set up table columns
     1247    // Start the timer
     1248    $start = microtime(true);
     1249
     1250    // Display table header
    12831251    global $table;
    12841252    echo $table;
     
    12861254    createTableTitle("Pantasks server status", 3);
    12871255    echo "<tr>";
    1288     createTableColumnHeader("Server");
    1289     createTableColumnHeader("Alive?");
    1290     createTableColumnHeader("Running?");
     1256
     1257    // Define column headers in an array for flexibility
     1258    $columnHeaders = array("Server", "Alive?", "Running?");
     1259    foreach ($columnHeaders as $header) {
     1260        createTableColumnHeader($header);
     1261    }
    12911262    echo "</tr>\n";
    12921263
    12931264    foreach ($servers as &$server) {
    1294 
    12951265        getServerStatus($db,$proj, $server, $alive, $running);
    12961266
    12971267        echo "<tr>\n";
     1268
     1269        // Generate the link once and pass it to the cell function
    12981270        $link = "czartool_labels.php?pass=".$pass
    12991271            ."&proj=".$proj
     
    13041276            ."&plottype=".$plotType;
    13051277
     1278        // Display server row cells
    13061279        createFormattedTableCell(1, $link, $server, 0, 0);
    13071280        createFormattedTableCell(0, "", $alive ? "yes" : "NO", !$alive, 0);
    13081281        createFormattedTableCell(0, "", $running ? "yes" : "NO", !$running, 0);
     1282
    13091283        echo "</tr>\n";
    13101284    }
    13111285
    1312     // timer finished
     1286    // Display loading time
    13131287    echo "<tr><th colspan=5>";
    1314     $time = microtime();
    1315     $time = explode(' ', $time);
    1316     $time = $time[1] + $time[0];
    1317     $finish = $time;
    1318     $total_time = round(($finish - $start), 3);
    1319     echo "loading in $total_time seconds.";
    1320     $start= $finish;
     1288    echo "loading in " . round((microtime(true) - $start), 3) . " seconds.";
    13211289    echo "</th></tr>";
    13221290    echo "</table><br>\n";
     
    15151483#
    15161484###########################################################################
    1517 function createSummitDataTable2($projectdb, $pass, $proj) {
     1485function createSummitDataTable2($projectdb, $pass, $proj, $debug) {
    15181486
    15191487    // timer start
    1520     $time = microtime();
    1521     $time = explode(' ', $time);
    1522     $time = $time[1] + $time[0];
    1523     $start = $time;
    1524 
    1525     // function begin
    1526     $date = gmdate("Y-m-d");
    1527     $datem1 = gmdate("Y-m-d",strtotime ( "-1 day") );
    1528     $datetime = gmdate("H:i:s");
     1488    $start = microtime(true);
     1489
     1490    // Define constants
     1491    $mjdDay = getMJD();
     1492    $expname = "%{$mjdDay}%";
     1493
     1494    $mjdDaym1 = $mjdDay - 1;
     1495    $expnamem1 = "%{$mjdDaym1}%";
     1496
     1497    $mjdDaym5 = $mjdDay - 5;
     1498    $expnamem5 = "o{$mjdDaym5}%";
     1499
     1500    $currentDate = gmdate("Y-m-d H:i:s");
     1501    $previousDate = gmdate("Y-m-d", strtotime("-1 day"));
    15291502
    15301503    // set up the table
     
    15331506    echo $table;
    15341507    echo "<tr>";
    1535     createTableTitle("Data status tonight $date <br> current time $datetime (UTC)", 4);
     1508      createTableTitle("Data status for night $mjdDay  <br> current time UT: $currentDate", 4);
    15361509    echo "<tr>";
    1537 
    1538     createTableColumnHeader("Exposure type");
    1539     createTableColumnHeader("<a href=\"czartool_labels.php?pass=".$pass."&proj=".$proj."&label=all&stage=summitExp\"><font color=\"blue\">summitExp status</font></a>");
    1540     createTableColumnHeader("<a href=\"czartool_labels.php?pass=".$pass."&proj=".$proj."&label=all&stage=downloadExp\"><font color=\"blue\">downloadExp status</font></a>");
    1541     createTableColumnHeader("<a href=\"czartool_labels.php?pass=".$pass."&proj=".$proj."&label=all&stage=rawExp\"><font color=\"blue\">rawExp </a>/
    1542                              <a href=\"czartool_labels.php?pass=".$pass."&proj=".$proj."&label=all&stage=newExp\"><font color=\"blue\"> newExp</font></a>");
    1543     $sql = "SELECT summitExp.exp_type,pzDownloadExp.state,rawExp.state,COUNT(*) FROM summitExp
    1544             LEFT JOIN pzDownloadExp USING (summit_id) LEFT JOIN rawExp on summitExp.exp_name = rawExp.exp_name
    1545             WHERE summitExp.dateobs like '$date%' group by summitExp.exp_type,pzDownloadExp.state,rawExp.state";
     1510      createTableColumnHeader("Exposure type");
     1511      createTableColumnHeader("<a href=\"czartool_labels.php?pass=".$pass."&proj=".$proj."&label=all&stage=summitExp\"><font color=\"blue\">summitExp status</font></a>");
     1512      createTableColumnHeader("<a href=\"czartool_labels.php?pass=".$pass."&proj=".$proj."&label=all&stage=downloadExp\"><font color=\"blue\">downloadExp status</font></a>");
     1513      createTableColumnHeader("<a href=\"czartool_labels.php?pass=".$pass."&proj=".$proj."&label=all&stage=rawExp\"><font color=\"blue\">rawExp </a>/
     1514                               <a href=\"czartool_labels.php?pass=".$pass."&proj=".$proj."&label=all&stage=newExp\"><font color=\"blue\"> newExp</font></a>");
     1515
     1516    $sql = "
     1517        SELECT sum_type, pzstate, rawstate, count(*), sum_exp, pz_exp, raw_exp
     1518        FROM
     1519          (SELECT summitExp.exp_type as sum_type, pzDownloadExp.state as pzstate, rawExp.state as rawstate, summitExp.exp_name as sum_exp, pzDownloadExp.exp_name as pz_exp, rawExp.exp_name as raw_exp
     1520           FROM summitExp
     1521           LEFT JOIN pzDownloadExp USING (summit_id)
     1522           LEFT JOIN rawExp ON summitExp.exp_name = rawExp.exp_name
     1523           WHERE summitExp.summit_id >= (
     1524               SELECT COALESCE(MIN(summit_id), 0)
     1525               FROM summitExp
     1526               WHERE exp_name LIKE '$expnamem5'
     1527            )
     1528            AND summitExp.exp_name LIKE '$expname' ORDER BY summitExp.dateobs desc) as sub
     1529        GROUP BY sum_type, pzstate, rawstate";
     1530    if ($debug) {echo "$sql<br>";}
     1531
    15461532    $qry = $projectdb->query($sql);
    15471533    while ($qry->fetchInto($tmp)) {
    1548         if ($tmp[1] == NULL) {
    1549           echo  "<tr><td>$tmp[0]<td> null <td> null <td bgcolor=\"yellow\"> <font color=\"red\">$tmp[3]";
     1534        list($expType, $downloadState, $rawState, $count, $summit_exp, $pz_exp, $raw_exp) = $tmp;
     1535        if ($downloadState == NULL) {
     1536          echo  "<tr><td> $expType ($summit_exp) <td> loading imfiles <td> null <td bgcolor=\"yellow\"> <font color=\"red\">$count";
    15501537        } else {
    1551           if ($tmp[1] == 'run') {
    1552             echo  "<tr><td>$tmp[0]<td> loading <td> null <td bgcolor=$columnHeaderColor> <font color=\"red\">$tmp[3]";
     1538          if ($downloadState == 'run') {
     1539            echo  "<tr><td> $expType ($summit_exp) <td> summit_copy ($pz_exp) <td> saving ($pz_exp) <td bgcolor=$columnHeaderColor> <font color=\"red\">$count";
    15531540          } else {
    1554             if ($tmp[2] == NULL) {
    1555               echo  "<tr><td>$tmp[0] <td> $tmp[1] <td> loading <td bgcolor=$columnHeaderColor> <font color=\"blue\">$tmp[3]";
     1541            if ($rawState == NULL) {
     1542              echo  "<tr><td> $expType ($summit_exp) <td> $downloadState ($pz_exp) <td> registering ($pz_exp) <td bgcolor=$columnHeaderColor> <font color=\"blue\">$count";
    15561543            } else {
    1557               echo  "<tr><td>$tmp[0]<td> $tmp[1] <td> downloaded <td> $tmp[3]";
     1544              echo  "<tr><td> $expType ($summit_exp) <td> $downloadState ($pz_exp) <td> $rawState ($raw_exp) <td> $count";
    15581545            }
    15591546          }
     
    15611548    }
    15621549
    1563     echo "<tr><th colspan=4>Last night $datem1 (UTC)";
    1564     $sql = "SELECT summitExp.exp_type,pzDownloadExp.state,rawExp.state,COUNT(*) FROM summitExp
    1565             LEFT JOIN pzDownloadExp USING (summit_id) LEFT JOIN rawExp on summitExp.exp_name = rawExp.exp_name
    1566             WHERE summitExp.dateobs like '$datem1%' group by summitExp.exp_type,pzDownloadExp.state,rawExp.state";
     1550    echo "<tr><th colspan=4>Last night $previousDate (UTC), $mjdDaym1 (MJD)";
     1551    $sql = "
     1552        SELECT sum_type, pzstate, rawstate, count(*), sum_exp, pz_exp, raw_exp
     1553        FROM
     1554          (SELECT summitExp.exp_type as sum_type, pzDownloadExp.state as pzstate, rawExp.state as rawstate, summitExp.exp_name as sum_exp, pzDownloadExp.exp_name as pz_exp, rawExp.exp_name as raw_exp
     1555           FROM summitExp
     1556           LEFT JOIN pzDownloadExp USING (summit_id)
     1557           LEFT JOIN rawExp ON summitExp.exp_name = rawExp.exp_name
     1558           WHERE summitExp.summit_id >= (
     1559               SELECT COALESCE(MIN(summit_id), 0)
     1560               FROM summitExp
     1561               WHERE exp_name LIKE '$expnamem5'
     1562            )
     1563            AND summitExp.exp_name LIKE '$expnamem1' ORDER BY summitExp.dateobs desc) as sub
     1564        GROUP BY sum_type, pzstate, rawstate";
     1565    // $sql = "
     1566    //     SELECT summitExp.exp_type, pzDownloadExp.state, rawExp.state, COUNT(*)
     1567    //     FROM summitExp
     1568    //     LEFT JOIN pzDownloadExp USING (summit_id)
     1569    //     LEFT JOIN rawExp ON summitExp.exp_name = rawExp.exp_name
     1570    //     WHERE summitExp.summit_id >= (
     1571    //         SELECT COALESCE(MIN(summit_id), 0)
     1572    //         FROM summitExp
     1573    //         WHERE exp_name LIKE '$expnamem5'
     1574    //     )
     1575    //     AND summitExp.exp_name LIKE '$expnamem1'
     1576    //     GROUP BY summitExp.exp_type, pzDownloadExp.state, rawExp.state";
     1577    if ($debug) {echo "$sql<br>";}
     1578
    15671579    $qry = $projectdb->query($sql);
    15681580    while ($qry->fetchInto($tmp)) {
    1569         if ($tmp[1] == NULL) {
    1570           echo  "<tr><td>$tmp[0]<td> null <td> null <td bgcolor=\"yellow\"> <font color=\"red\">$tmp[3]";
     1581        list($expType, $downloadState, $rawState, $count, $summit_exp, $pz_exp, $raw_exp) = $tmp;
     1582        if ($downloadState == NULL) {
     1583          echo  "<tr><td> $expType ($summit_exp) <td> loading imfiles <td> null <td bgcolor=\"yellow\"> <font color=\"red\">$count";
    15711584        } else {
    1572           if ($tmp[1] == 'run') {
    1573             echo  "<tr><td>$tmp[0]<td> loading <td> null <td bgcolor=$columnHeaderColor> <font color=\"red\">$tmp[3]";
     1585          if ($downloadState == 'run') {
     1586            echo  "<tr><td> $expType ($summit_exp) <td> summit_copy ($pz_exp) <td> saving ($pz_exp) <td bgcolor=$columnHeaderColor> <font color=\"red\">$count";
    15741587          } else {
    1575             if ($tmp[2] == NULL) {
    1576               echo  "<tr><td>$tmp[0] <td> $tmp[1] <td> loading <td bgcolor=$columnHeaderColor> <font color=\"blue\">$tmp[3]";
     1588            if ($rawState == NULL) {
     1589              echo  "<tr><td> $expType ($summit_exp) <td> $downloadState ($pz_exp) <td> registering <td bgcolor=$columnHeaderColor> <font color=\"blue\">$count";
    15771590            } else {
    1578               echo  "<tr><td>$tmp[0]<td> $tmp[1] <td> downloaded <td> $tmp[3]";
     1591              echo  "<tr><td> $expType ($summit_exp) <td> $downloadState ($pz_exp) <td> $rawState ($raw_exp) <td> $count";
    15791592            }
    15801593          }
    15811594        }
    15821595    }
    1583     // timer finished
     1596    //while ($qry->fetchInto($tmp)) {
     1597    //    list($expType, $downloadState, $rawState, $count) = $tmp;
     1598    //    if ($downloadState == NULL) {
     1599    //      echo  "<tr><td> $expType <td> null <td> null <td bgcolor=\"yellow\"> <font color=\"red\">$count";
     1600    //    } else {
     1601    //      if ($downloadState == 'run') {
     1602    //        echo  "<tr><td> $expType <td> loading <td> null <td bgcolor=$columnHeaderColor> <font color=\"red\">$count";
     1603    //      } else {
     1604    //        if ($rawState == NULL) {
     1605    //          echo  "<tr><td> $expType <td> $downloadState <td> loading <td bgcolor=$columnHeaderColor> <font color=\"blue\">$count";
     1606    //        } else {
     1607    //          echo  "<tr><td> $expType <td> $downloadState <td> download ($rawState) <td> $count";
     1608    //        }
     1609    //      }
     1610    //    }
     1611    //}
     1612
    15841613    echo "<tr><th colspan=4>";
    1585     $time = microtime();
    1586     $time = explode(' ', $time);
    1587     $time = $time[1] + $time[0];
    1588     $finish = $time;
    1589     $total_time = round(($finish - $start), 3);
    1590     echo "loading in $total_time seconds.";
    1591     $start= $finish;
     1614    // End timer
     1615    $total_time = round(microtime(true) - $start, 3);
     1616    echo "<center>loading in $total_time seconds<br></center>";
     1617
    15921618    echo "</th></tr>";
    15931619    echo "</table><br>";
     1620}
     1621
     1622function formatState($state) {
     1623    // Formats display of the state for better readability
     1624    if (is_null($state)) {
     1625        return "<span style='color: red;'>null</span>";
     1626    } elseif ($state == 'run') {
     1627        return "<span style='color: red;'>loading</span>";
     1628    } else {
     1629        return $state;
     1630    }
    15941631}
    15951632###########################################################################
     
    16081645    echo "<script type=\"text/javascript\" src=\"loader.js\"></script>";
    16091646    echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 640px\">";
    1610     echo "  <div id=\"disk_div\" style=\"width:640px; height:1200px\"></div>";
     1647    echo "  <div id=\"disk_div\" style=\"width:640px; height:4000px\"></div>";
    16111648    echo "  <div class=\"overlay\" style=\"position: absolute; width: 100px; top: 35px; right: 20px;\">";
    16121649    echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: #00ff00\"><center>Free</div>";
     
    16861723   echo "     },";
    16871724   echo "     bar: { groupWidth: '95%' },";
    1688    echo "     chartArea: {left:70, top:30, right:20, bottom:40},";
    1689    echo "     fontSize: 12,";
    1690    echo "     isStacked: true";
     1725   echo "     chartArea: {left:100, top:30, right:20, bottom:40},";
     1726   echo "     fontSize: 15,";
     1727   echo "     isStacked: true,";
     1728   echo "     colors: ['#76A7FA', '#FF5733', '#C70039', '#900C3F', '#581845']";
    16911729   echo "   };";
    16921730   echo "   var chart = new google.visualization.BarChart(document.getElementById('disk_div'));";
     
    18211859
    18221860    $date = gmdate("Y-m-d");
    1823     $sql = "SELECT MAX(exp_id) FROM rawExp WHERE dateobs >= date_sub('$date', interval 20 day) AND dateobs <= date_sub('$date', interval 10 day)";
     1861    $sql = "SELECT MAX(exp_id) FROM rawExp WHERE dateobs BETWEEN DATE_SUB('$date', INTERVAL 20 DAY) AND DATE_SUB('$date', INTERVAL 10 DAY)";
     1862    if ($debug) {echo "$sql<br>";}
    18241863    $qry = $db->query($sql);
     1864
    18251865    if (dberror($qry)) {
    1826         print "*** WARNING: no data in period 10-20 days before requested date (query will be slower) **\n";
     1866        echo "*** WARNING: No data in the period 10-20 days before requested date (query will be slower) **\n";
    18271867        $refExpID = 0;
    1828     }
    1829     $qry->fetchInto($refExpID);
    1830     if ($refExpID[0] = 'NULL') {
    1831         $refExpID[0] = 0;
    1832     }
     1868    } else {
     1869        $qry->fetchInto($refExpID);
     1870        $refExpID = isset($refExpID[0]) ? $refExpID[0] : 0;
     1871    }
     1872    // Print the result of the query
     1873    if ($debug) {echo "The result of MAX(exp_id) is: $refExpID<br>";}
     1874    {echo "The result of MAX(exp_id) is: $refExpID<br>";}
    18331875
    18341876    #Query for the needed data
     
    18381880#    $sql.= " WHERE (rawExp.dateobs > utc_date() - INTERVAL 14 hour) and (rawExp.dateobs < utc_date() + INTERVAL 10 hour)";
    18391881    $sql.= " WHERE (rawExp.dateobs > utc_date())";
     1882#    $sql.= " WHERE (rawExp.dateobs > '2024-10-24')";
     1883#    $sql.= " AND (rawExp.dateobs < '2024-10-25')";
    18401884    $sql.= " AND exp_id > $refExpID[0]";
    18411885    $sql.= " AND exp_type = 'OBJECT' AND camRun.state like 'full' ORDER BY dateobs asc;";
     
    18431887    $qry = $db->query($sql);
    18441888    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
     1889#    echo "<b>error with $sql </b><br>\n";
    18451890    while ($qry->fetchInto($row)) {
    18461891        $DQarray[] = $row;
     
    20442089
    20452090        #define new zeropoints
    2046         if(substr($row[5],0,1) == 'g') {$col_string = 'blue'; $zpt_off = $zp - 25.013;}
    2047         if(substr($row[5],0,1) == 'r') {$col_string = 'red'; $zpt_off = $zp - 24.840;}
    2048         if(substr($row[5],0,1) == 'i') {$col_string = '#6a3d9a'; $zpt_off = $zp - 24.711;}
    2049         if(substr($row[5],0,1) == 'z') {$col_string = 'green'; $zpt_off = $zp - 24.30;}
    2050         if(substr($row[5],0,1) == 'y') {$col_string = 'cyan'; $zpt_off = $zp - 23.57;}
    2051         if(substr($row[5],0,1) == 'w') {$col_string = 'grey'; $zpt_off = $zp - 26.000;}
     2091        if(substr($row[5],0,1) == 'g') {$col_string = '#00f000'; $zpt_off = $zp - 25.013;}
     2092        if(substr($row[5],0,1) == 'r') {$col_string = '#f00000'; $zpt_off = $zp - 24.840;}
     2093        if(substr($row[5],0,1) == 'i') {$col_string = '#f05000'; $zpt_off = $zp - 24.711;}
     2094        if(substr($row[5],0,1) == 'z') {$col_string = '#0050a0'; $zpt_off = $zp - 24.300;}
     2095        if(substr($row[5],0,1) == 'y') {$col_string = '#ffe000'; $zpt_off = $zp - 23.570;}
     2096        if(substr($row[5],0,1) == 'w') {$col_string = '#808080'; $zpt_off = $zp - 26.060;}
    20522097
    20532098        $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]);
     
    21012146}
    21022147
     2148
     2149
     2150
    21032151###########################################################################
    21042152#
     
    21082156function Gettimeseries($db, $selectedMode, $selectedLabel, $proj, $selectedStage) {
    21092157    // timer start
    2110     $time = microtime();
    2111     $time = explode(' ', $time);
    2112     $time = $time[1] + $time[0];
    2113     $start = $time;
     2158    $start = microtime(true);
    21142159
    21152160    // google chart javascript source code
     
    25122557 
    25132558    // timer end
    2514     $time = microtime();
    2515     $time = explode(' ', $time);
    2516     $time = $time[1] + $time[0];
    2517     $finish = $time;
    2518     $total_time = round(($finish - $start), 3);
    2519     $start= $finish;
    2520     echo "<center>loading in $total_time seconds</center>";
     2559    echo "<center> loading in " . round((microtime(true) - $start), 3) . " seconds. </center>";
    25212560}
    25222561
     
    29943033}
    29953034
     3035
     3036###########################################################################
     3037#
     3038# Get data quality
     3039#
     3040###########################################################################
     3041function getDataQuality2($db) {
     3042    // Start timer
     3043    $start = microtime(true);
     3044
     3045    $mjdDay  = getMJD();
     3046    $expname = "o".$mjdDay."%";
     3047
     3048    $sql = "SELECT SUBTIME(dateobs, '10:00:00') AS time,
     3049                   round(( 367*YEAR(dateobs)- FLOOR((7 * (YEAR(dateobs) + FLOOR((MONTH(dateobs) + 9) / 12))) / 4) + FLOOR(275 * MONTH(dateobs) / 9)
     3050                   + DAY(dateobs) + 1721013.5 + (HOUR(dateobs) / 24.0) + (MINUTE(dateobs) / 1440.0) + (SECOND(dateobs) / 86400.0) - 2400000.5), 5) AS MJD,
     3051                   filter, comment, ra*180/pi() as RA, decl*180/pi() as DECL, exp_name, alt, az, fwhm_major, fwhm_minor, zpt_obs, zpt_stdev, rawExp.exp_id
     3052            FROM rawExp JOIN chipRun using (exp_id) JOIN camRun using (chip_id) JOIN camProcessedExp using (cam_id)
     3053            WHERE rawExp.exp_name like '$expname'
     3054               AND exp_type = 'OBJECT'
     3055               AND camRun.state like 'full'
     3056               AND camProcessedExp.fault = 0
     3057               AND camProcessedExp.zpt_obs != 0; ";
     3058
     3059    $DQarray = array();
     3060    $qry = $db->query($sql);
     3061    if (dberror($qry)) {
     3062        echo "<b>Error with $sql</b><br>\n";
     3063        return;
     3064    }
     3065   
     3066    while ($qry->fetchInto($row)) {
     3067        $DQarray[] = $row;
     3068    }
     3069   
     3070    // Ensure $DQarray is not empty
     3071    if (empty($DQarray)) {
     3072        echo "<center><b> No data for MJD: $mjdDay </b></center>";
     3073        return; // Stop execution if no data to encode
     3074    }
     3075   
     3076    // Convert data array to JSON for easier handling in JavaScript
     3077    $dataJson = json_encode($DQarray);
     3078   
     3079    if ($dataJson === false) {
     3080        echo "<b>Error encoding JSON:</b> " . json_last_error_msg(); // Display any JSON encoding errors
     3081        return; // Stop execution if JSON encoding fails
     3082    }
     3083   
     3084    echo "<script>console.log(" . json_encode($dataJson) . ");</script>"; // Log JSON output to console for debugging
     3085
     3086echo <<<HTML
     3087<script type="text/javascript" src="loader.js"></script>
     3088
     3089<script type="text/javascript">
     3090    google.charts.load('current', {packages: ['corechart']});
     3091
     3092    // Use the encoded JSON directly in JavaScript
     3093    const dataArray = JSON.parse('{$dataJson}'); // Directly parse the PHP JSON string
     3094
     3095    // draw FWHM vs MJD
     3096    function drawFWHMChart() {
     3097        var data = new google.visualization.DataTable();
     3098            data.addColumn('number', 'MJD');
     3099            data.addColumn('number', 'FWHM_major');
     3100            data.addColumn({'type': 'string', 'role': 'tooltip', 'p': {'html': true}});
     3101            data.addColumn('number', 'FWHM_minor');
     3102            data.addColumn({'type': 'string', 'role': 'tooltip', 'p': {'html': true}});
     3103            data.addColumn('number', 'seeing ~ 1"');
     3104            data.addColumn('number', 'seeing ~ 3"');
     3105
     3106        const rows = dataArray.map(row => {
     3107            const [timestamp, mjd, filter, comment, ra, dec, exp_name, alt, az, iq_fwhm_maj, iq_fwhm_min, zpt_obs, zpt_stdev, exp_id] = row;
     3108
     3109            return [
     3110                parseFloat(mjd),      // Position Angle
     3111                parseFloat(iq_fwhm_maj),         // RA_offset (AST_R0)
     3112                "expname: "+exp_name+"<br>exp_id: "+exp_id+"<br>HST: "+timestamp+"<br>RA: "+ra+"<br>DEC: "+dec+"<br>filter: "+filter+"<br>comment: "+comment,
     3113                parseFloat(iq_fwhm_min),        // Dec_offset (AST_D0)
     3114                "expname: "+exp_name+"<br>exp_id: "+exp_id+"<br>HST: "+timestamp+"<br>RA: "+ra+"<br>DEC: "+dec+"<br>filter: "+filter+"<br>comment: "+comment,
     3115                4,
     3116                12
     3117            ];
     3118        });
     3119
     3120        data.addRows(rows);
     3121
     3122        const options = {
     3123            title: 'FWHM (MJD)',
     3124            titleTextStyle: {color: 'black', fontSize: 15},
     3125            width: '100%',
     3126            height: 480,
     3127            legend: { position: 'top', alignment: 'center' },
     3128            series: {
     3129                0: { color: '#0000ff', pointSize: 3, lineWidth: 1 },
     3130                1: { color: '#33a532', pointSize: 3, lineWidth: 1 },
     3131                2: { color: 'red', lineWidth: 2, pointSize: 0 },
     3132                3: { color: 'red', lineWidth: 2, lineDashStyle: [8, 4], pointSize: 0 }
     3133            },
     3134            intervals: { color: 'red', lineWidth: 2, style: 'sticks' },
     3135            hAxis: {
     3136                title: 'MJD',
     3137                gridlines: {count: -1}
     3138            },
     3139            vAxis: {
     3140                title: 'FWHM (pixels)',
     3141            },
     3142            tooltip: { isHtml: true }, // Render tooltips as HTML
     3143            chartArea: {left: '8%', top: 60, right: '5%', bottom: 50}, // Adjust left and right
     3144            fontSize: 12,
     3145        };
     3146
     3147        const chart = new google.visualization.LineChart(document.getElementById('dq_div_fwhm'));
     3148        chart.draw(data, options);
     3149    }
     3150
     3151    // draw zoomed zerpoint vs mjd
     3152    function drawZOOMZPTChart() {
     3153        var data = new google.visualization.DataTable();
     3154        data.addColumn('number', 'MJD');
     3155
     3156        // Add columns for each filter type to handle separate colors
     3157        data.addColumn('number', 'g (24.563, 25.013)');
     3158        data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});
     3159        data.addColumn({type: 'number', role: 'interval'});
     3160        data.addColumn({type: 'number', role: 'interval'});
     3161        data.addColumn('number', 'r (24.750, 24.840)');
     3162        data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});
     3163        data.addColumn({type: 'number', role: 'interval'});
     3164        data.addColumn({type: 'number', role: 'interval'});
     3165        data.addColumn('number', 'i (24.611, 24.711)');
     3166        data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});
     3167        data.addColumn({type: 'number', role: 'interval'});
     3168        data.addColumn({type: 'number', role: 'interval'});
     3169        data.addColumn('number', 'z (24.240, 24.300)');
     3170        data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});
     3171        data.addColumn({type: 'number', role: 'interval'});
     3172        data.addColumn({type: 'number', role: 'interval'});
     3173        data.addColumn('number', 'y (23.320, 23.570)');
     3174        data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});
     3175        data.addColumn({type: 'number', role: 'interval'});
     3176        data.addColumn({type: 'number', role: 'interval'});
     3177        data.addColumn('number', 'w (26.000, 26.300)');
     3178        data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});
     3179        data.addColumn({type: 'number', role: 'interval'});
     3180        data.addColumn({type: 'number', role: 'interval'});
     3181
     3182        const rows = dataArray.map(row => {
     3183            const [timestamp, mjd, filter, comment, ra, dec, exp_name, alt, az, iq_fwhm_maj, iq_fwhm_min, zpt_obs, zpt_stdev, exp_id] = row;
     3184
     3185            // Initialize all filter values as null
     3186            let zp_g = null, zp_r = null, zp_i = null, zp_z = null, zp_y = null, zp_w = null;
     3187
     3188            // Set the zeropoint offset based on filter and assign it to the correct series
     3189            switch (filter[0]) {
     3190                case 'g':
     3191                    zp_g = zpt_obs - 24.563;
     3192                    break;
     3193                case 'r':
     3194                    zp_r = zpt_obs - 24.750;
     3195                    break;
     3196                case 'i':
     3197                    zp_i = zpt_obs - 24.611;
     3198                    break;
     3199                case 'z':
     3200                    zp_z = zpt_obs - 24.240;
     3201                    break;
     3202                case 'y':
     3203                   zp_y = zpt_obs - 23.320;
     3204                    break;
     3205                case 'w':
     3206                    zp_w = zpt_obs - 26.000;
     3207                    break;
     3208            }
     3209
     3210            return [
     3211                parseFloat(mjd), // MJD value
     3212                zp_g, "expname: "+exp_name+"<br>exp_id: "+exp_id+"<br>HST: "+timestamp+"<br>RA: "+ra+"<br>DEC: "+dec+"<br>filter: "+filter+"<br>comment: "+comment,  parseFloat(zp_g - zpt_stdev), parseFloat(zp_g - zpt_stdev*-1),
     3213                zp_r, "expname: "+exp_name+"<br>exp_id: "+exp_id+"<br>HST: "+timestamp+"<br>RA: "+ra+"<br>DEC: "+dec+"<br>filter: "+filter+"<br>comment: "+comment,  parseFloat(zp_r - zpt_stdev), parseFloat(zp_r - zpt_stdev*-1),
     3214                zp_i, "expname: "+exp_name+"<br>exp_id: "+exp_id+"<br>HST: "+timestamp+"<br>RA: "+ra+"<br>DEC: "+dec+"<br>filter: "+filter+"<br>comment: "+comment,  parseFloat(zp_i - zpt_stdev), parseFloat(zp_i - zpt_stdev*-1),
     3215                zp_z, "expname: "+exp_name+"<br>exp_id: "+exp_id+"<br>HST: "+timestamp+"<br>RA: "+ra+"<br>DEC: "+dec+"<br>filter: "+filter+"<br>comment: "+comment,  parseFloat(zp_z - zpt_stdev), parseFloat(zp_z - zpt_stdev*-1),
     3216                zp_y, "expname: "+exp_name+"<br>exp_id: "+exp_id+"<br>HST: "+timestamp+"<br>RA: "+ra+"<br>DEC: "+dec+"<br>filter: "+filter+"<br>comment: "+comment,  parseFloat(zp_y - zpt_stdev), parseFloat(zp_y - zpt_stdev*-1),
     3217                zp_w, "expname: "+exp_name+"<br>exp_id: "+exp_id+"<br>HST: "+timestamp+"<br>RA: "+ra+"<br>DEC: "+dec+"<br>filter: "+filter+"<br>comment: "+comment,  parseFloat(zp_w - zpt_stdev), parseFloat(zp_w - zpt_stdev*-1)
     3218            ];
     3219        });
     3220
     3221        data.addRows(rows);
     3222
     3223        const options = {
     3224            title: 'Zeropoint zoom-in (MJD)',
     3225            titleTextStyle: { color: 'black', fontSize: 15 },
     3226            width: '100%',
     3227            height: 480,
     3228            legend: { position: 'top', alignment: 'start', maxLines: 3 },
     3229            series: {
     3230                0: { color: '#00f000', pointSize: 10, pointShape: 'circle',   linewidth: 1},  // 'g' filter
     3231                1: { color: '#f00000', pointSize: 10, pointShape: 'triangle', linewidth: 1},  // 'r' filter
     3232                2: { color: '#f05000', pointSize: 10, pointShape: 'square',   linewidth: 1},  // 'i' filter
     3233                3: { color: '#0050a0', pointSize: 10, pointShape: 'diamond',  linewidth: 1},  // 'z' filter
     3234                4: { color: '#ffe000', pointSize: 10, pointShape: 'star',     linewidth: 1},  // 'y' filter
     3235                5: { color: '#808080', pointSize: 10, pointShape: 'polygon',  linewidth: 1},  // 'w' filter
     3236            },
     3237            intervals: { color: 'red', lineWidth: 1, style: 'sticks' },
     3238            hAxis: {
     3239                title: 'MJD',
     3240                gridlines: { count: -1 }
     3241            },
     3242            vAxis: {
     3243                title: 'Zeropoint (mag)',
     3244                viewWindow: {   min: -1.00, max: .5    },
     3245            },
     3246            tooltip: { isHtml: true },
     3247            chartArea: { left: '9%', top: 60, right: '5%', bottom: 50 },
     3248            fontSize: 12,
     3249        };
     3250
     3251        const chart = new google.visualization.LineChart(document.getElementById('dq_div_zoomzpt'));
     3252        chart.draw(data, options);
     3253    }
     3254
     3255    // draw zeropoint vs mjd
     3256    function drawZPTChart() {
     3257        var data = new google.visualization.DataTable();
     3258        data.addColumn('number', 'MJD');
     3259
     3260        // Add columns for each filter type to handle separate colors
     3261        data.addColumn('number', 'g' );
     3262        data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});
     3263        data.addColumn({type: 'number', role: 'interval'});
     3264        data.addColumn({type: 'number', role: 'interval'});
     3265        data.addColumn('number', 'r' );
     3266        data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});
     3267        data.addColumn({type: 'number', role: 'interval'});
     3268        data.addColumn({type: 'number', role: 'interval'});
     3269        data.addColumn('number', 'i' );
     3270        data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});
     3271        data.addColumn({type: 'number', role: 'interval'});
     3272        data.addColumn({type: 'number', role: 'interval'});
     3273        data.addColumn('number', 'z' );
     3274        data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});
     3275        data.addColumn({type: 'number', role: 'interval'});
     3276        data.addColumn({type: 'number', role: 'interval'});
     3277        data.addColumn('number', 'y' );
     3278        data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});
     3279        data.addColumn({type: 'number', role: 'interval'});
     3280        data.addColumn({type: 'number', role: 'interval'});
     3281        data.addColumn('number', 'w' );
     3282        data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});
     3283        data.addColumn({type: 'number', role: 'interval'});
     3284        data.addColumn({type: 'number', role: 'interval'});
     3285
     3286        // Count occurrences of each filter
     3287        const filterCounts = { g: 0, r: 0, i: 0, z: 0, y: 0, w: 0 };
     3288       const rows = dataArray.map(row => {
     3289            const [timestamp, mjd, filter, comment, ra, dec, exp_name, alt, az, iq_fwhm_maj, iq_fwhm_min, zpt_obs, zpt_stdev, exp_id] = row;
     3290
     3291            // Initialize all filter values as null
     3292            let zp_g = null, zp_r = null, zp_i = null, zp_z = null, zp_y = null, zp_w = null;
     3293
     3294            // Increment the count for the filter
     3295            if (filterCounts.hasOwnProperty(filter[0])) {
     3296                filterCounts[filter[0]] += 1;
     3297            }
     3298
     3299            // Set the zeropoint offset based on filter and assign it to the correct series
     3300            switch (filter[0]) {
     3301                case 'g':
     3302                    zp_g = zpt_obs - 0.0;
     3303                    break;
     3304                case 'r':
     3305                    zp_r = zpt_obs - 0.0;
     3306                    break;
     3307                case 'i':
     3308                    zp_i = zpt_obs - 0.0;
     3309                    break;
     3310                case 'z':
     3311                    zp_z = zpt_obs - 0.0;
     3312                    break;
     3313                case 'y':
     3314                    zp_y = zpt_obs - 0.0;
     3315                    break;
     3316                case 'w':
     3317                    zp_w = zpt_obs - 0.0;
     3318                    break;
     3319            }
     3320
     3321            return [
     3322                parseFloat(mjd), // MJD value
     3323                zp_g, "expname: "+exp_name+"<br>exp_id: "+exp_id+"<br>HST: "+timestamp+"<br>RA: "+ra+"<br>DEC: "+dec+"<br>filter: "+filter+"<br>comment: "+comment,  parseFloat(zp_g - zpt_stdev), parseFloat(zp_g - zpt_stdev*-1),
     3324                zp_r, "expname: "+exp_name+"<br>exp_id: "+exp_id+"<br>HST: "+timestamp+"<br>RA: "+ra+"<br>DEC: "+dec+"<br>filter: "+filter+"<br>comment: "+comment,  parseFloat(zp_r - zpt_stdev), parseFloat(zp_r - zpt_stdev*-1),
     3325                zp_i, "expname: "+exp_name+"<br>exp_id: "+exp_id+"<br>HST: "+timestamp+"<br>RA: "+ra+"<br>DEC: "+dec+"<br>filter: "+filter+"<br>comment: "+comment,  parseFloat(zp_i - zpt_stdev), parseFloat(zp_i - zpt_stdev*-1),
     3326                zp_z, "expname: "+exp_name+"<br>exp_id: "+exp_id+"<br>HST: "+timestamp+"<br>RA: "+ra+"<br>DEC: "+dec+"<br>filter: "+filter+"<br>comment: "+comment,  parseFloat(zp_z - zpt_stdev), parseFloat(zp_z - zpt_stdev*-1),
     3327                zp_y, "expname: "+exp_name+"<br>exp_id: "+exp_id+"<br>HST: "+timestamp+"<br>RA: "+ra+"<br>DEC: "+dec+"<br>filter: "+filter+"<br>comment: "+comment,  parseFloat(zp_y - zpt_stdev), parseFloat(zp_y - zpt_stdev*-1),
     3328                zp_w, "expname: "+exp_name+"<br>exp_id: "+exp_id+"<br>HST: "+timestamp+"<br>RA: "+ra+"<br>DEC: "+dec+"<br>filter: "+filter+"<br>comment: "+comment,  parseFloat(zp_w - zpt_stdev), parseFloat(zp_w - zpt_stdev*-1),
     3329
     3330            ];
     3331        });
     3332      data.addRows(rows);
     3333
     3334        // Include counts in the title using string concatenation
     3335        const countsTitle = 'Zeropoint (MJD) g: ' + filterCounts.g + ', r: ' + filterCounts.r + ', i: ' + filterCounts.i + ', z: ' + filterCounts.z + ', y: ' + filterCounts.y + ', w: ' + filterCounts.w;
     3336
     3337
     3338        console.log(countsTitle);
     3339
     3340        const options = {
     3341            title: countsTitle,
     3342            titleTextStyle: { color: 'black', fontSize: 15 },
     3343            width: '100%',
     3344            height: 480,
     3345            legend: { position: 'top', alignment: 'center' },
     3346            series: {
     3347                0: { color: '#00f000', pointSize: 10, pointShape: 'circle',   linewidth: 1},  // 'g' filter
     3348                1: { color: '#f00000', pointSize: 10, pointShape: 'triangle', linewidth: 1},  // 'r' filter
     3349                2: { color: '#f05000', pointSize: 10, pointShape: 'square',   linewidth: 1},  // 'i' filter
     3350                3: { color: '#0050a0', pointSize: 10, pointShape: 'diamond',  linewidth: 1},  // 'z' filter
     3351                4: { color: '#ffe000', pointSize: 10, pointShape: 'star',     linewidth: 1},  // 'y' filter
     3352                5: { color: '#808080', pointSize: 10, pointShape: 'polygon',  linewidth: 1},  // 'w' filter
     3353            },
     3354            intervals: { color: 'red', lineWidth: 1, style: 'sticks' },
     3355            hAxis: {
     3356                title: 'MJD',
     3357                gridlines: { count: -1 }
     3358            },
     3359            vAxis: {
     3360                title: 'Zeropoint (mag)'
     3361            },
     3362            tooltip: { isHtml: true },
     3363            chartArea: { left: '9%', top: 60, right: '5%', bottom: 50 },
     3364            fontSize: 12,
     3365        };
     3366
     3367        const chart = new google.visualization.LineChart(document.getElementById('dq_div_zpt'));
     3368        chart.draw(data, options);
     3369    }
     3370
     3371    google.charts.setOnLoadCallback(drawFWHMChart);
     3372    google.charts.setOnLoadCallback(drawZPTChart);
     3373    google.charts.setOnLoadCallback(drawZOOMZPTChart);
     3374
     3375</script>
     3376
     3377<div class="chartWithOverlay" style="position: relative; width: 640px; height:500px;">
     3378    <div id="dq_div_fwhm" style="width:640px;"></div>
     3379    <div class="overlay" style="position: absolute; width: 400px; bottom: 60px; left: 85px;"></div>
     3380</div>
     3381
     3382<div class="chartWithOverlay" style="position: relative; width: 640px; height:500px;">
     3383    <div id="dq_div_zpt" style="width:640px;"></div>
     3384    <div class="overlay" style="position: absolute; width: 400px; bottom: 60px; left: 85px;"></div>
     3385</div>
     3386
     3387<div class="chartWithOverlay" style="position: relative; width: 640px; height:500px;">
     3388    <div id="dq_div_zoomzpt" style="width:640px;"></div>
     3389    <div class="overlay" style="position: absolute; width: 400px; bottom: 60px; left: 85px;"></div>
     3390</div>
     3391
     3392HTML;
     3393    // End timer
     3394    $total_time = round(microtime(true) - $start, 3);
     3395    echo "<center>loading plot in $total_time seconds<br></center>";
     3396
     3397}
     3398
     3399
     3400
    29963401function getprocrate ($proc1, $proc0, $trange) {
    29973402  if($proc1 > $proc0) {
  • trunk/ippMonitor/raw/ipp.php

    r42384 r42736  
    958958}
    959959
     960function getMJD() {
     961    // Get the current date and time in UTC as a Unix timestamp
     962    $currentTimestamp = time();
     963   
     964    // Convert the Unix timestamp to Julian Date (JD)
     965    $jd = 2440587.5 + ($currentTimestamp / 86400);
     966   
     967    // Calculate the Modified Julian Date (MJD)
     968    $mjd = $jd - 2400000.5;
     969    $mjdDay = floor($mjd); // Get only the day part of MJD
     970   
     971    // Concatenate the desired string for expname
     972    //$expname = "o" . $mjdDay . "%";
     973   
     974    // Format the current date in 'YYYY-MM-DD-HH:mm:ss' for display
     975    //$currentUTC = gmdate('Y-m-d-H:i:s', $currentTimestamp);
     976   
     977    // Display the result
     978    //echo "Current UTC: $currentUTC, MJD: $mjdDay, expname: $expname<br>";
     979   
     980    // Return MJD day as an integer
     981    return $mjdDay;
     982}
     983
     984
     985
    960986?>
  • trunk/ippMonitor/raw/ipp.plots.dat

    r42272 r42736  
    2222menulink  | menuselect      | link    | Plot Background (chipProcessedImfile) vs Moon Phase (rawExp) | scatterCpiBgReMpImage.php
    2323menulink  | menuselect      | link    | Plot Background (chipProcessedImfile) vs Sun Angle (rawExp) | scatterCpiBgReSaImage.php
     24
     25menutop   | menutop      | plain   | &nbsp;                                 |
     26menulink  | menuselect      | link    | pointing status | scatterPlotPointing.php
     27menulink  | menuselect      | link    | data quality status | scatterPlotDataQuality.php
     28menulink  | menuselect      | link    | airmass status | scatterPlotAirmassMcal.php
  • trunk/ippMonitor/raw/storage.php

    r42276 r42736  
    2323echo "<table border=\"0\">";
    2424echo "<tr>";
    25 echo "  <td style=width:1000px>";
     25echo "  <td style=width:1200px>";
    2626echo "  <h1 align=\"middle\">Storage status</h1>";
    2727# storage timeseries
     
    4242/////////////////////////////////////////////////////////////////////////////
    4343
    44 
    4544###########################################################################
    4645#
     
    4948###########################################################################
    5049function getHosts($db) {
    51     // timer start
    52     $time = microtime();
    53     $time = explode(' ', $time);
    54     $time = $time[1] + $time[0];
    55     $start = $time;
    56 
    57     #echo "<script type=\"text/javascript\" src=\"https://www.gstatic.com/charts/loader.js\"></script>";
     50    $start = microtime(true);
     51
    5852    echo "<script type=\"text/javascript\" src=\"loader.js\"></script>";
    59     echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 640px\">";
    60     echo "  <div id=\"disk_div\" style=\"width:1000px; height:1600px\"></div>";
     53    echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 100%\">";
     54    echo "  <div id=\"disk_div\" style=\"width:100%; height:4000px\"></div>";
    6155    echo "  <div class=\"overlay\" style=\"position: absolute; width: 100px; top: 50px; right: 20px;\">";
    6256    echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: #00ff00\"><center>Free</div>";
     
    6862    echo "</div>";
    6963
    70     echo "<script type=\"text/javascript\">";
    71     echo "google.charts.load('current', {packages: ['corechart', 'bar']});";
    72     echo "google.charts.setOnLoadCallback(drawBarColors);";
    73     echo "function drawBarColors() {";
    74     echo "  var data = google.visualization.arrayToDataTable([";
    75     echo "    ['Host', ";
    76     echo "     'used', {type: 'string', role: 'style'}, {type: 'string', role: 'tooltip', 'p': {'html': true}}, ";
    77     echo "     'free', {type: 'string', role: 'style'}, {type: 'string', role: 'tooltip', 'p': {'html': true}}],";
    78 
    79     $sql = "SELECT host, format(total,1), format(available,2), format(used,2), writable, readable, format(used/total*100,2) FROM hosts order by host";
    80     if ($debug) {echo "$sql<br>";}
     64    // Set environment variables
     65    putenv("PATH=/usr/local/bin:/usr/bin:/bin:/data/ippc65.0/ipp/src/psconfig//ipp-20210708-gentoo.lin64/bin");
     66    putenv("PERL5LIB=/data/ippc65.0/ipp/src/psconfig//ipp-20210708-gentoo.lin64/lib");
     67
     68    $hostnoteall = array();
     69    exec("neb-host |cut -b 17-30,86-", $hostnoteall);
     70
     71    $sql = "SELECT host, format(total, 2), format(available, 2), format(used, 2), writable, readable, format(used/total*100,3) as ratio
     72            FROM hosts
     73            ORDER BY host";
    8174    $qry = $db->query($sql);
    82     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
    83     # not sure why neb-host doesn't work on ipp113 CCL.20210216
    84     exec("neb-host |cut -b 17-30,86-", $hostnoteall);
     75
     76    if ($qry === false) {
     77        echo "<b>Error with SQL query</b><br>";
     78        return;
     79    }
     80
     81    $dataRows = array();
    8582    while ($qry->fetchInto($row)) {
    86         list($host, $total, $available, $used, $writable, $readable, $ratio) = $row;
    87        $hostnotes = preg_grep("/$host/", $hostnoteall);
    88        $hostnote = array_values($hostnotes);
    89        if ($writable == 1 && $readable == 1) {
    90           if ($ratio >= 97) {
    91             # space used over limits, up mode (read/write ok).
    92             echo "[ \"$host\", ";
    93             echo "      $used, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #ff0000;\", \"<i><b>$host: $ratio% of $total TB used</b></i><br>$hostnote[0]\", ";
    94             echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #00ff00;\", \"<i><b>$host: $available TB free</b></i>\"],";
    95           }
    96           else {
    97             # enough space, up mode (read/write ok).
    98             echo "[ \"$host\", ";
    99             echo "      $used, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #ffff00;\", \"<i><b>$host: $ratio% of $total TB used</b></i><br>$hostnote[0]\", ";
    100             echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #00ff00;\", \"<i><b>$host: $available TB free</b></i>\"],";
    101          }
    102        }
    103        else if ($writable == 0 && $readable == 1) {
    104           if ($ratio >= 97) {
    105             # space used over limits, repair mode (read only).
    106             echo "[ \"$host\", ";
    107             echo "      $used, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #ff0000;\", \"<i><b>$host: $ratio% of $total TB used<br><font color=red>$hostnote[0]\", ";
    108             echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #bbbbbb;\", \"<i><b>$host: $available TB free</b></i>\"],";
    109           }
    110           else {
    111             # enough space, but hosts are unstable, repair mode (read only).
    112             echo "[ \"$host\", ";
    113             echo "      $used, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #ffff00;\", \"<i><b>$host: $ratio% of $total TB used<br>$hostnote[0]\", ";
    114             echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #bbbbbb;\", \"<i><b>$host: $available TB free</b></i>\"],";
    115           }
    116        }
    117        else {
    118             # down mode (can't read or write).
    119             echo "[ \"$host\", ";
    120             echo "      $used, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #bbbbbb;\", \"<i><b>$host: $ratio% used<br>$hostnote[0]\", ";
    121             echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #bbbbbb;\", \"<i><b>$host: $available TB free</b></i>\"],";
    122        }
     83        // Access data using numeric indices
     84        $host = $row[0]; // ipp071.0
     85        $total = $row[1]; // 80.0352
     86        $available = $row[2]; // 10.8096
     87        $used = $row[3]; // 69.2256
     88        $writable = $row[4]; // 0
     89        $readable = $row[5]; // 1
     90        $ratio = $row[6]; // 86.493950215116
     91
     92        $hostnotes = preg_grep("/$host/", $hostnoteall);
     93        $hostnote = reset($hostnotes);
     94
     95        $styles = "stroke-width: 0.5; stroke-color: black;";
     96        if ($writable == 1 && $readable == 1) {
     97            $usedColor = $ratio >= 97 ? "#ff0000" : "#ffff00";
     98            $freeColor = "#00ff00";
     99        } elseif ($writable == 0 && $readable == 1) {
     100            $usedColor = $ratio >= 97 ? "#ff0000" : "#ffff00";
     101            $freeColor = "#bbbbbb";
     102        } else {
     103            $usedColor = $freeColor = "#bbbbbb";
     104        }
     105
     106        $dataRows[] = "[ \"$host\", $used, \"$styles color: $usedColor;\", \"$host: $ratio% of $total TB used<br>$hostnote\",
     107                       $available, \"$styles color: $freeColor;\", \"$host: $available TB free\"]";
    123108    }
    124    echo "  ]);";
    125    echo "   var options = {";
    126    echo "     title: 'Nebulous Disk Use across IPP Clusters',";
    127    echo "     titleTextStyle: {color: 'black', fontSize: 15},";
    128    echo "     width: '100%',";
    129    echo "     height: '100%',";
    130    echo "     tooltip: {isHtml: true},";
    131    echo "     legend: { position: 'none',";
    132    echo "               alignment: 'end',";
    133    echo "               maxLines: 3},";
    134    echo "     hAxis: {  title: 'Space (TB)',";
    135    echo "               gridlines: {count: 10}";
    136    echo "     },";
    137    echo "     bar: { groupWidth: '95%' },";
    138    echo "     chartArea: {left:70, top:30, right:20, bottom:40},";
    139    echo "     fontSize: 12,";
    140    echo "     isStacked: true";
    141    echo "   };";
    142    echo "   var chart = new google.visualization.BarChart(document.getElementById('disk_div'));";
    143    echo "   chart.draw(data, options);";
    144    echo " }";
    145    echo "</script>";
    146     $time = microtime();
    147     $time = explode(' ', $time);
    148     $time = $time[1] + $time[0];
    149     $finish = $time;
    150     $total_time = round(($finish - $start), 3);
    151     $start= $finish;
     109
     110    echo "<script type=\"text/javascript\">
     111            google.charts.load('current', {packages: ['corechart', 'bar']});
     112            google.charts.setOnLoadCallback(drawBarColors);
     113
     114            function drawBarColors() {
     115                var data = google.visualization.arrayToDataTable([
     116                    ['Host', 'Used', {type: 'string', role: 'style'}, {type: 'string', role: 'tooltip', 'p': {'html': true}},
     117                     'Free', {type: 'string', role: 'style'}, {type: 'string', role: 'tooltip', 'p': {'html': true}}],
     118                    " . implode(",\n", $dataRows) . "
     119                ]);
     120               
     121                var options = {
     122                    title: 'Nebulous Disk Use across IPP Clusters',
     123                    titleTextStyle: {color: 'black', fontSize: 15},
     124                    width: '100%',
     125                    height: '100%',
     126                    tooltip: {isHtml: true},
     127                    legend: { position: 'none', alignment: 'end', maxLines: 3 },
     128                    hAxis: { title: 'Space (TB)', gridlines: {count: 10} },
     129                    bar: { groupWidth: '95%' },
     130                    chartArea: {left:100, top:50, right:20, bottom:40},
     131                    fontSize: 15,
     132                    isStacked: true
     133                };
     134
     135                var chart = new google.visualization.BarChart(document.getElementById('disk_div'));
     136                chart.draw(data, options);
     137            }
     138          </script>";
     139
     140    $total_time = round(microtime(true) - $start, 3);
    152141    echo "<center>loading in $total_time seconds<br></center>";
    153142}
     143
    154144
    155145###########################################################################
     
    186176    #echo "<script type=\"text/javascript\" src=\"https://www.gstatic.com/charts/loader.js\"></script>";
    187177    echo "<script type=\"text/javascript\" src=\"loader.js\"></script>";
    188     echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 640; height:400\">";
    189     echo "  <div id=\"space_div\" style=\"width:1000; \"></div>";
     178    echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 100%; height:400\">";
     179    echo "  <div id=\"space_div\" style=\"width:100%; \"></div>";
    190180    echo "  <div class=\"overlay\" style=\"position: absolute; width: 400px; bottom: 60px; left: 85px;\">";
    191181    echo "    <div style=\"font-size: 16px; color:#0000ff; background-color:#ffffff\"><b>ipp + ippb nodes: $ippusable + $ippbusable TB (latest usable)</b></div>";
Note: See TracChangeset for help on using the changeset viewer.