1178 lines
48 KiB
JavaScript
1178 lines
48 KiB
JavaScript
|
// Sanitization
|
||
|
$(function() {
|
||
|
$('#container').html('<center><img src="/images/slc/common_images/spinner.gif"></center>');
|
||
|
|
||
|
})
|
||
|
|
||
|
function popup(site) {
|
||
|
if (!site) {
|
||
|
site = 'kslc'
|
||
|
}
|
||
|
alert('Something is wrong!');
|
||
|
window.location.href = 'https://www.weather.gov/wrh/timeseries?site='+site;
|
||
|
}
|
||
|
|
||
|
function myMonitorOBS(SITE,numHours) {
|
||
|
SITE = SITE.toUpperCase();
|
||
|
$('#SITE').html('<input type="hidden" value="'+SITE+'" name="SITE">');
|
||
|
var numMinutes = numHours * 60;
|
||
|
var InfoToGet = 'https://api.mesowest.net/v2/stations/timeseries?STID='+SITE+'&showemptystations=1&units=temp|F,speed|mph,english&recent='+numMinutes+'&token=d8c6aee36a994f90857925cea26934be&complete=1&obtimezone=local';
|
||
|
console.log('HELLO', InfoToGet);
|
||
|
$.getJSON(InfoToGet, function(DATA) {
|
||
|
if (DATA.SUMMARY.RESPONSE_MESSAGE == "OK") {
|
||
|
// Metadata
|
||
|
var stnID = DATA.STATION[0].STID;
|
||
|
var stnNAM = DATA.STATION[0].NAME;
|
||
|
var stnLAT = DATA.STATION[0].LATITUDE;
|
||
|
var stnLON = DATA.STATION[0].LONGITUDE
|
||
|
var stnELE = DATA.STATION[0].ELEVATION;
|
||
|
var state = DATA.STATION[0].STATE;
|
||
|
var cwa = DATA.STATION[0].CWA;
|
||
|
var network = DATA.STATION[0].SHORTNAME;
|
||
|
var derived = 0;
|
||
|
|
||
|
// Building block for datasets
|
||
|
var header1 = '<table id="OBS_DATA"><tbody><tr id="HEADER"><td>Date/Time<br> </td>';
|
||
|
var EngUnits = '<tr id="HEADER"><td>(L)</td>';
|
||
|
var stamps = '';
|
||
|
|
||
|
if (DATA.STATION[0].hasOwnProperty('OBSERVATIONS')) {
|
||
|
stamps = DATA.STATION[0].OBSERVATIONS.date_time;
|
||
|
var numObs = DATA.STATION[0].OBSERVATIONS.date_time.length;
|
||
|
numObs = numObs - 1;
|
||
|
var tableData = '';
|
||
|
// Loop through each observation
|
||
|
var METARString = '<table id="OBS">';
|
||
|
for (j = numObs; j > -1; j--) {
|
||
|
// Date and time
|
||
|
var MW_TIMESTAMP = DATA.STATION[0].OBSERVATIONS.date_time[j];
|
||
|
var TIMEZONE = DATA.STATION[0].TIMEZONE;
|
||
|
var TIMESTAMP = new Date(MW_TIMESTAMP);
|
||
|
TIMESTAMP = TIMESTAMP.toLocaleString('en-US', { timeZone: TIMEZONE });
|
||
|
var months_arr = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
|
||
|
var MONTH = ''; //new Date(TIMESTAMP).getMonth();
|
||
|
var month = MW_TIMESTAMP; //months_arr[MONTH];
|
||
|
var day = ''; //new Date(TIMESTAMP).getDate();
|
||
|
var hours = ''; //new Date(TIMESTAMP).getHours();
|
||
|
var minutes = ''; //new Date(TIMESTAMP).getMinutes();
|
||
|
// if (parseInt(minutes) < 10) {
|
||
|
// minutes = "0" + minutes;
|
||
|
// } else {
|
||
|
// minutes = minutes;
|
||
|
// }
|
||
|
// if (hours < 12) {
|
||
|
// var ampm = 'am';
|
||
|
// } else {
|
||
|
// var ampm = 'pm';
|
||
|
// }
|
||
|
// if (hours == '0') {
|
||
|
// hours = 12;
|
||
|
// } else if (hours > 12) {
|
||
|
// hours = hours - 12;
|
||
|
// }
|
||
|
var ampm = '';
|
||
|
// Temperature
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('air_temp_set_1')) {
|
||
|
var ATData = DATA.STATION[0].OBSERVATIONS.air_temp_set_1;
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Temp.<br> </td>';
|
||
|
EngUnits += '<td>(°F)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.air_temp_set_1[j] !== null) {
|
||
|
var TEMP_F = '<td>'+Math.round(DATA.STATION[0].OBSERVATIONS.air_temp_set_1[j])+'</td>';
|
||
|
} else {
|
||
|
var TEMP_F = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var TEMP_F = '';
|
||
|
}
|
||
|
// Dew Point
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('dew_point_temperature_set_1d')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Dew<br>Point</td>';
|
||
|
EngUnits += '<td>(°F)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.dew_point_temperature_set_1d[j] !== null) {
|
||
|
var DEWPOINT = '<td>'+Math.round(DATA.STATION[0].OBSERVATIONS.dew_point_temperature_set_1d[j])+'</td>';
|
||
|
} else {
|
||
|
var DEWPOINT = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var DEWPOINT = '';
|
||
|
}
|
||
|
// Relative Humidity
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('relative_humidity_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Relative<br>Humidity</td>';
|
||
|
EngUnits += '<td>(%)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.relative_humidity_set_1[j] !== null) {
|
||
|
var RH_PCT = '<td>'+Math.round(DATA.STATION[0].OBSERVATIONS.relative_humidity_set_1[j])+'</td>';
|
||
|
} else {
|
||
|
var RH_PCT = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var RH_PCT = '';
|
||
|
}
|
||
|
// Wind Chill
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('wind_chill_set_1d')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Wind<br>Chill</td>';
|
||
|
EngUnits += '<td>(°F)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.wind_chill_set_1d[j] !== null) {
|
||
|
var WC = '<td>'+Math.round(DATA.STATION[0].OBSERVATIONS.wind_chill_set_1d[j])+'</td>';
|
||
|
} else {
|
||
|
var WC = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var WC = '';
|
||
|
}
|
||
|
// Wind Direction
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('wind_direction_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Wind<br>Direction</td>';
|
||
|
EngUnits += '<td> </td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.wind_cardinal_direction_set_1d[j] !== null) {
|
||
|
var Wind_DIR = (DATA.STATION[0].OBSERVATIONS.wind_cardinal_direction_set_1d[j]);
|
||
|
var WIND_DIR = '<td>'+Wind_DIR+'</td>';
|
||
|
} else {
|
||
|
var WIND_DIR = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var WIND_DIR = '';
|
||
|
}
|
||
|
// Wind Speed & Gust
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('wind_speed_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Wind<br>Speed</td>';
|
||
|
EngUnits += '<td>(mph)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.wind_speed_set_1[j] !== null) {
|
||
|
var WIND_SPD = Math.round(DATA.STATION[0].OBSERVATIONS.wind_speed_set_1[j]);
|
||
|
if (WIND_SPD < 20 ) {
|
||
|
WIND_SPD = '<td>'+WIND_SPD;
|
||
|
} else if (WIND_SPD < 40 ) {
|
||
|
WIND_SPD = '<td><font color="blue">'+WIND_SPD+'</font>';
|
||
|
} else if (WIND_SPD < 58 ) {
|
||
|
WIND_SPD = '<td><font color="red">'+WIND_SPD+'</font>';
|
||
|
} else {
|
||
|
WIND_SPD = '<td><font color=#FF00FF>'+WIND_SPD+'</font>';
|
||
|
}
|
||
|
} else {
|
||
|
var WIND_SPD = '<td>0';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('wind_gust_set_1')) {
|
||
|
if (DATA.STATION[0].OBSERVATIONS.wind_gust_set_1[j] !== null) {
|
||
|
var WIND_GST =Math.round(DATA.STATION[0].OBSERVATIONS.wind_gust_set_1[j]);
|
||
|
if (WIND_GST < 20 ) {
|
||
|
WIND_SPD += 'G'+WIND_GST+'</td>';
|
||
|
} else if (WIND_GST < 40 ) {
|
||
|
WIND_SPD += '<font color="blue">G'+WIND_GST+'</font></td>';
|
||
|
} else if (WIND_GST < 58 ) {
|
||
|
WIND_SPD += '<font color="red">G'+WIND_GST+'</font></td>';
|
||
|
} else {
|
||
|
WIND_SPD += '<font color=#FF00FF>G'+WIND_GST+'</font></td>';
|
||
|
}
|
||
|
} else {
|
||
|
WIND_SPD += '</td>';
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
var WIND_SPD = '';
|
||
|
}
|
||
|
// Fuel Temperature
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('fuel_temp_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Fuel<br>Temp.</td>';
|
||
|
EngUnits += '<td>(°F)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.fuel_temp_set_1[j] !== null) {
|
||
|
var FUEL_T = '<td>'+Math.round(DATA.STATION[0].OBSERVATIONS.fuel_temp_set_1[j])+'</td>';
|
||
|
} else {
|
||
|
var FUEL_T = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var FUEL_T = '';
|
||
|
}
|
||
|
// Fuel Moisture
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('fuel_moisture_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Fuel<br>Moisture</td>';
|
||
|
EngUnits += '<td>(%)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.fuel_moisture_set_1[j] !== null) {
|
||
|
var FUEL_PCT = '<td>'+Math.round(DATA.STATION[0].OBSERVATIONS.fuel_moisture_set_1[j])+'</td>';
|
||
|
} else {
|
||
|
var FUEL_PCT = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var FUEL_PCT = '';
|
||
|
}
|
||
|
// Visibility
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('visibility_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Visibility<br> </td>';
|
||
|
EngUnits += '<td>(miles)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.visibility_set_1[j] !== null) {
|
||
|
var VISIBILITY =(DATA.STATION[0].OBSERVATIONS.visibility_set_1[j]).toFixed(2);
|
||
|
if (VISIBILITY <= 1 ) {
|
||
|
VISIBILITY = '<td><font color=#FF00FF>'+VISIBILITY+'</font></td>';
|
||
|
} else if (VISIBILITY <= 3 ) {
|
||
|
VISIBILITY = '<td><font color="#FF0000">'+VISIBILITY+'</font></td>';
|
||
|
} else if (VISIBILITY < 7) {
|
||
|
VISIBILITY = '<td><font color="#FF8800">'+VISIBILITY+'</font></td>';
|
||
|
} else {
|
||
|
VISIBILITY = '<td>'+VISIBILITY+'</td>';
|
||
|
}
|
||
|
} else {
|
||
|
var VISIBILITY = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var VISIBILITY = '';
|
||
|
}
|
||
|
// Present Weather
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('weather_cond_code_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Weather<br> </td>';
|
||
|
EngUnits += '<td> </td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.weather_cond_code_set_1[j] !== null) {
|
||
|
if (network == 'NWS/FAA') {
|
||
|
var WEATHER = parseInt(DATA.STATION[0].OBSERVATIONS.weather_cond_code_set_1[j]);
|
||
|
if (WEATHER < 80) { //
|
||
|
WX_ELEM1 = getWeatherCode(WEATHER);
|
||
|
WX_ELEM2 = '';
|
||
|
WX_ELEM3 = '';
|
||
|
} else if (WEATHER < 6400) {
|
||
|
WX1 = Math.floor (WEATHER / 80);
|
||
|
WX_ELEM1 = getWeatherCode(WX1);
|
||
|
WX2 = (WEATHER % 80);
|
||
|
WX_ELEM2 = getWeatherCode(WX2)+',';
|
||
|
WX_ELEM3 = '';
|
||
|
} else {
|
||
|
WX1 = Math.floor (WEATHER / 6400);
|
||
|
WX_ELEM1 = getWeatherCode(WX1);
|
||
|
WX2 = Math.floor (WEATHER / 80);
|
||
|
WX_ELEM2 = getWeatherCode(WX2)+',';
|
||
|
WX3 = (WEATHER % 80);
|
||
|
WX_ELEM1 = getWeatherCode(WX3)+',';
|
||
|
}
|
||
|
WEATHER = '<td>'+WX_ELEM3+' '+WX_ELEM2+' '+WX_ELEM1+'</td>';
|
||
|
} else {
|
||
|
WEATHER = '<td>'+(DATA.STATION[0].OBSERVATIONS.weather_condition_set_1d[j])+'</td>';
|
||
|
}
|
||
|
} else {
|
||
|
var WEATHER = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var WEATHER = '';
|
||
|
}
|
||
|
//Cloud Layers
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('cloud_layer_1_code_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Clouds<br> </td>';
|
||
|
EngUnits += '<td>(x100 ft)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.cloud_layer_1_code_set_1[j] !== null) {
|
||
|
var SKY1 =(DATA.STATION[0].OBSERVATIONS.cloud_layer_1_code_set_1[j]).toString();
|
||
|
var COVERAGE1 = SKY1.substr(SKY1.length -1);
|
||
|
if (COVERAGE1 == "1") {
|
||
|
SKY_COND1 = 'CLR';
|
||
|
} else if (COVERAGE1 == "2") {
|
||
|
SKY_COND1 = 'SCT';
|
||
|
} else if (COVERAGE1 == "3") {
|
||
|
SKY_COND1 = 'BKN';
|
||
|
} else if (COVERAGE1 == "4") {
|
||
|
SKY_COND1 = 'OVC';
|
||
|
} else if (COVERAGE1 == "5") {
|
||
|
SKY_COND1 = 'VV';
|
||
|
} else if (COVERAGE1 == "6") {
|
||
|
SKY_COND1 = 'FEW';
|
||
|
} else {
|
||
|
SKY_COND1 = '';
|
||
|
}
|
||
|
var DECK1 = parseInt(SKY1.slice(0, -1));
|
||
|
if (isNaN(DECK1)) {
|
||
|
DECK1 = '';
|
||
|
} else if (DECK1 < 10) {
|
||
|
DECK1 = "00"+DECK1;
|
||
|
} else if (DECK1 < 100) {
|
||
|
DECK1 = "0"+DECK1;
|
||
|
} else {
|
||
|
DECK1 = DECK1;
|
||
|
}
|
||
|
} else {
|
||
|
var SKY_COND1 = '';
|
||
|
var DECK1 = '';
|
||
|
}
|
||
|
} else {
|
||
|
var SKY_COND1 = '';
|
||
|
var DECK1 = '';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('cloud_layer_2_code_set_1')) {
|
||
|
if (DATA.STATION[0].OBSERVATIONS.cloud_layer_2_code_set_1[j] !== null) {
|
||
|
var SKY2 =(DATA.STATION[0].OBSERVATIONS.cloud_layer_2_code_set_1[j]).toString();
|
||
|
var COVERAGE2 = SKY2.substr(SKY2.length -1);
|
||
|
if (COVERAGE2 == "1") {
|
||
|
SKY_COND2 = 'CLR';
|
||
|
} else if (COVERAGE2 == "2") {
|
||
|
SKY_COND2 = 'SCT';
|
||
|
} else if (COVERAGE2 == "3") {
|
||
|
SKY_COND2 = 'BKN';
|
||
|
} else if (COVERAGE2 == "4") {
|
||
|
SKY_COND2 = 'OVC';
|
||
|
} else if (COVERAGE2 == "5") {
|
||
|
SKY_COND2 = 'VV';
|
||
|
} else if (COVERAGE2 == "6") {
|
||
|
SKY_COND2 = 'FEW';
|
||
|
} else {
|
||
|
SKY_COND2 = '';
|
||
|
}
|
||
|
var DECK2 = parseInt(SKY2.slice(0, -1));
|
||
|
if (isNaN(DECK2)) {
|
||
|
DECK2 = '';
|
||
|
} else if (DECK2 < 10) {
|
||
|
DECK2 = "00"+DECK2;
|
||
|
} else if (DECK2 < 100) {
|
||
|
DECK2 = "0"+DECK2;
|
||
|
} else {
|
||
|
DECK2 = DECK2;
|
||
|
}
|
||
|
} else {
|
||
|
var SKY_COND2 = '';
|
||
|
var DECK2 = '';
|
||
|
}
|
||
|
} else {
|
||
|
var SKY_COND2 = '';
|
||
|
var DECK2 = '';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('cloud_layer_3_code_set_1')) {
|
||
|
if (DATA.STATION[0].OBSERVATIONS.cloud_layer_3_code_set_1[j] !== null) {
|
||
|
var SKY3 =(DATA.STATION[0].OBSERVATIONS.cloud_layer_3_code_set_1[j]).toString();
|
||
|
var COVERAGE3 = SKY3.substr(SKY3.length -1);
|
||
|
if (COVERAGE3 == "1") {
|
||
|
SKY_COND3 = 'CLR';
|
||
|
} else if (COVERAGE3 == "2") {
|
||
|
SKY_COND3 = 'SCT';
|
||
|
} else if (COVERAGE3 == "3") {
|
||
|
SKY_COND3 = 'BKN';
|
||
|
} else if (COVERAGE3 == "4") {
|
||
|
SKY_COND3 = 'OVC';
|
||
|
} else if (COVERAGE3 == "5") {
|
||
|
SKY_COND3 = 'VV';
|
||
|
} else if (COVERAGE3 == "6") {
|
||
|
SKY_COND3 = 'FEW';
|
||
|
} else {
|
||
|
SKY_COND3 = '';
|
||
|
}
|
||
|
var DECK3 = parseInt(SKY3.slice(0, -1));
|
||
|
if (isNaN(DECK3)) {
|
||
|
DECK3 = '';
|
||
|
} else if (DECK3 < 10) {
|
||
|
DECK3 = "00"+DECK3;
|
||
|
} else if (DECK3 < 100) {
|
||
|
DECK3 = "0"+DECK3;
|
||
|
} else {
|
||
|
DECK3 = DECK3;
|
||
|
}
|
||
|
} else {
|
||
|
var SKY_COND3 = '';
|
||
|
var DECK3 = '';
|
||
|
}
|
||
|
} else {
|
||
|
var SKY_COND3 = '';
|
||
|
var DECK3 = '';
|
||
|
}
|
||
|
var SKY_COND = '';
|
||
|
// If there was a cloud layer, THEN make the cloud cells
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('cloud_layer_1_code_set_1')) {
|
||
|
if (SKY_COND1 == "CLR" || SKY_COND1 == "FEW" || SKY_COND1 == "SCT") {
|
||
|
LAYER1 = SKY_COND1+DECK1;
|
||
|
} else if (DECK1 < 10) {
|
||
|
LAYER1 = '<font color=#FF00FF>'+SKY_COND1+DECK1+'</font>';
|
||
|
} else if (DECK1 < 31) {
|
||
|
LAYER1 = '<font color="red">'+SKY_COND1+DECK1+'</font>';
|
||
|
} else if (DECK1 < 81) {
|
||
|
LAYER1 = '<font color="orange">'+SKY_COND1+DECK1+'</font>';
|
||
|
} else {
|
||
|
LAYER1 = SKY_COND1+DECK1;
|
||
|
}
|
||
|
|
||
|
if (SKY_COND2 == "CLR" || SKY_COND2 == "FEW" || SKY_COND2 == "SCT") {
|
||
|
LAYER2 = SKY_COND2+DECK2;
|
||
|
} else if (DECK2 < 10) {
|
||
|
LAYER2 = '<font color=#FF00FF>'+SKY_COND2+DECK2+'</font>';
|
||
|
} else if (DECK2 < 31) {
|
||
|
LAYER2 = '<font color="red">'+SKY_COND2+DECK2+'</font>';
|
||
|
} else if (DECK2 < 81) {
|
||
|
LAYER2 = '<font color="orange">'+SKY_COND2+DECK2+'</font>';
|
||
|
} else {
|
||
|
LAYER2 = SKY_COND2+DECK2;
|
||
|
}
|
||
|
if (SKY_COND3 == "CLR" || SKY_COND3 == "FEW" || SKY_COND3 == "SCT") {
|
||
|
LAYER3 = SKY_COND3+DECK3;
|
||
|
} else if (DECK3 < 10) {
|
||
|
LAYER3 = '<font color=#FF00FF>'+SKY_COND3+DECK3+'</font>';
|
||
|
} else if (DECK3 < 31) {
|
||
|
LAYER3 = '<font color="red">'+SKY_COND3+DECK3+'</font>';
|
||
|
} else if (DECK3 < 81) {
|
||
|
LAYER3 = '<font color="orange">'+SKY_COND3+DECK3+'</font>';
|
||
|
} else {
|
||
|
LAYER3 = SKY_COND3+DECK3;
|
||
|
}
|
||
|
var SKY_COND = '<td>'+LAYER1+' '+LAYER2+' '+LAYER3+'</td>';
|
||
|
}
|
||
|
// Station Pressure
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('pressure_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Station<br>Pressure</td>';
|
||
|
EngUnits += '<td>(in Hg)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.pressure_set_1[j] !== null) {
|
||
|
var P = '<td>'+(DATA.STATION[0].OBSERVATIONS.pressure_set_1[j]).toFixed(2)+'</td>';
|
||
|
} else {
|
||
|
var P = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var P = '';
|
||
|
}
|
||
|
// Sea Level Pressure
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('sea_level_pressure_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Sea Level<br>Pressure</td>';
|
||
|
EngUnits += '<td>(mb)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.sea_level_pressure_set_1[j] !== null) {
|
||
|
var SEALEVEL = '<td>'+(DATA.STATION[0].OBSERVATIONS.sea_level_pressure_set_1[j]).toFixed(2)+'</td>';
|
||
|
} else {
|
||
|
var SEALEVEL = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var SEALEVEL = '';
|
||
|
}
|
||
|
// Altimeter Setting
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('altimeter_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Altimeter<br>Setting</td>';
|
||
|
EngUnits += '<td>(in Hg)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.altimeter_set_1[j] !== null) {
|
||
|
var ALTIMTER = '<td>'+(DATA.STATION[0].OBSERVATIONS.altimeter_set_1[j]).toFixed(2)+'</td>';
|
||
|
} else {
|
||
|
var ALTIMTER = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var ALTIMTER = '';
|
||
|
}
|
||
|
// Station Pressure
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('station_pressure_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Station<br>Pressure</td>';
|
||
|
EngUnits += '<td>(in Hg)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.station_pressure_set_1[j] !== null) {
|
||
|
var STATION_P = '<td>'+(DATA.STATION[0].OBSERVATIONS.station_pressure_set_1[j]).toFixed(2)+'</td>';
|
||
|
} else {
|
||
|
var STATION_P = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var STATION_P = '';
|
||
|
}
|
||
|
// Solar Radiation
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('solar_radiation_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Solar<br>Radiation</td><td>Percent<br>Possible</td>';
|
||
|
EngUnits += '<td>(W/m²)</td><td>(%)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.solar_radiation_set_1[j] !== null) {
|
||
|
var RAW_SOLAR = (Math.round(DATA.STATION[0].OBSERVATIONS.solar_radiation_set_1[j]));
|
||
|
var SOLAR_POSS = calcSolarPCT(MW_TIMESTAMP,stnLAT,stnLON);
|
||
|
var PCT = Math.round (100 * RAW_SOLAR / SOLAR_POSS);
|
||
|
if (PCT > 100) {
|
||
|
PCT = 100;
|
||
|
}
|
||
|
if (RAW_SOLAR > 0 && SOLAR_POSS > 0) {
|
||
|
var SOLAR = '<td>'+RAW_SOLAR+'</td>';
|
||
|
var SOLAR_PCT = '<td>'+PCT+' %</td>';
|
||
|
} else {
|
||
|
var SOLAR = '<td>0</td>';
|
||
|
var SOLAR_PCT = '<td>--</td>';
|
||
|
}
|
||
|
} else {
|
||
|
var SOLAR = '<td> </td>';
|
||
|
var SOLAR_PCT = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var SOLAR = '';
|
||
|
var SOLAR_PCT = '';
|
||
|
}
|
||
|
// Soil Temperature
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('soil_temp_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Soil<br>Temp.</td>';
|
||
|
EngUnits += '<td>(°F)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.soil_temp_set_1[j] !== null) {
|
||
|
var SOIL_T = '<td>'+Math.round(DATA.STATION[0].OBSERVATIONS.soil_temp_set_1[j])+'</td>';
|
||
|
} else {
|
||
|
var SOIL_T = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var SOIL_T = '';
|
||
|
}
|
||
|
// Road Temperature
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('road_temp_set_2')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Road<br>Temp.</td>';
|
||
|
EngUnits += '<td>(°F)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.road_temp_set_2[j] !== null) {
|
||
|
var ROAD_T = '<td>'+Math.round(DATA.STATION[0].OBSERVATIONS.road_temp_set_2[j])+'</td>';
|
||
|
} else {
|
||
|
var ROAD_T = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var ROAD_T = '';
|
||
|
}
|
||
|
// Road Sub-Surface Temp
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('road_subsurface_tmp_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Road Sub<br>Temp.</td>';
|
||
|
EngUnits += '<td>(°F)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.road_subsurface_tmp_set_1[j] !== null) {
|
||
|
var SROAD_T = '<td>'+Math.round(DATA.STATION[0].OBSERVATIONS.road_subsurface_tmp_set_1[j])+'</td>';
|
||
|
} else {
|
||
|
var SROAD_T = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var SROAD_T = '';
|
||
|
}
|
||
|
// If Accumulated Precip or any increment of precip up to one hour is set,
|
||
|
// we will calculate 1, 3, 6 and 24 hour precip values on our own.
|
||
|
// Synoptic does not consistently return ihigher interval data for those fields
|
||
|
// Even if we get those fields, we will disable any processing of that data down the line.
|
||
|
|
||
|
// Accumulated Precip
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('precip_accum_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Accumulated<br>Precip</td>';
|
||
|
EngUnits += '<td>(inches)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.precip_accum_set_1[j] !== null) {
|
||
|
var ACC_Precip = (DATA.STATION[0].OBSERVATIONS.precip_accum_set_1[j]).toFixed(2);
|
||
|
var ACC_PCPN = '<td><font color="green">'+ACC_Precip+'</font></td>';
|
||
|
} else {
|
||
|
var ACC_PCPN = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var ACC_PCPN = '';
|
||
|
}
|
||
|
// 1 Minute Precip
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('precip_accum_one_minute_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>1 Min.</br>Precip</td>';
|
||
|
EngUnits += '<td>(inches)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.precip_accum_one_minute_set_1[j] !== null) {
|
||
|
var oneMINprecip = (DATA.STATION[0].OBSERVATIONS.precip_accum_one_minute_set_1[j]).toFixed(2);
|
||
|
if (oneMINprecip == '0.001') {
|
||
|
oneMINprecip = 'T';
|
||
|
}
|
||
|
var MIN_1_PCPN = '<td><font color="green">'+oneMINprecip+'</font></td>';
|
||
|
} else {
|
||
|
var MIN_1_PCPN = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var MIN_1_PCPN = '';
|
||
|
}
|
||
|
// 5 Minute Precip
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('precip_accum_five_minute_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>5 Min.</br>Precip</td>';
|
||
|
EngUnits += '<td>(inches)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.precip_accum_five_minute_set_1[j] !== null) {
|
||
|
var fiveMINprecip = (DATA.STATION[0].OBSERVATIONS.precip_accum_five_minute_set_1[j]).toFixed(2);
|
||
|
if (fiveMINprecip == '0.001') {
|
||
|
fiveMINprecip = 'T';
|
||
|
}
|
||
|
var MIN_5_PCPN = '<td><font color="green">'+fiveMINprecip+'</font></td>';
|
||
|
} else {
|
||
|
var MIN_5_PCPN = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var MIN_5_PCPN = '';
|
||
|
}
|
||
|
// 10 Minute Precip
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('precip_accum_ten_minute_set_1')) {
|
||
|
derived = 1;
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>10 Min.</br>Precip</td>';
|
||
|
EngUnits += '<td>(inches)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.precip_accum_ten_minute_set_1[j] !== null) {
|
||
|
var tenMINprecip = (DATA.STATION[0].OBSERVATIONS.precip_accum_ten_minute_set_1[j]).toFixed(2);
|
||
|
var MIN_10_PCPN = '<td><font color="green">'+tenMINprecip+'</font></td>';
|
||
|
} else {
|
||
|
var MIN_10_PCPN = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var MIN_10_PCPN = '';
|
||
|
}
|
||
|
// 15 Minute Precip
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('precip_accum_fifteen_minute_set_1')) {
|
||
|
derived = 1;
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>15 Min.</br>Precip</td>';
|
||
|
EngUnits += '<td>(inches)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.precip_accum_fifteen_minute_set_1[j] !== null) {
|
||
|
var fifteenMINprecip = (DATA.STATION[0].OBSERVATIONS.precip_accum_fifteen_minute_set_1[j]).toFixed(2);
|
||
|
var MIN_15_PCPN = '<td><font color="green">'+fifteenMINprecip+'</font></td>';
|
||
|
} else {
|
||
|
var MIN_15_PCPN = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var MIN_15_PCPN = '';
|
||
|
}
|
||
|
// 30 Minute Precip
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('precip_accum_30_minute_set_1')) {
|
||
|
derived = 1;
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>30 Min.</br>Precip</td>';
|
||
|
EngUnits += '<td>(inches)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.precip_accum_30_minute_set_1[j] !== null) {
|
||
|
var thirtyMINprecip = (DATA.STATION[0].OBSERVATIONS.precip_accum_30_minute_set_1[j]).toFixed(2);
|
||
|
var MIN_30_PCPN = '<td><font color="green">'+thirtyMINprecip+'</font></td>';
|
||
|
} else {
|
||
|
var MIN_30_PCPN = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var MIN_30_PCPN = '';
|
||
|
}
|
||
|
// 1 Hour Precip
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('precip_accum_one_hour_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>1 Hour<br>Precip</td>';
|
||
|
EngUnits += '<td>(inches)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.precip_accum_one_hour_set_1[j] !== null) {
|
||
|
if (parseFloat(DATA.STATION[0].OBSERVATIONS.precip_accum_one_hour_set_1[j]) == '0.001') {
|
||
|
var HR_1_PCPN = '<td><font color="green">T</font></td>';
|
||
|
} else {
|
||
|
var HR_1_PCPN = '<td><font color="green">'+(DATA.STATION[0].OBSERVATIONS.precip_accum_one_hour_set_1[j]).toFixed(2)+'</font></td>';
|
||
|
}
|
||
|
} else {
|
||
|
var HR_1_PCPN = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var HR_1_PCPN = '';
|
||
|
}
|
||
|
// 3 Hour Precip
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('precip_accum_three_hour_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>3 Hour</br>Precip</td>';
|
||
|
EngUnits += '<td>(inches)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.precip_accum_three_hour_set_1[j] !== null) {
|
||
|
if (parseFloat(DATA.STATION[0].OBSERVATIONS.precip_accum_three_hour_set_1[j]) == '0.001') {
|
||
|
var HR_3_PCPN = '<td><font color="green">T</font></td>';
|
||
|
} else {
|
||
|
var HR_3_PCPN = '<td><font color="green">'+(DATA.STATION[0].OBSERVATIONS.precip_accum_three_hour_set_1[j]).toFixed(2)+'</font></td>';
|
||
|
}
|
||
|
} else {
|
||
|
var HR_3_PCPN = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var HR_3_PCPN = '';
|
||
|
}
|
||
|
// 6 Hour Precip
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('precip_accum_six_hour_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>6 Hour<br>Precip</td>';
|
||
|
EngUnits += '<td>(inches)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.precip_accum_six_hour_set_1[j] !== null) {
|
||
|
if (parseFloat(DATA.STATION[0].OBSERVATIONS.precip_accum_six_hour_set_1[j]) == '0.001') {
|
||
|
var HR_6_PCPN = '<td><font color="green">T</font></td>';
|
||
|
} else {
|
||
|
var HR_6_PCPN = '<td><font color="green">'+(DATA.STATION[0].OBSERVATIONS.precip_accum_six_hour_set_1[j]).toFixed(2)+'</font></td>';
|
||
|
}
|
||
|
} else {
|
||
|
var HR_6_PCPN = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var HR_6_PCPN = '';
|
||
|
}
|
||
|
// 24 Hour Precip
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('precip_accum_24_hour_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>24 Hour<br>Precip</td>';
|
||
|
EngUnits += '<td>(inches)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.precip_accum_24_hour_set_1[j] !== null) {
|
||
|
if (parseFloat(DATA.STATION[0].OBSERVATIONS.precip_accum_24_hour_set_1[j]) == '0.001') {
|
||
|
var HR_24_PCPN = '<td><font color="green">T</font></td>';
|
||
|
} else {
|
||
|
var HR_24_PCPN = '<td><font color="green">'+(DATA.STATION[0].OBSERVATIONS.precip_accum_24_hour_set_1[j]).toFixed(2)+'</font></td>';
|
||
|
}
|
||
|
} else {
|
||
|
var HR_24_PCPN = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var HR_24_PCPN = '';
|
||
|
}
|
||
|
// Precip sine midnight
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('precip_accum_since_local_midnight_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Precip<br>Since 12am</td>';
|
||
|
EngUnits += '<td>(°F)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.precip_accum_since_local_midnight_set_1[j] !== null) {
|
||
|
var MIDNIGHT = '<td><font color="green">'+(DATA.STATION[0].OBSERVATIONS.precip_accum_since_local_midnight_set_1[j]).toFixed(2)+'</font></td>';
|
||
|
} else {
|
||
|
var MIDNIGHT = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var MIDNIGHT = '';
|
||
|
}
|
||
|
// Snow Depth
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('snow_depth_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Snow<br>Depth</td>';
|
||
|
EngUnits += '<td>(inches)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.snow_depth_set_1[j] !== null) {
|
||
|
var curSnow = (DATA.STATION[0].OBSERVATIONS.snow_depth_set_1[j]).toFixed(1);
|
||
|
var SNOW_DEPTH = '<td>'+curSnow+'</td>';
|
||
|
} else {
|
||
|
var SNOW_DEPTH = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var SNOW_DEPTH = '';
|
||
|
}
|
||
|
// Snow Interval
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('snow_interval_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Snow<br>Interval</td>';
|
||
|
EngUnits += '<td>(inches)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.snow_interval_set_1[j] !== null) {
|
||
|
var SNOW_INTERVAL = '<td>'+(DATA.STATION[0].OBSERVATIONS.snow_interval_set_1[j]).toFixed(1)+'</td>';
|
||
|
} else {
|
||
|
var SNOW_INTERVAL = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var SNOW_INTERVAL = '';
|
||
|
}
|
||
|
// Snow Water Equivalent
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('snow_water_equiv_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Snow/Water<br>Equivalent</td>';
|
||
|
EngUnits += '<td>(inches)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.snow_water_equiv_set_1[j] !== null) {
|
||
|
var SWE = '<td>'+(DATA.STATION[0].OBSERVATIONS.snow_water_equiv_set_1[j]).toFixed(2)+'</td>';
|
||
|
} else {
|
||
|
var SWE = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var SWE = '';
|
||
|
}
|
||
|
// 6 Hour Max T
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('air_temp_high_6_hour_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>6 Hr<br>Max</td>';
|
||
|
EngUnits += '<td>(°F)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.air_temp_high_6_hour_set_1[j] !== null) {
|
||
|
var HR6_MAXT = '<td><font color="red">'+Math.round(DATA.STATION[0].OBSERVATIONS.air_temp_high_6_hour_set_1[j])+'</font></td>';
|
||
|
} else {
|
||
|
var HR6_MAXT = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var HR6_MAXT = '';
|
||
|
}
|
||
|
// 6 Hour Min T
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('air_temp_low_6_hour_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>6 Hr<br>Min</td>';
|
||
|
EngUnits += '<td>(°F)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.air_temp_low_6_hour_set_1[j] !== null) {
|
||
|
var HR6_MINT = '<td><font color="blue">'+Math.round(DATA.STATION[0].OBSERVATIONS.air_temp_low_6_hour_set_1[j])+'</font></td>';
|
||
|
} else {
|
||
|
var HR6_MINT = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var HR6_MINT = '';
|
||
|
}
|
||
|
// 24 Hour Max T
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('air_temp_high_24_hour_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>24 Hr<br>Max</td>';
|
||
|
EngUnits += '<td>(°F)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.air_temp_high_24_hour_set_1[j] !== null) {
|
||
|
var HR24_MAXT = '<td><font color="red">'+Math.round(DATA.STATION[0].OBSERVATIONS.air_temp_high_24_hour_set_1[j])+'</font></td>';
|
||
|
} else {
|
||
|
var HR24_MAXT = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var HR24_MAXT = '';
|
||
|
}
|
||
|
// 24 Hour Min T
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('air_temp_low_24_hour_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>24 Hr<br>Min</td>';
|
||
|
EngUnits += '<td>(°F)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.air_temp_low_24_hour_set_1[j] !== null) {
|
||
|
var HR24_MINT = '<td><font color="blue">'+Math.round(DATA.STATION[0].OBSERVATIONS.air_temp_low_24_hour_set_1[j])+'</font></td>';
|
||
|
} else {
|
||
|
var HR24_MINT = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var HR24_MINT = '';
|
||
|
}
|
||
|
// Water Temperature
|
||
|
if (DATA.STATION[0].OBSERVATIONS.hasOwnProperty('T_water_temp_set_1')) {
|
||
|
if (j == 0) {
|
||
|
header1 += '<td>Water<br>Temp.</td>';
|
||
|
EngUnits += '<td>(°F)</td>';
|
||
|
}
|
||
|
if (DATA.STATION[0].OBSERVATIONS.T_water_temp_set_1[j] !== null) {
|
||
|
var WATER_T = '<td>'+Math.round(DATA.STATION[0].OBSERVATIONS.T_water_temp_set_1[j])+'</td>';
|
||
|
} else {
|
||
|
var WATER_T = '<td> </td>';
|
||
|
}
|
||
|
} else {
|
||
|
var WATER_T = '';
|
||
|
}
|
||
|
// Append one row of data to the stream
|
||
|
tableData += '<tr><td>'+month+' '+day+', '+hours+':'+minutes+' '+ampm+'</td>'+TEMP_F+DEWPOINT+RH_PCT+WC+WIND_DIR+WIND_SPD+FUEL_T+FUEL_PCT+VISIBILITY+WEATHER+SKY_COND+P+SEALEVEL+ALTIMTER+STATION_P+SOLAR+SOLAR_PCT+SOIL_T+ROAD_T+SROAD_T+ACC_PCPN+MIN_1_PCPN+MIN_5_PCPN+MIN_10_PCPN+MIN_15_PCPN+MIN_30_PCPN+HR_1_PCPN+HR_3_PCPN+HR_6_PCPN+HR_24_PCPN+MIDNIGHT+SNOW_DEPTH+SNOW_INTERVAL+SWE+HR6_MAXT+HR6_MINT+HR24_MAXT+HR24_MINT+WATER_T+'</tr>';
|
||
|
} // Successful return of data
|
||
|
var header0 = '<div id="SITE"><p>Weather conditions for:<br>'+stnNAM+', '+ state +' ('+network+' - <a href="https://www.weather.gov/'+cwa+'">'+cwa+'</a>) <br>Elev: '+stnELE+' ft; Lat/Lon: '+stnLAT+'/'+stnLON+'<br><font color="green"><div onclick="getCalYearPrecip(\''+SITE+'\',\'english\');" id="CAL_YEAR"><u>Get Yearly Precip Total (non QA/QC\'d data) </u></div><div onclick="getH2OYearPrecip(\''+SITE+'\',\'english\');" id="H2O_YEAR"><u>Get Water Year Precip Total (non QA/QC\'d data): </u></div></font></div><br> ';
|
||
|
$('#OBS').html(header0 + header1 +'</tr>' + EngUnits + '</tr>' + tableData+'</tbody></table>');
|
||
|
} else {
|
||
|
// Station has not reported in the specified number of hours
|
||
|
$('#OBS').html('<h2>'+SITE +' has no data available for the requested time period</h2>');
|
||
|
}
|
||
|
} else if (DATA.SUMMARY.RESPONSE_MESSAGE == 'No stations found for this request.') {
|
||
|
// Station ID not valid
|
||
|
$('#OBS').html('<h2>'+SITE +' is not a valid station identifier.</h2>');
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
|
||
|
function getWeatherCode(WEATHER) {
|
||
|
// Documentation: https://blog.synopticlabs.org/blog/2016/09/26/weather-condition-codes.html
|
||
|
// Coloring from MesoWest:
|
||
|
// '/TS|SQ|FC/ <font color=red><b>$r_wx</b></font></td>"; }
|
||
|
// '/RA|SN|GS|GR <font color=green><b>$r_wx</b></font></td>"; }
|
||
|
// '/FG|FU|BS/ <font color=#FF00FF><b>$r_wx</b></font></td>"; }
|
||
|
// '/BR|HZ/ <font color=orange><b>$r_wx</b></font></td>"; }
|
||
|
if (WEATHER == -3) {
|
||
|
HTML = '<font color="red">FC</font>';
|
||
|
DESC = 'Water Spout';
|
||
|
} else if (WEATHER == -2) {
|
||
|
HTML = '<font color="red">FC</font>';
|
||
|
DESC = 'Funnel Cloud';
|
||
|
} else if (WEATHER == -1) {
|
||
|
HTML = '<font color="red">FC</font>';
|
||
|
DESC = 'Tornado';
|
||
|
} else if (WEATHER == 1) {
|
||
|
HTML = '<font color="green">RA</font>';
|
||
|
DESC = 'Rain';
|
||
|
} else if (WEATHER == 2) {
|
||
|
HTML = '<font color="green">DZ</font>';
|
||
|
DESC = 'Drizzle';
|
||
|
} else if (WEATHER == 3) {
|
||
|
HTML = '<font color="green">SN</font>';
|
||
|
DESC = 'Snow';
|
||
|
} else if (WEATHER == 4) {
|
||
|
HTML = '<font color="green">GR</font>';
|
||
|
DESC = 'Hail';
|
||
|
} else if (WEATHER == 5) {
|
||
|
HTML = '<font color="red">TS</font>';
|
||
|
DESC = 'Thunder';
|
||
|
} else if (WEATHER == 6) {
|
||
|
HTML = '<font color="orange">HZ</font>';
|
||
|
DESC = 'Haze';
|
||
|
} else if (WEATHER == 7) {
|
||
|
HTML = '<font color="#FF00FF">FU</font>';
|
||
|
DESC = 'Smoke';
|
||
|
} else if (WEATHER == 8) {
|
||
|
HTML = '<font color="#FF00FF">DU</font>';
|
||
|
DESC = 'Dust';
|
||
|
} else if (WEATHER == 9) {
|
||
|
HTML = '<font color="#FF00FF">FG</font>';
|
||
|
DESC = 'Fog';
|
||
|
} else if (WEATHER == 10) {
|
||
|
HTML = '<font color="red">SQ</font>';
|
||
|
DESC = 'Squalls';
|
||
|
} else if (WEATHER == 11) {
|
||
|
HTML = '<font color="#FF00FF">VA</font>';
|
||
|
DESC = 'Volcanic Ash';
|
||
|
} else if (WEATHER == 13) {
|
||
|
HTML = '<font color="green">-RA</font>';
|
||
|
DESC = 'Lt rain';
|
||
|
} else if (WEATHER == 14) {
|
||
|
HTML = '<font color="green">+RA</font>';
|
||
|
DESC = 'Hvy rain';
|
||
|
} else if (WEATHER == 15) {
|
||
|
HTML = '<font color="red">ZR</font>';
|
||
|
DESC = 'Freezing rain';
|
||
|
} else if (WEATHER == 16) {
|
||
|
HTML = '<font color=green"">SH</font>';
|
||
|
DESC = 'Shwrs';
|
||
|
} else if (WEATHER == 17) {
|
||
|
HTML = '<font color="green">-DZ</font>';
|
||
|
DESC = 'Lt drizzle';
|
||
|
} else if (WEATHER == 18) {
|
||
|
HTML = '<font color="green">+DZ</font>';
|
||
|
DESC = 'Hvy drizzle';
|
||
|
} else if (WEATHER == 19) {
|
||
|
HTML = '<font color="green">FZDZ</font>';
|
||
|
DESC = 'Freezing drizzle';
|
||
|
} else if (WEATHER == 20) {
|
||
|
HTML = '<font color="green">-SN</font>';
|
||
|
DESC = 'Lt snow';
|
||
|
} else if (WEATHER == 21) {
|
||
|
HTML = '<font color="green">+SN</font>';
|
||
|
DESC = 'Hvy snow';
|
||
|
} else if (WEATHER == 22) {
|
||
|
HTML = '<font color="green">SN</font>';
|
||
|
DESC = 'Snow';
|
||
|
} else if (WEATHER == 23) {
|
||
|
HTML = '<font color="green">PL</font>';
|
||
|
DESC = 'Ice pellets';
|
||
|
} else if (WEATHER == 24) {
|
||
|
HTML = '<font color="green">SG</font>';
|
||
|
DESC = 'Snow grains';
|
||
|
} else if (WEATHER == 25) {
|
||
|
HTML = '<font color="green">GS</font>';
|
||
|
DESC = 'Snow pellets';
|
||
|
} else if (WEATHER == 26) {
|
||
|
HTML = '<font color="green">-GR</font>';
|
||
|
DESC = 'Lt hail';
|
||
|
} else if (WEATHER == 27) {
|
||
|
HTML = '<font color="green">+GR</font>';
|
||
|
DESC = 'Hvy hail';
|
||
|
} else if (WEATHER == 28) {
|
||
|
HTML = '<font color="red">-TS</font>';
|
||
|
DESC = 'Lt thunderstorm';
|
||
|
} else if (WEATHER == 29) {
|
||
|
HTML = '<font color="red">+TS</font>';
|
||
|
DESC = 'Hvy thunderstorm';
|
||
|
} else if (WEATHER == 30) {
|
||
|
HTML = '<font color="#FF00FF">FZFG</font>';
|
||
|
DESC = 'Freezing Fog';
|
||
|
} else if (WEATHER == 31) {
|
||
|
HTML = '<font color="orange">BR</font>';
|
||
|
DESC = 'Mist';
|
||
|
} else if (WEATHER == 32) {
|
||
|
HTML = '<font color="orange">BLSN</font>';
|
||
|
DESC = 'Blowing snow';
|
||
|
} else if (WEATHER == 33) {
|
||
|
HTML = '<font color="orange">BLDU</font>';
|
||
|
DESC = 'Blowing dust';
|
||
|
} else if (WEATHER == 34) {
|
||
|
HTML = '<font color="orange">BLPY</font>';
|
||
|
DESC = 'Blowing spray';
|
||
|
} else if (WEATHER == 35) {
|
||
|
HTML = '<font color="orange">BLSA</font>';
|
||
|
DESC = 'Blowing sand';
|
||
|
} else if (WEATHER == 36) {
|
||
|
HTML = '<font color="green">IC</font>';
|
||
|
DESC = 'Ice crystals';
|
||
|
} else if (WEATHER == 37) {
|
||
|
HTML = '<font color="green">IC</font>';
|
||
|
DESC = 'Ice needles';
|
||
|
} else if (WEATHER == 38) {
|
||
|
HTML = '<font color="green">-GR</font>';
|
||
|
DESC = 'Lt hail';
|
||
|
} else if (WEATHER == 39) {
|
||
|
HTML = '<font color="orange">FUHZ</font>';
|
||
|
DESC = 'Smoke, haze';
|
||
|
} else if (WEATHER == 40) {
|
||
|
HTML = '<font color="orange">DU</font>';
|
||
|
DESC = 'Dust whirls';
|
||
|
} else if (WEATHER == 41) {
|
||
|
HTML = 'UP';
|
||
|
DESC = 'Unknown precipitation';
|
||
|
} else if (WEATHER == 49) {
|
||
|
HTML = '<font color="red">-ZR</font>';
|
||
|
DESC = 'Lt freezing rain';
|
||
|
} else if (WEATHER == 50) {
|
||
|
HTML = '<font color="red">+ZR</font>';
|
||
|
DESC = 'Heavy freezing rain';
|
||
|
} else if (WEATHER == 51) {
|
||
|
HTML = '<font color="green">-SH</font>';
|
||
|
DESC = 'Lt shwrs';
|
||
|
} else if (WEATHER == 52) {
|
||
|
HTML = '<font color="green">+SH</font>';
|
||
|
DESC = 'Hvy shwrs';
|
||
|
} else if (WEATHER == 53) {
|
||
|
HTML = '<font color="green">-FZDZ</font>';
|
||
|
DESC = 'Lt freezing drizzle';
|
||
|
} else if (WEATHER == 54) {
|
||
|
HTML = '<font color="green">+FZDZ</font>';
|
||
|
DESC = 'Hvy freezing drizzle';
|
||
|
} else if (WEATHER == 55) {
|
||
|
HTML = '<font color="green">-SN</font>';
|
||
|
DESC = 'Lt snow';
|
||
|
} else if (WEATHER == 56) {
|
||
|
HTML = '<font color="green">+SN</font>';
|
||
|
DESC = 'Hvy snow';
|
||
|
} else if (WEATHER == 57) {
|
||
|
HTML = '<font color="green">-PL</font>';
|
||
|
DESC = 'Lt ice pellets';
|
||
|
} else if (WEATHER == 58) {
|
||
|
HTML = '<font color="green">+PL</font>';
|
||
|
DESC = 'Hvy ice pellets';
|
||
|
} else if (WEATHER == 59) {
|
||
|
HTML = '<font color="green">-SG</font>';
|
||
|
DESC = 'Lt snow grains';
|
||
|
} else if (WEATHER == 60) {
|
||
|
HTML = '<font color="green">+SG</font>';
|
||
|
DESC = 'Heavy snow grains';
|
||
|
} else if (WEATHER == 61) {
|
||
|
HTML = '<font color="green">-GS</font>';
|
||
|
DESC = 'Lt snow pellets';
|
||
|
} else if (WEATHER == 62) {
|
||
|
HTML = '<font color="green">+GS</font>';
|
||
|
DESC = 'Hvy snow pellets';
|
||
|
} else if (WEATHER == 63) {
|
||
|
HTML = '<font color="green">PL</font>';
|
||
|
DESC = 'Ice pellets';
|
||
|
} else if (WEATHER == 64) {
|
||
|
HTML = '<font color="green">-IC</font>';
|
||
|
DESC = 'Lt ice crystals';
|
||
|
} else if (WEATHER == 65) {
|
||
|
HTML = '<font color="green">+IC</font>';
|
||
|
DESC = 'Hvy ice crystals';
|
||
|
} else if (WEATHER == 66) {
|
||
|
HTML = '<font color="red">TSRA</font>';
|
||
|
DESC = 'Thunder shwr';
|
||
|
} else if (WEATHER == 67) {
|
||
|
HTML = '<font color="green">GS</font>';
|
||
|
DESC = 'Snow pellets';
|
||
|
} else if (WEATHER == 68) {
|
||
|
HTML = '<font color="orange">+BLDU</font>';
|
||
|
DESC = 'Hvy blowing dust';
|
||
|
} else if (WEATHER == 69) {
|
||
|
HTML = '<font color="orange">+BLSA</font>';
|
||
|
DESC = 'Hvy blowing sand';
|
||
|
} else if (WEATHER == 69) {
|
||
|
HTML = '<font color="orange">+BLSN</font>';
|
||
|
DESC = 'Hvy blowing snow';
|
||
|
} else if (WEATHER == 75) {
|
||
|
HTML = '<font color="green">-PL</font>';
|
||
|
DESC = 'Lt ice pellets';
|
||
|
} else if (WEATHER == 76) {
|
||
|
HTML = '<font color="green">+PL</font>';
|
||
|
DESC = 'Hvy ice pellets';
|
||
|
} else if (WEATHER == 77) {
|
||
|
HTML = '<font color="red">-TSRA</font>';
|
||
|
DESC = 'Lt thunder shwr';
|
||
|
} else if (WEATHER == 78) {
|
||
|
HTML = '<font color="red">+TSRA</font>';
|
||
|
DESC = 'Hvy thunder shwr';
|
||
|
}
|
||
|
return(DESC);
|
||
|
}
|
||
|
// Need to figure out
|
||
|
function calcSolarPCT(dattim,xlat,xlon) {
|
||
|
//console.log(dattim,xlat,xlon)
|
||
|
var utcMoment = moment.utc(dattim);
|
||
|
var d = new Date(utcMoment.format());
|
||
|
var rd = new Date(utcMoment.format());
|
||
|
rd.setHours(rd.getHours() - 1);
|
||
|
var hours = utcMoment.format("H");
|
||
|
var minutes = d.getMinutes();
|
||
|
minutes = minutes < 10 ? '0' + minutes : minutes;
|
||
|
var solpot = 0;
|
||
|
while (rd < d) {
|
||
|
var start = new Date(rd.getFullYear(), 0, 0);
|
||
|
var diff = rd - start;
|
||
|
var oneDay = 1000 * 60 * 60 * 24;
|
||
|
var julday = Math.floor(diff / oneDay) - 1;
|
||
|
var hr = rd.getHours();
|
||
|
hr = utcMoment.format("H") - 1;
|
||
|
var min = rd.getMinutes();
|
||
|
min = utcMoment.format('m');
|
||
|
xt24 = hr + (min / 60.);
|
||
|
|
||
|
var degrad = 0.017453293;
|
||
|
var dpd = 0.986301;
|
||
|
var solset = -999;
|
||
|
var sinob = Math.sin(23.5 * degrad);
|
||
|
var julian = (julday) + hr;
|
||
|
var xlong;
|
||
|
if (julian > 80.) {
|
||
|
xlong = dpd * (julian - 80.);
|
||
|
} else {
|
||
|
xlong = dpd * (julian + 285.);
|
||
|
}
|
||
|
xlong = xlong * degrad;
|
||
|
declin = Math.asin(sinob * Math.sin(xlong));
|
||
|
decdeg = declin / degrad;
|
||
|
|
||
|
djul = julian * 360. / 365.;
|
||
|
rjul = djul * degrad;
|
||
|
eccfac = 1.000110 + 0.034221 * Math.cos(rjul) + 0.00128 * Math.sin(rjul) + 0.000719 * Math.cos(2 * rjul) + 0.000077 * Math.sin(2 * rjul);
|
||
|
solcon = 1370. * eccfac;
|
||
|
tlocap = xt24 + (xlon / 15.);
|
||
|
omega = 15. * (tlocap - 12.) * degrad;
|
||
|
xxlat = xlat * degrad;
|
||
|
fracsc = Math.sin(declin) * Math.sin(xxlat) + Math.cos(declin) * Math.cos(xxlat) * Math.cos(omega);
|
||
|
solpot = solpot + (fracsc * solcon);
|
||
|
utcMoment.add(10, 'm');
|
||
|
rd = new Date(rd.getTime() + 10 * 60000);
|
||
|
}
|
||
|
solpot = solpot / 6.;
|
||
|
// return solpot.toFixed(0);
|
||
|
if (solpot > 0) {
|
||
|
return(solpot.toFixed(0));
|
||
|
} else {
|
||
|
return '--';
|
||
|
}
|
||
|
}
|
||
|
function getCalYearPrecip(SITE,units) {
|
||
|
const d = new Date();
|
||
|
var year = d.getFullYear();
|
||
|
$.getJSON('https://api.synopticdata.com/v2/stations/precip?stid='+SITE+'&start='+year+'01010000&end=210001010000&pmode=totals&token=d8c6aee36a994f90857925cea26934be&units='+units, function (DATA) {
|
||
|
if (DATA.STATION[0]) {
|
||
|
var VALUE = DATA.STATION[0].OBSERVATIONS.precipitation[0].total.toFixed(2);
|
||
|
$('#CAL_YEAR').html('<font color="green">Current calendar year total (since January 1, '+year+'): ' +VALUE +' '+ DATA.UNITS.precipitation.toLowerCase()+'</font>');
|
||
|
} else {
|
||
|
$('#CAL_YEAR').html('<font color="black">Data not available at this location.</font>');
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
|
||
|
function getH2OYearPrecip(SITE,units) {
|
||
|
var d = new Date();
|
||
|
var year = d.getFullYear();
|
||
|
var month = d.getMonth();
|
||
|
month = parseInt(month);
|
||
|
if (month < 9) {
|
||
|
year = parseInt(year) - 1;
|
||
|
}
|
||
|
$.getJSON('https://api.synopticdata.com/v2/stations/precip?stid='+SITE+'&start='+year+'10010000&end=210001010000&pmode=totals&token=d8c6aee36a994f90857925cea26934be&units='+units, function (DATA) {
|
||
|
if (DATA.STATION[0]) {
|
||
|
var VALUE = DATA.STATION[0].OBSERVATIONS.precipitation[0].total.toFixed(2);
|
||
|
$('#H2O_YEAR').html('<font color="green">Current water year total (since October 1, '+year+'): ' +VALUE +' '+ DATA.UNITS.precipitation.toLowerCase()+'</font>');
|
||
|
} else {
|
||
|
$('#H2O_YEAR').html('<font color="black">Data not available at this location.</font>');
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
|