1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745
|
<?php /* File: CU-defs.php
Purpose: provide a bridge to naming of weather variables from the native Cumulus software package to Weather-Display names used in common scripts like ajax-dashboard.php and ajax-gizmo.php
Author: Ken True - webmaster@saratoga-weather.org
(created by gen-defs.php - V1.08 - 12-Jan-2013) Generated on 2013-01-14 11:01:26 PST
//Version CU-defs.php - V1.11 - 13-May-2020
*/ // --------------------------------------------------------------------------
// allow viewing of generated source
if (isset($_REQUEST["sce"]) and strtolower($_REQUEST["sce"]) == "view" ) { //--self downloader -- $filenameReal = __FILE__; $download_size = filesize($filenameReal); header("Pragma: public"); header("Cache-Control: private"); header("Cache-Control: no-cache, must-revalidate"); header("Content-type: text/plain"); header("Accept-Ranges: bytes"); header("Content-Length: $download_size"); header("Connection: close"); readfile($filenameReal); exit; } $WXsoftware = 'CU'; // this has WD $varnames = $WX['CU-varnames']; equivalents $uomtemp = $WX['tempunit']; $uombaro = $WX['pressunit']; $uomwind = $WX['windunit']; $uomrain = $WX['rainunit']; $uomdistance = $WX['windrununit']; $time = substr($WX['time'],0,5); // calculated value $date = $WX['date']; $sunrise = $WX['sunrise']; $sunset = $WX['sunset']; $moonrise = $WX['moonrise']; $moonset = $WX['moonset']; $moonphase = $WX['MoonPercentAbs']; $hoursofpossibledaylight = $WX['daylength']; $stationlatitude = $WX['latitude']; $stationlongitude = $WX['longitude']; $windowsuptime = $WX['SystemUpTime']; $freememory = $WX['MemoryStatus']; $Startimedate = $WX['ProgramUpTime']; $wdversion = $WX['version'].'-b'.$WX['build']; // calculated value $wdbuild = $WX['build']; if(substr($wdversion,0,1) > '1') {$SITE['WXsoftwareLongName'] .= 'MX'; } $timeofnextupdate = date('H:i',strtotime(CUfixupTime($time))+$WX['interval']*60); // calculated value $temperature = $WX['temp']; $tempnodp = round(preg_replace('|,|','.',$WX['temp']),0); // calculated value $humidity = $WX['hum']; $dewpt = $WX['dew']; $maxtemp = $WX['tempTH']; $maxtempt = $WX['TtempTH']; $mintemp = $WX['tempTL']; $mintempt = $WX['TtempTL']; $heati = $WX['heatindex']; $heatinodp = round(preg_replace('|,|','.',$WX['heatindex']),0); // calculated value $windch = $WX['wchill']; $windchnodp = round(preg_replace('|,|','.',$WX['wchill']),0); // calculated value $humidex = $WX['humidex']; $apparenttemp = $WX['apptemp']; $tempchangehour = $WX['temptrend']; $maxtempyest = $WX['tempYH']; $maxtempyestt = $WX['TtempYH']; $mintempyest = $WX['tempYL']; $mintempyestt = $WX['TtempYL']; if(isset($WX['RecentOutsideTemp h=24'])) { $temp24hoursago = $WX['RecentOutsideTemp h=24']; } // beta tag if(isset($WX['RecentHumidity m=60'])){$humchangelasthour=$WX['hum']-$WX['RecentHumidity m=60'];} // conditional value if(isset($WX['RecentDewPoint m=60'])){$dewchangelasthour=$WX['dew']-$WX['RecentDewPoint m=60'];} // conditional value if(isset($WX['RecentPressure m=60'])){$barochangelasthour=$WX['press']-$WX['RecentPressure m=60'];} // conditional value $avgspd = $WX['wspeed']; $gstspd = $WX['wgust']; $maxgst = $WX['wgustTM']; $maxgstt = $WX['TwgustTM']; $dirlabel = $WX['wdir']; $baro = $WX['press']; $trend = $WX['presstrendval']; $pressuretrendname = $WX['presstrend']; $pressuretrendname3hour = $WX['presstrendenglish']; $vpforecasttext = $WX['wsforecast']; $dayrn = $WX['rfall']; $monthrn = $WX['rmonth']; $yearrn = $WX['ryear']; $currentrainratehr = $WX['rrate']; $maxrainrate = $WX['rrateTM']; $maxrainratehr = $WX['rrateTM']; $maxrainratetime = $WX['TrrateTM']; $yesterdayrain = $WX['rfallY']; $VPsolar = $WX['SolarRad']; $VPuv = $WX['UV']; if(isset($WX['solarTH'])) { $highsolar = $WX['solarTH']; } // beta tag if(isset($WX['UVTH'])) { $highuv = $WX['UVTH']; } // beta tag if(isset($WX['TsolarTH'])) { $highsolartime = $WX['TsolarTH']; } // beta tag if(isset($WX['TUVTH'])) { $highuvtime = $WX['TUVTH']; } // beta tag if(isset($WX['UVYH'])) { $highuvyest = $WX['UVYH']; } // beta tag if(isset($WX['TUVYH'])) { $highuvyesttime = $WX['TUVYH']; } // beta tag $mrecordwindgust = $WX['MonthGustH']; list($mrecordhighgustday,$mrecordhighgustmonth,$mrecordhighgustyear)=CU_getRecordDate($WX['MonthGustHD'],$WX['year']); // calculated value $snownowin = $WX['snowdepth']; $snownowcm = $WX['snowdepth']; $temp0minuteago = $WX['temp']; $wind0minuteago = $WX['wspeed']; $gust0minuteago = $WX['wgust']; $dir0minuteago = $WX['wdir']; $hum0minuteago = $WX['hum']; $dew0minuteago = $WX['dew']; $baro0minuteago = $WX['press']; $rain0minuteago = $WX['rfall']; $VPsolar0minuteago = $WX['SolarRad']; $VPuv0minuteago = $WX['UV']; if(isset($WX['RecentOutsideTemp m=5'])) { $temp5minuteago = $WX['RecentOutsideTemp m=5']; } // beta tag if(isset($WX['RecentWindSpeed m=5'])) { $wind5minuteago = $WX['RecentWindSpeed m=5']; } // beta tag if(isset($WX['RecentWindGust m=5'])) { $gust5minuteago = $WX['RecentWindGust m=5']; } // beta tag if(isset($WX['RecentWindAvgDir m=5'])) {$dir5minuteago = CU_deg2dir($WX['RecentWindAvgDir m=5']); } // conditional value if(isset($WX['RecentHumidity m=5'])) { $hum5minuteago = $WX['RecentHumidity m=5']; } // beta tag if(isset($WX['RecentDewPoint m=5'])) { $dew5minuteago = $WX['RecentDewPoint m=5']; } // beta tag if(isset($WX['RecentPressure m=5'])) { $baro5minuteago = $WX['RecentPressure m=5']; } // beta tag if(isset($WX['RecentRainToday m=5'])) { $rain5minuteago = $WX['RecentRainToday m=5']; } // beta tag if(isset($WX['RecentSolarRad m=5'])) { $VPsolar5minuteago = $WX['RecentSolarRad m=5']; } // beta tag if(isset($WX['RecentUV m=5'])) { $VPuv5minuteago = $WX['RecentUV m=5']; } // beta tag if(isset($WX['RecentOutsideTemp m=10'])) { $temp10minuteago = $WX['RecentOutsideTemp m=10']; } // beta tag if(isset($WX['RecentWindSpeed m=10'])) { $wind10minuteago = $WX['RecentWindSpeed m=10']; } // beta tag if(isset($WX['RecentWindGust m=10'])) { $gust10minuteago = $WX['RecentWindGust m=10']; } // beta tag if(isset($WX['RecentWindAvgDir m=10'])) {$dir10minuteago = CU_deg2dir($WX['RecentWindAvgDir m=10']); } // conditional value if(isset($WX['RecentHumidity m=10'])) { $hum10minuteago = $WX['RecentHumidity m=10']; } // beta tag if(isset($WX['RecentDewPoint m=10'])) { $dew10minuteago = $WX['RecentDewPoint m=10']; } // beta tag if(isset($WX['RecentPressure m=10'])) { $baro10minuteago = $WX['RecentPressure m=10']; } // beta tag if(isset($WX['RecentRainToday m=10'])) { $rain10minuteago = $WX['RecentRainToday m=10']; } // beta tag if(isset($WX['RecentSolarRad m=10'])) { $VPsolar10minuteago = $WX['RecentSolarRad m=10']; } // beta tag if(isset($WX['RecentUV m=10'])) { $VPuv10minuteago = $WX['RecentUV m=10']; } // beta tag if(isset($WX['RecentOutsideTemp m=15'])) { $temp15minuteago = $WX['RecentOutsideTemp m=15']; } // beta tag if(isset($WX['RecentWindSpeed m=15'])) { $wind15minuteago = $WX['RecentWindSpeed m=15']; } // beta tag if(isset($WX['RecentWindGust m=15'])) { $gust15minuteago = $WX['RecentWindGust m=15']; } // beta tag if(isset($WX['RecentWindAvgDir m=15'])) {$dir15minuteago = CU_deg2dir($WX['RecentWindAvgDir m=15']); } // conditional value if(isset($WX['RecentHumidity m=15'])) { $hum15minuteago = $WX['RecentHumidity m=15']; } // beta tag if(isset($WX['RecentDewPoint m=15'])) { $dew15minuteago = $WX['RecentDewPoint m=15']; } // beta tag if(isset($WX['RecentPressure m=15'])) { $baro15minuteago = $WX['RecentPressure m=15']; } // beta tag if(isset($WX['RecentRainToday m=15'])) { $rain15minuteago = $WX['RecentRainToday m=15']; } // beta tag if(isset($WX['RecentSolarRad m=15'])) { $VPsolar15minuteago = $WX['RecentSolarRad m=15']; } // beta tag if(isset($WX['RecentUV m=15'])) { $VPuv15minuteago = $WX['RecentUV m=15']; } // beta tag if(isset($WX['RecentOutsideTemp m=20'])) { $temp20minuteago = $WX['RecentOutsideTemp m=20']; } // beta tag if(isset($WX['RecentWindSpeed m=20'])) { $wind20minuteago = $WX['RecentWindSpeed m=20']; } // beta tag if(isset($WX['RecentWindGust m=20'])) { $gust20minuteago = $WX['RecentWindGust m=20']; } // beta tag if(isset($WX['RecentWindAvgDir m=20'])) {$dir20minuteago = CU_deg2dir($WX['RecentWindAvgDir m=20']); } // conditional value if(isset($WX['RecentHumidity m=20'])) { $hum20minuteago = $WX['RecentHumidity m=20']; } // beta tag if(isset($WX['RecentDewPoint m=20'])) { $dew20minuteago = $WX['RecentDewPoint m=20']; } // beta tag if(isset($WX['RecentPressure m=20'])) { $baro20minuteago = $WX['RecentPressure m=20']; } // beta tag if(isset($WX['RecentRainToday m=20'])) { $rain20minuteago = $WX['RecentRainToday m=20']; } // beta tag if(isset($WX['RecentSolarRad m=20'])) { $VPsolar20minuteago = $WX['RecentSolarRad m=20']; } // beta tag if(isset($WX['RecentUV m=20'])) { $VPuv20minuteago = $WX['RecentUV m=20']; } // beta tag if(isset($WX['RecentOutsideTemp m=30'])) { $temp30minuteago = $WX['RecentOutsideTemp m=30']; } // beta tag if(isset($WX['RecentWindSpeed m=30'])) { $wind30minuteago = $WX['RecentWindSpeed m=30']; } // beta tag if(isset($WX['RecentWindGust m=30'])) { $gust30minuteago = $WX['RecentWindGust m=30']; } // beta tag if(isset($WX['RecentWindAvgDir m=30'])) {$dir30minuteago = CU_deg2dir($WX['RecentWindAvgDir m=30']); } // conditional value if(isset($WX['RecentHumidity m=30'])) { $hum30minuteago = $WX['RecentHumidity m=30']; } // beta tag if(isset($WX['RecentDewPoint m=30'])) { $dew30minuteago = $WX['RecentDewPoint m=30']; } // beta tag if(isset($WX['RecentPressure m=30'])) { $baro30minuteago = $WX['RecentPressure m=30']; } // beta tag if(isset($WX['RecentRainToday m=30'])) { $rain30minuteago = $WX['RecentRainToday m=30']; } // beta tag if(isset($WX['RecentSolarRad m=30'])) { $VPsolar30minuteago = $WX['RecentSolarRad m=30']; } // beta tag if(isset($WX['RecentUV m=30'])) { $VPuv30minuteago = $WX['RecentUV m=30']; } // beta tag if(isset($WX['RecentOutsideTemp m=45'])) { $temp45minuteago = $WX['RecentOutsideTemp m=45']; } // beta tag if(isset($WX['RecentWindSpeed m=45'])) { $wind45minuteago = $WX['RecentWindSpeed m=45']; } // beta tag if(isset($WX['RecentWindGust m=45'])) { $gust45minuteago = $WX['RecentWindGust m=45']; } // beta tag if(isset($WX['RecentWindAvgDir m=45'])) {$dir45minuteago = CU_deg2dir($WX['RecentWindAvgDir m=45']); } // conditional value if(isset($WX['RecentHumidity m=45'])) { $hum45minuteago = $WX['RecentHumidity m=45']; } // beta tag if(isset($WX['RecentDewPoint m=45'])) { $dew45minuteago = $WX['RecentDewPoint m=45']; } // beta tag if(isset($WX['RecentPressure m=45'])) { $baro45minuteago = $WX['RecentPressure m=45']; } // beta tag if(isset($WX['RecentRainToday m=45'])) { $rain45minuteago = $WX['RecentRainToday m=45']; } // beta tag if(isset($WX['RecentSolarRad m=45'])) { $VPsolar45minuteago = $WX['RecentSolarRad m=45']; } // beta tag if(isset($WX['RecentUV m=45'])) { $VPuv45minuteago = $WX['RecentUV m=45']; } // beta tag if(isset($WX['RecentOutsideTemp m=60'])) { $temp60minuteago = $WX['RecentOutsideTemp m=60']; } // beta tag if(isset($WX['RecentWindSpeed m=60'])) { $wind60minuteago = $WX['RecentWindSpeed m=60']; } // beta tag if(isset($WX['RecentWindGust m=60'])) { $gust60minuteago = $WX['RecentWindGust m=60']; } // beta tag if(isset($WX['RecentWindAvgDir m=60'])) {$dir60minuteago = CU_deg2dir($WX['RecentWindAvgDir m=60']); } // conditional value if(isset($WX['RecentHumidity m=60'])) { $hum60minuteago = $WX['RecentHumidity m=60']; } // beta tag if(isset($WX['RecentDewPoint m=60'])) { $dew60minuteago = $WX['RecentDewPoint m=60']; } // beta tag if(isset($WX['RecentPressure m=60'])) { $baro60minuteago = $WX['RecentPressure m=60']; } // beta tag if(isset($WX['RecentRainToday m=60'])) { $rain60minuteago = $WX['RecentRainToday m=60']; } // beta tag if(isset($WX['RecentSolarRad m=60'])) { $VPsolar60minuteago = $WX['RecentSolarRad m=60']; } // beta tag if(isset($WX['RecentUV m=60'])) { $VPuv60minuteago = $WX['RecentUV m=60']; } // beta tag if(isset($WX['RecentOutsideTemp m=75'])) { $temp75minuteago = $WX['RecentOutsideTemp m=75']; } // beta tag if(isset($WX['RecentWindSpeed m=75'])) { $wind75minuteago = $WX['RecentWindSpeed m=75']; } // beta tag if(isset($WX['RecentWindGust m=75'])) { $gust75minuteago = $WX['RecentWindGust m=75']; } // beta tag if(isset($WX['RecentWindAvgDir m=75'])) {$dir75minuteago = CU_deg2dir($WX['RecentWindAvgDir m=75']); } // conditional value if(isset($WX['RecentHumidity m=75'])) { $hum75minuteago = $WX['RecentHumidity m=75']; } // beta tag if(isset($WX['RecentDewPoint m=75'])) { $dew75minuteago = $WX['RecentDewPoint m=75']; } // beta tag if(isset($WX['RecentPressure m=75'])) { $baro75minuteago = $WX['RecentPressure m=75']; } // beta tag if(isset($WX['RecentRainToday m=75'])) { $rain75minuteago = $WX['RecentRainToday m=75']; } // beta tag if(isset($WX['RecentSolarRad m=75'])) { $VPsolar75minuteago = $WX['RecentSolarRad m=75']; } // beta tag if(isset($WX['RecentUV m=75'])) { $VPuv75minuteago = $WX['RecentUV m=75']; } // beta tag if(isset($WX['RecentOutsideTemp m=90'])) { $temp90minuteago = $WX['RecentOutsideTemp m=90']; } // beta tag if(isset($WX['RecentWindSpeed m=90'])) { $wind90minuteago = $WX['RecentWindSpeed m=90']; } // beta tag if(isset($WX['RecentWindGust m=90'])) { $gust90minuteago = $WX['RecentWindGust m=90']; } // beta tag if(isset($WX['RecentWindAvgDir m=90'])) {$dir90minuteago = CU_deg2dir($WX['RecentWindAvgDir m=90']); } // conditional value if(isset($WX['RecentHumidity m=90'])) { $hum90minuteago = $WX['RecentHumidity m=90']; } // beta tag if(isset($WX['RecentDewPoint m=90'])) { $dew90minuteago = $WX['RecentDewPoint m=90']; } // beta tag if(isset($WX['RecentPressure m=90'])) { $baro90minuteago = $WX['RecentPressure m=90']; } // beta tag if(isset($WX['RecentRainToday m=90'])) { $rain90minuteago = $WX['RecentRainToday m=90']; } // beta tag if(isset($WX['RecentSolarRad m=90'])) { $VPsolar90minuteago = $WX['RecentSolarRad m=90']; } // beta tag if(isset($WX['RecentUV m=90'])) { $VPuv90minuteago = $WX['RecentUV m=90']; } // beta tag if(isset($WX['RecentOutsideTemp m=105'])) { $temp105minuteago = $WX['RecentOutsideTemp m=105']; } // beta tag if(isset($WX['RecentWindSpeed m=105'])) { $wind105minuteago = $WX['RecentWindSpeed m=105']; } // beta tag if(isset($WX['RecentWindGust m=105'])) { $gust105minuteago = $WX['RecentWindGust m=105']; } // beta tag if(isset($WX['RecentWindAvgDir m=105'])) {$dir105minuteago = CU_deg2dir($WX['RecentWindAvgDir m=105']); } // conditional value if(isset($WX['RecentHumidity m=105'])) { $hum105minuteago = $WX['RecentHumidity m=105']; } // beta tag if(isset($WX['RecentDewPoint m=105'])) { $dew105minuteago = $WX['RecentDewPoint m=105']; } // beta tag if(isset($WX['RecentPressure m=105'])) { $baro105minuteago = $WX['RecentPressure m=105']; } // beta tag if(isset($WX['RecentRainToday m=105'])) { $rain105minuteago = $WX['RecentRainToday m=105']; } // beta tag if(isset($WX['RecentSolarRad m=105'])) { $VPsolar105minuteago = $WX['RecentSolarRad m=105']; } // beta tag if(isset($WX['RecentUV m=105'])) { $VPuv105minuteago = $WX['RecentUV m=105']; } // beta tag if(isset($WX['RecentOutsideTemp m=120'])) { $temp120minuteago = $WX['RecentOutsideTemp m=120']; } // beta tag if(isset($WX['RecentWindSpeed m=120'])) { $wind120minuteago = $WX['RecentWindSpeed m=120']; } // beta tag if(isset($WX['RecentWindGust m=120'])) { $gust120minuteago = $WX['RecentWindGust m=120']; } // beta tag if(isset($WX['RecentWindAvgDir m=120'])) {$dir120minuteago = CU_deg2dir($WX['RecentWindAvgDir m=120']); } // conditional value if(isset($WX['RecentHumidity m=120'])) { $hum120minuteago = $WX['RecentHumidity m=120']; } // beta tag if(isset($WX['RecentDewPoint m=120'])) { $dew120minuteago = $WX['RecentDewPoint m=120']; } // beta tag if(isset($WX['RecentPressure m=120'])) { $baro120minuteago = $WX['RecentPressure m=120']; } // beta tag if(isset($WX['RecentRainToday m=120'])) { $rain120minuteago = $WX['RecentRainToday m=120']; } // beta tag if(isset($WX['RecentSolarRad m=120'])) { $VPsolar120minuteago = $WX['RecentSolarRad m=120']; } // beta tag if(isset($WX['RecentUV m=120'])) { $VPuv120minuteago = $WX['RecentUV m=120']; } // beta tag if(isset($WX['ET'])) { $VPet = $WX['ET']; } // beta tag $dateoflastrainalways = $WX['LastRainTipISO']; $highbaro = $WX['pressTH']; $highbarot = $WX['TpressTH']; if(isset($WX['solarYH'])) { $highsolaryest = $WX['solarYH']; } // beta tag if(isset($WX['TsolarYH'])) { $highsolaryesttime = $WX['TsolarYH']; } // beta tag $hourrn = $WX['rhour']; $maxaverageyest = $WX['windYM']; $maxaverageyestt = $WX['TwindYM']; $maxbaroyest = $WX['pressYH']; $maxbaroyestt = $WX['TpressYH']; $maxgstdirectionletter = CU_deg2dir($WX['bearingTM']); // calculated value $maxgustyest = $WX['wgustYM']; $maxgustyestt = $WX['TwgustYM']; $minchillyest = $WX['wchillYL']; $minchillyestt = $WX['TwchillYL']; $minwindch = $WX['wchillTL']; $minwindcht = $WX['TwchillTL']; $mrecordhighbaro = $WX['MonthPressH']; list($mrecordhighbaroday,$mrecordhighbaromonth,$mrecordhighbaroyear)=CU_getRecordDate($WX['MonthPressHD'],$WX['year']); // calculated value $mrecordhightemp = $WX['MonthTempH']; list($mrecordhightempday,$mrecordhightempmonth,$mrecordhightempyear)=CU_getRecordDate($WX['MonthTempHD'],$WX['year']); // calculated value $mrecordlowchill = $WX['MonthWChillL']; list($mrecordlowchillday,$mrecordlowchillmonth,$mrecordlowchillyear)=CU_getRecordDate($WX['MonthWChillLD'],$WX['year']); // conditional value $mrecordlowtemp = $WX['MonthTempL']; list($mrecordlowtempday,$mrecordlowtempmonth,$mrecordlowtempyear)=CU_getRecordDate($WX['MonthTempLD'],$WX['year']); // calculated value $windruntoday = $WX['windrun']; $yrecordhighbaro = $WX['YearPressH']; list($yrecordhighbaroday,$yrecordhighbaromonth,$yrecordhighbaroyear)=CU_getRecordDate($WX['YearPressHD'],$WX['year']); // calculated value list($yrecordhighgustday,$yrecordhighgustmonth,$yrecordhighgustyear)=CU_getRecordDate($WX['YearGustHD'],$WX['year']); // calculated value $yrecordhightemp = $WX['YearTempH']; list($yrecordhightempday,$yrecordhightempmonth,$yrecordhightempyear)=CU_getRecordDate($WX['YearTempHD'],$WX['year']); // calculated value $yrecordlowchill = $WX['YearWChillL']; list($yrecordlowchillday,$yrecordlowchillmonth,$yrecordlowchillyear)=CU_getRecordDate($WX['YearWChillLD'],$WX['year']); // conditional value $yrecordlowtemp = $WX['YearTempL']; list($yrecordlowtempday,$yrecordlowtempmonth,$yrecordlowtempyear)=CU_getRecordDate($WX['YearTempLD'],$WX['year']); // calculated value $yrecordwindgust = $WX['YearGustH']; $yrecordwindspeed = $WX['YearWindH']; $minbaroyest = $WX['pressYL']; $minbaroyestt = $WX['TpressYL']; $mrecordlowbaro = $WX['MonthPressL']; list($mrecordlowbaroday,$mrecordlowbaromonth,$mrecordlowbaroyear)=CU_getRecordDate($WX['MonthPressLD'],$WX['year']); // calculated value $yrecordlowbaro = $WX['YearPressL']; list($yrecordlowbaroday,$yrecordlowbaromonth,$yrecordlowbaroyear)=CU_getRecordDate($WX['YearPressLD'],$WX['year']); // calculated value $recordhightemp = $WX['tempH']; list($recordhightempday,$recordhightempmonth,$recordhightempyear)=CU_getAlltimeDate($WX['TtempH']); // calculated value $recordlowtemp = $WX['tempL']; list($recordlowtempday,$recordlowtempmonth,$recordlowtempyear)=CU_getAlltimeDate($WX['TtempL']); // calculated value $maxheat = $WX['heatindexTH']; $maxheatt = $WX['TheatindexTH']; $maxheatyest = $WX['heatindexYH']; $mrecordhighheatindex = $WX['MonthHeatIndexH']; $yrecordhighheatindex = $WX['YearHeatIndexH']; $lowbaro = $WX['pressTL']; $lowbarot = $WX['TpressTL']; $maxheatyestt = $WX['TheatindexYH']; list($mrecordhighheatindexday,$mrecordhighheatindexmonth,$mrecordhighheatindexyear)=CU_getRecordDate($WX['MonthHeatIndexHD'],$WX['year']); // conditional value list($yrecordhighheatindexday,$yrecordhighheatindexmonth,$yrecordhighheatindexyear)=CU_getRecordDate($WX['YearHeatIndexHD'],$WX['year']); // conditional value $windrunyesterday = $WX['windrunY'];
// end of generation script # CU unique functions included from CU-functions-inc.txt #------------------------------------------------------------------------------------- # function processed WD variables #-------------------------------------------------------------------------------------
global $SITE;
$SITE['commaDecimal'] = strpos($temperature,',') !==false?true:false; // using comma for decimal point?
if(substr($WX['LastRainTipISO'],0,4) <> '0000') { // got a last rain valid date # $WX['LastRainTipISO'] = '2012-06-05 03:58'; $cuDF = ($SITE['WDdateMDY'])?'m/d/y':'d/m/y'; list($dateoflastrainalways,$timeoflastrainalways) = explode(' ',date("$cuDF H:i",strtotime($WX['LastRainTipISO']))); $dayswithnorain = intval((strtotime(date('Y-m-d'))-strtotime(substr($WX['LastRainTipISO'],0,10)))/86400); }
if(isset($SITE['conditionsMETAR'])) { // override with METAR conditions for text and icon if requested. include_once("get-metar-conditions-inc.php"); list($Currentsolardescription,$iconnumber,$icongraphic,$icontext,$mtrstuff) = mtr_conditions($SITE['conditionsMETAR'], $time, $sunrise, $sunset,true); if(isset($currentrainratehr) and (!isset($SITE['overrideRain']) or (isset($SITE['overrideRain']) and $SITE['overrideRain'])) ) { list($Currentsolardescription,$iconnumber) = CU_RainRateIcon($Currentsolardescription,$iconnumber,$currentrainratehr,$uomrain,$time,$sunrise,$sunset,$WX['LastRainTipISO']); } }
# generate the separate date/time variables by dissection of input date/time and format list($date_year,$date_month,$date_day,$time_hour,$time_minute,$monthname,$dayname) = CU_setDateTimes($date,$time,$SITE['WDdateMDY']);
$beaufortnum = CU_beaufortNumber($avgspd,$uomwind); $bftspeedtext = CU_beaufortText($beaufortnum);
list($chandler,$chandlertxt,$chandlerimg) = CU_CBI($temperature,$uomtemp,$humidity);
if(!isset($wdversion) and isset($SITE['WXsoftwareVersion'])) {$wdversion = $SITE['WXsoftwareVersion']; }
list($feelslike,$heatcolourword) = CU_setFeelslike ($temperature,$windch,$heati,$humidex,$apparenttemp,$uomtemp);
if($dirlabel == '---'){$dirlabel = $WX['currentwdir'];} // use current winddir when wdir='---' for avg=0.0 wind
#------------------------------------------------------------------------------------- # WCT support function - CU_RainRateIcon #-------------------------------------------------------------------------------------
function CU_RainRateIcon($inText,$inIcon,$inRate,$inUOM,$time,$sunrise,$sunset,$lastRain='0000-00-00T00:00:00') { global $Debug; /* Rainfall intensity is classified according to the rate of precipitation:
Light rain — rate is < 2.5 mm (0.098 in) per hour Moderate rain — rate is between 2.5 mm (0.098 in) - 7.6 mm (0.30 in) or 10 mm (0.39 in) per hour Heavy rain — rate is > 7.6 mm (0.30 in) per hour, or between 10 mm (0.39 in) and 50 mm (2.0 in) per hour Violent rain — rate is > 50 mm (2.0 in) per hour */ $Debug .= "<!-- CU_RainRateIcon in='$inText' icon='$inIcon' rate='$inRate' uom='$inUOM' -->\n"; $newText = ''; // assume no changes $newIcon = $inIcon; $rate = $inRate; if(preg_match('|in|i',$inUOM)) { // convert to mm/hr rate $rate = $inRate * 25.4; } if(substr($lastRain,0,4) <> '0000') { if($rate < 0.001 and time()-strtotime($lastRain) < 30*60) { $newText = 'Moderate Drizzle'; } }
if ($rate > 0.0 and $rate < 2.5) { $newText = 'Light Rain'; } if ($rate >=2.5 and $rate < 7.6) { $newText = 'Moderate Rain'; } if ($rate >=7.6 and $rate < 50.0) { $newText = 'Heavy Rain'; } if ($rate >= 50.0) { $newText = 'Violent Rain'; } if($newText <> '' or $rate == 0.0) { if ($newText <> '' and $inText <> '') {$newText .= ', ';} $newText .= preg_replace('/(Light|Moderate|Heavy|Violent|Extreme){0,1}\s*(Rain|Mist|Drizzle), /i','',$inText); $newIcon = mtr_get_iconnumber ($time,$newText,$sunrise,$sunset); } else { $newText = $inText; } $Debug .= "<!-- CU_RainRateIcon out='$newText' icon='$newIcon' rate='$rate' mm/hr -->\n"; return(array($newText,$newIcon)); }
#------------------------------------------------------------------------------------- # CU support function - CUfixupTime #-------------------------------------------------------------------------------------
function CUfixupTime ($intime) { global $Debug; $tfixed = preg_replace('/^(\S+)\s+(\S+)$/is',"$2",$intime); $t = explode(':',$tfixed); if(!isset($t[1])) { $t = explode('.',$tfixed); } if (preg_match('/p/i',$tfixed)) { $t[0] = $t[0] + 12; } if ($t[0] > 23) {$t[0] = 12; } if (preg_match('/^12.*a/i',$tfixed)) { $t[0] = 0; } if ($t[0] < '10') {$t[0] = sprintf("%02d",$t[0]); } // leading zero on hour. $t2 = join(':',$t); // put time back to gether; $t2 = preg_replace('/[^\d\:]/is','',$t2); // strip out the am/pm if any $Debug .= "<!-- CUfixupTime in='$intime' tfixed='$tfixed' out='$t2' -->\n"; return($t2); } // end CUfixupTime
#------------------------------------------------------------------------------------- # CU support function - CU_setDateTimes #-------------------------------------------------------------------------------------
function CU_setDateTimes ($indate,$intime,$MDYformat=true) { // returns: $date_year,$date_month,$date_day,$time_hour,$time_minute,$date_month,$monthname,$dayname global $Debug; $Debug .= "<!-- CU_setDateTimes date='$indate' time=$intime' MDY=$MDYformat -->\n"; $d = explode('/',$indate); if(!isset($d[2])) {$d = explode("-",$indate);} if(!isset($d[2])) {$d = explode(".",$indate);} if($d[2]<2000) {$d[2]+=2000;} if($MDYformat) { // mm/dd/yyyy $YMD = "$d[2]-$d[0]-$d[1]"; } else { // dd/mm/yyyy $YMD = "$d[2]-$d[1]-$d[0]"; } $t = CUfixupTime($intime); $CUtime = strtotime("$YMD $t:00"); $Debug .= "<!-- CU_setDateTimes CUtime='$YMD $t:00' assembled -->\n"; $CUtime = date('Y m d H i F l',$CUtime); $Debug .= "<!-- CU_setDateTimes CUtime='$CUtime' values set -->\n"; if(isset($_REQUEST['debug'])) {echo $Debug; } return(explode(' ',$CUtime)); // results returned in array for list() assignment } // end CU_setDateTimes
#------------------------------------------------------------------------------------- # CU support function - CU_beaufortNumber #-------------------------------------------------------------------------------------
function CU_beaufortNumber ($inWind,$usedunit) { global $Debug; $rawwind = $inWind; // first convert all winds to knots if(strpos($inWind,',') !== false) { $rawwind = preg_replace('|,|','.',$inWind); } $WINDkts = 0.0; if (preg_match('/kts|knot/i',$usedunit)) { $WINDkts = $rawwind * 1.0; } elseif (preg_match('/mph/i',$usedunit)) { $WINDkts = $rawwind * 0.8689762; } elseif (preg_match('/mps|m\/s/i',$usedunit)) { $WINDkts = $rawwind * 1.94384449; } elseif (preg_match('/kmh|km\/h/i',$usedunit)) { $WINDkts = $rawwind * 0.539956803; } else { $Debug .= "<!-- CU_beaufortNumber .. unknown input unit '$usedunit' for wind=$rawwind -->\n"; $WINDkts = $rawwind * 1.0; }
// return a number for the beaufort scale based on wind in knots if ($WINDkts < 1 ) {return(0); } if ($WINDkts < 4 ) {return(1); } if ($WINDkts < 7 ) {return(2); } if ($WINDkts < 11 ) {return(3); } if ($WINDkts < 17 ) {return(4); } if ($WINDkts < 22 ) {return(5); } if ($WINDkts < 28 ) {return(6); } if ($WINDkts < 34 ) {return(7); } if ($WINDkts < 41 ) {return(8); } if ($WINDkts < 48 ) {return(9); } if ($WINDkts < 56 ) {return(10); } if ($WINDkts < 64 ) {return(11); } if ($WINDkts >= 64 ) {return(12); } return("0"); } // end CU_beaufortNumber
#------------------------------------------------------------------------------------- # CU support function - CU_beaufortText #-------------------------------------------------------------------------------------
function CU_beaufortText ($beaufortnumber) {
$B = array( /* Beaufort 0 to 12 in English */ "Calm", "Light air", "Light breeze", "Gentle breeze", "Moderate breeze", "Fresh breeze", "Strong breeze", "Near gale", "Gale", "Strong gale", "Storm", "Violent storm", "Hurricane" );
if(isset($B[$beaufortnumber])) { return $B[$beaufortnumber]; } else { return "Unknown $beaufortnumber Bft"; } } // end CU_beaufortText
#------------------------------------------------------------------------------------- # CU support function - CU_setFeelslike #-------------------------------------------------------------------------------------
function CU_setFeelslike ($temp,$windchill,$heatindex,$humidex,$apparenttemp,$tempUOM) { global $Debug, $SITE; // establish the feelslike temperature and return a word describing how it feels
$HeatWords = array( 'Unknown', 'Extreme Heat Danger', 'Heat Danger', 'Extreme Heat Caution', 'Extremely Hot', 'Uncomfortably Hot', 'Hot', 'Warm', 'Comfortable', 'Cool', 'Cold', 'Uncomfortably Cold', 'Very Cold', 'Extreme Cold' ); if(isset($SITE['feelslike'])) { $flVar = $SITE['feelslike']; } else { $flVar = -1; }
// first convert all temperatures to Centigrade if need be $TC = $temp; $WC = $windchill; switch ($flVar) { case 0: $HC = $heatindex; $using = 'HeatIndex'; break; case 1: $HC = $humidex; $using = 'Humidex'; break; case 2: $HC = $apparenttemp; $using = 'ApparentTemp'; break; default: $HC = $heatindex; $using = 'HeatIndex(default)'; break; } if(strpos($TC,',') !== false) { $TC = preg_replace('|,|','.',$TC); $WC = preg_replace('|,|','.',$WC); $HC = preg_replace('|,|','.',$HC); } if (preg_match('|F|i',$tempUOM)) { // convert F to C if need be $TC = sprintf("%01.1f",round(($TC-32.0) / 1.8,1)); $WC = sprintf("%01.1f",round(($WC-32.0) / 1.8,1)); $HC = sprintf("%01.1f",round(($HC-32.0) / 1.8,1)); } // Feelslike if ($TC <= 16.0 ) { $feelslike = $WC; //use WindChill } elseif ($TC >=27.0) { $feelslike = $HC; //use HeatIndex/Humidex/ApparentTemp } else { $feelslike = $TC; // use temperature }
if (preg_match('|F|i',$tempUOM)) { // convert C back to F if need be $feelslike = (1.8 * $feelslike) + 32.0; } $feelslike = round($feelslike,0);
// determine the 'heat color word' to use $hcWord = $HeatWords[0]; $hcFound = false; if ($TC > 32 and $HC > 29) { if ($HC > 54 and ! $hcFound) { $hcWord = $HeatWords[1]; $hcFound = true;} if ($HC > 45 and ! $hcFound) { $hcWord = $HeatWords[2]; $hcFound = true; } if ($HC > 39 and ! $hcFound) { $hcWord = $HeatWords[4]; $hcFound = true; } if ($HC > 29 and ! $hcFound) { $hcWord = $HeatWords[6]; $hcFound = true; } } elseif ($WC < 16 ) { if ($WC < -18 and ! $hcFound) { $hcWord = $HeatWords[13]; $hcFound = true; } if ($WC < -9 and ! $hcFound) { $hcWord = $HeatWords[12]; $hcFound = true; } if ($WC < -1 and ! $hcFound) { $hcWord = $HeatWords[11]; $hcFound = true; } if ($WC < 8 and ! $hcFound) { $hcWord = $HeatWords[10]; $hcFound = true; } if ($WC < 16 and ! $hcFound) { $hcWord = $HeatWords[9]; $hcFound = true; } } elseif ($WC >= 16 and $TC <= 32) { if ($TC <= 26 and ! $hcFound) { $hcWord = $HeatWords[8]; $hcFound = true; } if ($TC <= 32 and ! $hcFound) { $hcWord = $HeatWords[7]; $hcFound = true; } }
if(isset($_REQUEST['debug'])) { echo "<!-- CU_setFeelslike input T,WC,HI,HU,AT,U='$temp,$windchill,$heatindex,$humidex,$apparenttemp,$tempUOM'\n"; echo " cnvt T,WC,$using='$TC,$WC,$HC'°C\n"; echo " feelslike=$feelslike hcWord=$hcWord\n -->\n"; }
return(array($feelslike,$hcWord)); } // end of CU_setFeelslike
#------------------------------------------------------------------------------------- # CU support function - CU_CBI - Chandler Burning Index #-------------------------------------------------------------------------------------
function CU_CBI($inTemp,$inTempUOM,$inHumidity) { // thanks to Chris from sloweather.com for the CBI calculation script // modified by Ken True for template usage preg_match('/([\d\.\,\+\-]+)/',$inTemp,$t); // strip non-numeric from inTemp if any $ctemp = $t[1]; if(strpos($ctemp,',') !== false) { $ctemp = preg_replace('|,|','.',$ctemp); } if(!preg_match('|C|i',$inTempUOM)) { $ctemp = ($ctemp-32.0) / 1.8; // convert from Fahrenheit } preg_match('/([\d\.\,\+\-]+)/',$inHumidity,$t); // strip non-numeric from inHumidity if any $rh = $t[1]; if(strpos($rh,',') !== false) { $rh = preg_replace('|,|','.',$rh); }
// Start Index Calcs // Chandler Index $cbi = (((110 - 1.373 * $rh) - 0.54 * (10.20 - $ctemp)) * (124 * pow(10,-0.0142 * $rh) ))/60; // CBI = (((110 - 1.373*RH) - 0.54 * (10.20 - T)) * (124 * 10**(-0.0142*RH)))/60 //Sort out the Chandler Index $cbi = round($cbi,1); if ($cbi > "97.5") { $cbitxt = "EXTREME"; $cbiimg= "fdl_extreme.gif"; } elseif ($cbi >="90") { $cbitxt = "VERY HIGH"; $cbiimg= "fdl_vhigh.gif"; } elseif ($cbi >= "75") { $cbitxt = "HIGH"; $cbiimg= "fdl_high.gif"; } elseif ($cbi >= "50") { $cbitxt = "MODERATE"; $cbiimg= "fdl_moderate.gif"; } else { $cbitxt="LOW"; $cbiimg= "fdl_low.gif"; } $data = array($cbi,$cbitxt,$cbiimg); return $data; } // end CU_CBI
#------------------------------------------------------------------------------------- # CU support function - CU_getRecordDate - Convert 'dd Month '.'YYYY' to list(d,m,y) #-------------------------------------------------------------------------------------
function CU_getRecordDate($inDayMonth,$inYear) { global $SITE,$Debug; $EnglishMonths = array( 'January','February','March','April','May','June', 'July','August','September','October','November','December'); $tstr = $inDayMonth . ' ' . $inYear; $Debug .= "<!-- CU_getRecordDate input tstr='$tstr' -->\n";
// input dates are assumed to be in English only if (isset($SITE['monthNames'])) { // convert TO English for strtotime() foreach ($EnglishMonths as $i => $monthEN) { $tstr = preg_replace('|'.$SITE['monthNames'][$i].'|i',$monthEN,$tstr); } $Debug .= "<!-- CU_getRecordDate after tstr='$tstr' -->\n"; }
$ttime = strtotime($tstr); $ltime = date('j n Y',$ttime); $Debug .= "<!-- CU_getRecordDate result ltime='$ltime' -->\n"; return(explode(' ',$ltime));
}
#------------------------------------------------------------------------------------- # CU support function - CU_getAlltimeDate - Convert 'at 2:45 PM on 16 October 2009' to list(d,m,y) #-------------------------------------------------------------------------------------
function CU_getAlltimeDate($inDate) { global $SITE,$Debug; $EnglishMonths = array( 'January','February','March','April','May','June', 'July','August','September','October','November','December');
$Debug .= "<!-- CU_getAlltimeDate input inDate='$inDate' -->\n"; if(preg_match('|^at (.*) on (.*)$|i',$inDate,$m)) { // at 2:45 PM on 16 October 2009 $tstr = $m[2] . " " .$m[1]; } elseif (preg_match('|^on (.*)$|i',$inDate,$m)) { // on 16 October 2009 $tstr = $m[1]; }
// input dates are assumed to be in English only if (isset($SITE['monthNames'])) { // convert TO English for strtotime() foreach ($EnglishMonths as $i => $monthEN) { $tstr = preg_replace('|'.$SITE['monthNames'][$i].'|i',$monthEN,$tstr); } $Debug .= "<!-- CU_getAlltimeDate after tstr='$tstr' -->\n"; }
$ttime = strtotime($tstr); $ltime = date('j n Y H:i',$ttime); $Debug .= "<!-- CU_getAlltimeDate result ltime='$ltime' -->\n"; return(explode(' ',$ltime));
}
#------------------------------------------------------------------------------------- # CU support function - CU_deg2dir - Convert wind direction degrees to cardinal name #-------------------------------------------------------------------------------------
function CU_deg2dir ($degrees) { // figure out a text value for compass direction // Given the wind direction, return the text label // for that value. 16 point compass $winddir = $degrees; if ($winddir == "n/a") { return($winddir); }
if (!isset($winddir)) { return "---"; } if (!is_numeric($winddir)) { return($winddir); } $windlabel = array ("N","NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW","SW", "WSW", "W", "WNW", "NW", "NNW"); $dir = $windlabel[ fmod((($winddir + 11) / 22.5),16) ]; return($dir);
} // end function CU_deg2dir
#------------------------------------------------------------------------------------- # end of CU support functions #-------------------------------------------------------------------------------------
?>
|