$writeToGridStatus = $queryManager->writeGridToDB($grid, $timestamp, $gridReference, java_values($driver->gridExtent));
    if ($writeToGridStatus) {
        $ozoneCount = $queryManager->getGridOzoneCount($timestamp);
        $prevCount = apc_fetch("_totalo3_" . ($timestamp - 300));
        if ($ozoneCount !== false && $prevCount !== false) {
            if ((1 + EPS1) * $prevCount < $ozoneCount) {
                error_log("ERROR_METRIC: Potential spike in some monitor for time: {$timestamp}");
            }
            apc_store("_totalo3_{$timestamp}", $ozoneCount);
        }
    }
    $queryTime += microtime(true) - $queryStart;
}
if ($writeToGridStatus) {
    $contourStart = microtime(true);
    $r = $driver->getContours($allData['ozoneStations'], $allData['windStations'], $allData['ozoneValues'], $allData['windSpeed'], $allData['windDirection'], $stepSize);
    $contourLines = java_values($r);
    $updatedTime = time();
    $ret = $contourDataStore->saveContour($timestamp, getSerializedJson($contourLines, $timestamp, $updatedTime), $useJSONP, $keepHistory);
    $queryManager->setGridUpdatedTime($timestamp, $txnAt, $updatedTime);
    if (!$ret) {
        echo 'ERROR: ' . $contourDataStore->getLastError() . "\n";
    }
    echo "Contour Saved to file!!\n";
    $contourTime = microtime(true) - $contourStart;
    // write grid data file
    //   create grid data array; same formate as output from loadGrid()
    /*    if (! empty($grid)) {
          $grid_array = array();
          $grid_array['timestamp'] = $timestamp;
          $grid_array['gen_time'] = $updatedTime;
    //echo "prewritegrid\n";
    $writeToGridStatus = $queryManager->writeGridToDB($grid, $timestamp, $gridReference, java_values($driver->gridExtent), $param);
    if ($writeToGridStatus) {
        $paramCount = $queryManager->getGridParamCount($timestamp, $param);
        $prevCount = apc_fetch("_total{$param}_" . ($timestamp - 300));
        if ($paramCount !== false && $prevCount !== false) {
            if ((1 + EPS1) * $prevCount < $ozoneCount) {
                error_log("ERROR_METRIC: Potential spike in some monitor for time: {$timestamp}");
            }
            apc_store("_total{$param}_{$timestamp}", $ozoneCount);
        }
    }
    $queryTime += microtime(true) - $queryStart;
}
if ($writeToGridStatus && false) {
    $r = $driver->getContours($allData["{$param}Stations"], $allData['windStations'], $allData["{$param}Values"], $allData['windSpeed'], $allData['windDirection'], $stepSize);
    $contourLines = java_values($r);
    $updatedTime = time();
    $ret = $contourDataStore->saveContour($timestamp, getSerializedJson($contourLines, $timestamp, $updatedTime), $param, $useJSONP, $keepHistory);
    $queryManager->setGridUpdatedTime($timestamp, $param, $txnAt, $updatedTime);
    if (!$ret) {
        echo 'ERROR: ' . $contourDataStore->getLastError() . "\n";
    }
    echo "Contour Saved to file!!\n";
    // write grid data file
    //   create grid data array; same formate as output from loadGrid()
    /*    if (! empty($grid)) {
          $grid_array = array();
          $grid_array['timestamp'] = $timestamp;
          $grid_array['gen_time'] = $updatedTime;
          $grid_array['gridExtent'] = $gridExtent;