145 lines
5.4 KiB
HTML
145 lines
5.4 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Wunderground obs</title>
|
|
</head>
|
|
<body>
|
|
|
|
|
|
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js" integrity="sha512-WNLxfP/8cVYL9sj8Jnp6et0BkubLP31jhTG9vhL/F5uEZmg5wEzKoXp1kJslzPQWwPT1eyMiSxlKCgzHLOTOTQ==" crossorigin="anonymous"></script>
|
|
<link href="https://unpkg.com/tabulator-tables@4.7.2/dist/css/tabulator.min.css" rel="stylesheet">
|
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/luxon@2.3.1/build/global/luxon.min.js"></script>
|
|
<script type="text/javascript" src="https://unpkg.com/tabulator-tables@4.7.2/dist/js/tabulator.min.js"></script>
|
|
<button onclick="reloadData()">Data autorefreshes every 5 minutes, click to refresh now</button>
|
|
<a>QPE 00L is direct from WU, the other QPE are derived and may be off if time settings on the individual PWS are incorrect</a>
|
|
<input type="checkbox" id="cwa" name="cwa" value="RLX" onchange="filters()" checked>
|
|
<label for="cwa">RLX only</label><br>
|
|
<div id="wunderobs"></div>
|
|
|
|
<script>
|
|
var dataurl = 'db.php'
|
|
|
|
|
|
function googleMap(cell, formatterParams){
|
|
return "http://maps.google.com/maps?t=k&q=loc:" + cell.getData().lat + "+" + cell.getData().lon + "&basemap=satellite";
|
|
}
|
|
|
|
function calculateApparentTemperature(temperature, dewPoint, windSpeed) {
|
|
// Heat Index calculation for temperatures above 80°F (26.7°C)
|
|
function heatIndex(temp, dp) {
|
|
if (temp < 80) return temp;
|
|
|
|
let hi = 0.5 * (temp + 61.0 + ((temp - 68.0) * 1.2) + (dp * 0.094));
|
|
|
|
if (hi > 79) {
|
|
hi = -42.379 +
|
|
2.04901523 * temp +
|
|
10.14333127 * dp -
|
|
0.22475541 * temp * dp -
|
|
6.83783 * Math.pow(10, -3) * Math.pow(temp, 2) -
|
|
5.481717 * Math.pow(10, -2) * Math.pow(dp, 2) +
|
|
1.22874 * Math.pow(10, -3) * Math.pow(temp, 2) * dp +
|
|
8.5282 * Math.pow(10, -4) * temp * Math.pow(dp, 2) -
|
|
1.99 * Math.pow(10, -6) * Math.pow(temp, 2) * Math.pow(dp, 2);
|
|
|
|
// Adjustments for high temperatures
|
|
if (dp < 13) {
|
|
hi -= ((13 - dp) / 4) * Math.sqrt((17 - Math.abs(temp - 95)) / 17);
|
|
}
|
|
if (dp > 85) {
|
|
hi += ((dp - 85) / 10) * ((87 - temp) / 5);
|
|
}
|
|
}
|
|
|
|
return hi;
|
|
}
|
|
|
|
// Wind Chill calculation for temperatures below 50°F (10°C)
|
|
function windChill(temp, wind) {
|
|
if (temp > 50 || wind < 3) return temp;
|
|
|
|
let wc = 35.74 + 0.6215 * temp - 35.75 * Math.pow(wind, 0.16) + 0.4275 * temp * Math.pow(wind, 0.16);
|
|
return wc;
|
|
}
|
|
|
|
let apparentTemp;
|
|
|
|
if (temperature > 80) {
|
|
// High temperature scenario, use heat index
|
|
apparentTemp = heatIndex(temperature, dewPoint);
|
|
} else if (temperature < 50 && windSpeed > 3) {
|
|
// Low temperature scenario, use wind chill
|
|
apparentTemp = windChill(temperature, windSpeed);
|
|
} else {
|
|
// Moderate temperature, just return the actual temperature
|
|
apparentTemp = temperature;
|
|
}
|
|
|
|
// Ensure the result is within reasonable bounds
|
|
apparentTemp = Math.min(140, Math.max(-20, apparentTemp));
|
|
|
|
return apparentTemp.toFixed(1);
|
|
}
|
|
|
|
function reloadData() {
|
|
table.replaceData(dataurl);
|
|
}
|
|
|
|
var table = new Tabulator("#wunderobs", {
|
|
responsiveLayout:true,
|
|
tooltipsHeader:true,
|
|
columns:[
|
|
{title:"Station", field:"stationid", formatter:"link", formatterParams:{urlPrefix:"https://www.wunderground.com/dashboard/pws/", target:"_blank"}},
|
|
{title:"Time (UTC)", field:"lastob"},
|
|
{title:"T", field:"tempf"},
|
|
{title:"ApT",formatter:function(cell) {
|
|
apparentT = calculateApparentTemperature(cell.getData().tempf,cell.getData().dewpt,cell.getData().windspd);
|
|
console.log(apparentT)
|
|
return apparentT
|
|
|
|
}},
|
|
{title:"Td", field:"dewpt"},
|
|
{title:"QPE 00L", field:"preciptotal",formatter:"money",headerTooltip:"Since Midnight"},
|
|
{title:"24hr QPE", field:"rain24",formatter:"money"},
|
|
{title:"6hr QPE", field:"rain6",formatter:"money"},
|
|
{title:"3hr QPE", field:"rain3",formatter:"money"},
|
|
{title:"Winddir", field:"winddir"},
|
|
{title:"Speed", field:"windspd",headerTooltip:"Mph"},
|
|
{title:"Gust", field:"windgust",headerTooltip:"Mph"},
|
|
{title:"PK 24 Gust", field:"windmax",headerTooltip:"Mph"},
|
|
{title:"MaxT", field:"maxt",headerTooltip:"Last 24hrs"},
|
|
{title:"MinT", field:"mint",headerTooltip:"Last 24hrs"},
|
|
{title:"Elev", field:"elev",responsive:2},
|
|
{title:"Lon", field:"lon",visible:false},
|
|
{title:"City", field:"adm1"},
|
|
{title:"State", field:"adm2"},
|
|
{title:"County", field:"county"},
|
|
{title:"Baro", field:"pressure",responsive:2},
|
|
{title:"Location", field:"neighborhood", formatter:"link", formatterParams:{url: googleMap, target:"_blank"}}
|
|
],
|
|
});
|
|
|
|
table.setData(dataurl);
|
|
|
|
function filters() {
|
|
var y = document.getElementById("cwa").checked;
|
|
if (y) {
|
|
dataurl = 'db.php'
|
|
table.replaceData(dataurl)
|
|
table.addFilter("cwa", "=", 'RLX');
|
|
|
|
}
|
|
if (!y) {
|
|
dataurl = 'db.php?outside=yes'
|
|
table.replaceData(dataurl)
|
|
table.removeFilter("cwa", "=", 'RLX');
|
|
}
|
|
}
|
|
// {title:"24hr QPE", field:"rain24", formatterParms:{precision:2}},
|
|
var timeout = setInterval(reloadData, 300000);
|
|
</script>
|
|
</body>
|
|
</html>
|