Author Topic: Using PoP Variable from Saratoga-Weather Forecast Script  (Read 2130 times)

0 Members and 1 Guest are viewing this topic.

Offline Carson Weather

  • Contributor
  • ***
  • Posts: 108
    • http://www.carsonweather.com
Using PoP Variable from Saratoga-Weather Forecast Script
« on: June 26, 2008, 01:22:42 AM »
Hello,

On my index page I'm using a couple of elements from Ken's NWS forecast script to show "short term" forecast info. (I've got a separate page with the detailed stuff)

I had been using the code shown below to show current period PoP but it is no longer working.
I've also tried $PoP[0] as a variable, but it doesn't work either.

Would someone mind helping a PHP-challended guy out???


Code: [Select]
<?php
    if ($forecastpop[0] =="100") {
echo "Chance of Rain/Snow is near $forecastpop[0]%"; 
}
    elseif ($forecastpop[0] >= "00") {
            echo "Chance of Precipitation is $forecastpop[0]%";
}  
     else { 
            echo " ";
}
?>

-Joe      

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Using PoP Variable from Saratoga-Weather Forecast Script
« Reply #1 on: June 27, 2008, 12:13:31 PM »
I have a bit of bad news for you unfortunately .. the NOAA Point-printable forecast doesn't include a separate line for PoP (like the old www.wrh.noaa.gov forecasts), so the $forecastpop array isn't filled by normal operation of the script.
For Zone forecasts (the fallback if the point-printable forecast isn't available), it does fill in a $forecastpop array based on the text of the zone forecast.

So .. what you're looking for isn't available during 'normal' operation of advforecast2.php as the NOAA website doesn't provide it .. the only place the PoP appears is as a number associated with the name of a particular icon.  So 'ra60.jpg' would indicate rain with 60% PoP.

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Carson Weather

  • Contributor
  • ***
  • Posts: 108
    • http://www.carsonweather.com
Re: Using PoP Variable from Saratoga-Weather Forecast Script
« Reply #2 on: June 27, 2008, 12:34:35 PM »
It's your script so I guess you know it best :)

I saw that you were populating the image tag with the text, and figured it could  be done :(

Code: [Select]
if ($PoP[$i] > 0) {
  $tag .= ". Chance of measurable precipation is " . $PoP[$i] . '%.';
}

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Using PoP Variable from Saratoga-Weather Forecast Script
« Reply #3 on: June 27, 2008, 06:12:35 PM »
Yes, that was in the Zone part of the forecast parser.  That area has to take a (sometimes abbreviated) forecast for multiple days and split it up into day/night forecasts for the period.  The code you cited was to make sure the 'Chance of measurable precipation' text appears into each of the cloned forecasts for the days between.  It's not used in the regular (point-printable) forecast section.

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

 

anything