Page 1 of 1
New PW-forecast.php script for international/multilingual forecasts
Posted: Sun 15 Jan 2023 2:34 am
by saratogaWX
As you likely know, after Apple bought DarkSky, the ability to get new DarkSky API keys vanished, and the API itself is soon to be withdrawn from availability. Fortunately, a PhD student has cobbled together an API using public weather data (GFS, GEFS, HRRR) on Amazon Web Services and is offering a free API in the DarkSky format. WooHoo, said I. So I've adapted my existing (and soon to be obsolete) DS-forecast.php to use the new API.
The site offering the API is
https://pirateweather.net/ ('pirate' because HRRR sounds like the ARRRR that pirates supposedly used).
The new API is not quite as full-featured as the real DarkSky API:
1) English text responses only (but the PW-forecast.php handles multilingual translations built-in)
2) Sparse 'conditions' text.. usually only one word.
3) Alerts are just titles.. no link to details
I'll be adding the offering to the Base-World template set next week. The script set is available from two sources:
https://saratoga-weather.org/scripts-PWforecast.php and
https://github.com/ktrue/PW-forecast
See the demo at
https://saratoga-weather.org/PW-forecast-demo.php
Re: New PW-forecast.php script for international/multilingual forecasts
Posted: Tue 17 Jan 2023 10:03 am
by ConligWX
Thanks again for all your hard work Ken. Much appreciated.
hoping someone from the cumulus community could write a Forecast page for the CumulusMX website too.
Re: New PW-forecast.php script for international/multilingual forecasts
Posted: Tue 17 Jan 2023 3:15 pm
by dazza1223
ConligWX wrote: ↑Tue 17 Jan 2023 10:03 am
Thanks again for all your hard work Ken. Much appreciated.
hoping someone from the cumulus community could write a Forecast page for the CumulusMX website too.
that be so good if that can happen
Re: New PW-forecast.php script for international/multilingual forecasts
Posted: Tue 17 Jan 2023 10:37 pm
by jlmr731
First, Thanks to Ken with all the work very nicely done.
All i did was to knock out the tables from index.htm and put in a php include to the PW-forecast.php so edit the name if you have changed anything.
I zipped up my example web page and also the menu.js file if you want a link pointing to forecast menu.js is in the js directory
My example is here
https://wickliffeweather.com/forecast.php
Re: New PW-forecast.php script for international/multilingual forecasts
Posted: Thu 19 Jan 2023 8:08 am
by ConligWX
excellent. Thanks for the file.
Re: New PW-forecast.php script for international/multilingual forecasts
Posted: Thu 19 Jan 2023 10:12 am
by Nossie
I loved DarkSky prior to apple taking them over, such a shame - but no surprise I guess.
Will need to check this out! Thank you, everyone involved!
Re: New PW-forecast.php script for international/multilingual forecasts
Posted: Thu 19 Jan 2023 12:50 pm
by ConligWX
saratogaWX wrote: ↑Sun 15 Jan 2023 2:34 am
As you likely know, after Apple bought DarkSky, the ability to get new DarkSky API keys vanished, and the API itself is soon to be withdrawn from availability. Fortunately, a PhD student has cobbled together an API using public weather data (GFS, GEFS, HRRR) on Amazon Web Services and is offering a free API in the DarkSky format. WooHoo, said I. So I've adapted my existing (and soon to be obsolete) DS-forecast.php to use the new API.
See the demo at
https://saratoga-weather.org/PW-forecast-demo.php
Ken I has just added the standalone page to my website. I am using Aerisweather Forecast in my Settings as the default Forecast for Saratoga Templates. I also have DS setup as a standalone. when I add PW as a standalone my webpage background colour changes from dark to light.
AerisWeather
https://www.conligwx.org/wxforecast.php
DarkSky
https://www.conligwx.org/wxforecastds.php
PirateWeather
https://www.conligwx.org/wxforecastpw.php
Any thoughts?
Re: New PW-forecast.php script for international/multilingual forecasts
Posted: Thu 19 Jan 2023 5:22 pm
by saratogaWX
Just did a small update of PW-forecast.php to V2.51 of the script to automatically set the timeline display to ampm or 24hr time based on $timeFormat/$SITE['timeFormat']. (If the time format has 'g', then am/pm is used, otherwise 24hr time is used).
Available on the script page, the Template update tool page and on GitHub.
Best regards,
Ken
Re: New PW-forecast.php script for international/multilingual forecasts
Posted: Thu 19 Jan 2023 5:39 pm
by saratogaWX
ConligWX wrote: ↑Thu 19 Jan 2023 12:50 pm
saratogaWX wrote: ↑Sun 15 Jan 2023 2:34 am
As you likely know, after Apple bought DarkSky, the ability to get new DarkSky API keys vanished, and the API itself is soon to be withdrawn from availability. Fortunately, a PhD student has cobbled together an API using public weather data (GFS, GEFS, HRRR) on Amazon Web Services and is offering a free API in the DarkSky format. WooHoo, said I. So I've adapted my existing (and soon to be obsolete) DS-forecast.php to use the new API.
See the demo at
https://saratoga-weather.org/PW-forecast-demo.php
Ken I has just added the standalone page to my website. I am using Aerisweather Forecast in my Settings as the default Forecast for Saratoga Templates. I also have DS setup as a standalone. when I add PW as a standalone my webpage background colour changes from dark to light.
AerisWeather
https://www.conligwx.org/wxforecast.php
DarkSky
https://www.conligwx.org/wxforecastds.php
PirateWeather
https://www.conligwx.org/wxforecastpw.php
Any thoughts?
You're generating a dynamic background to the page of your website.
Somehow, the merry-timeline is causing the CSS of 'background-color: #212121;' to be suppressed in the browser, yielding a 'white' background.
I do know that merry-timeline does modify background colors for the hour-sliced display to indicate the weather/sky condition.
I've not messed about with dynamically produced replicating backgrounds like you have, so have no additional advice on how to fix.. sorry!
Edit: Try fixing the body CSS in weather-screen-narrow-black.css to have
Code: Select all
background-color:#212121 !important;
instead of just
.. works to restore background using Firefox debugger
Re: New PW-forecast.php script for international/multilingual forecasts
Posted: Thu 19 Jan 2023 7:27 pm
by ConligWX
saratogaWX wrote: ↑Thu 19 Jan 2023 5:39 pm
You're generating a dynamic background to the page of your website.
Somehow, the merry-timeline is causing the CSS of 'background-color: #212121;' to be suppressed in the browser, yielding a 'white' background.
I do know that merry-timeline does modify background colors for the hour-sliced display to indicate the weather/sky condition.
I've not messed about with dynamically produced replicating backgrounds like you have, so have no additional advice on how to fix.. sorry!
Edit: Try fixing the body CSS in weather-screen-narrow-black.css to have
Code: Select all
background-color:#212121 !important;
instead of just
.. works to restore background using Firefox debugger
Much Appreciated Ken!
Re: New PW-forecast.php script for international/multilingual forecasts
Posted: Thu 19 Jan 2023 8:32 pm
by jlmr731
your new merry-timeline looks much better, give a nice clean look and much easier to read
Re: New PW-forecast.php script for international/multilingual forecasts
Posted: Fri 20 Jan 2023 11:03 am
by ConligWX
jlmr731 wrote: ↑Tue 17 Jan 2023 10:37 pm
First, Thanks to Ken with all the work very nicely done.
All i did was to knock out the tables from index.htm and put in a php include to the PW-forecast.php so edit the name if you have changed anything.
I zipped up my example web page and also the menu.js file if you want a link pointing to forecast menu.js is in the js directory
My example is here
https://wickliffeweather.com/forecast.php
I found you needed also to change the main PW-forecast.php code (mine is PWcmx-forecast.php)
from:
Code: Select all
<body style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; background-color:#FFFFFF">
to
Code: Select all
<body style="font-family:'Rosario', sans-serif; font-size:15px; background-color:#FFFFFF">
so the Forecast page has the same font/sizing. I'm using the standard PW-forecast.php for Saratoga Templates and a cloned one (PWcmx-forecast.php) for CumulusMX Web page Templates.
Re: New PW-forecast.php script for international/multilingual forecasts
Posted: Fri 20 Jan 2023 8:46 pm
by jlmr731
That works out nicely thanks, also if you want the daily forecast to be hoverable like the rest of the site, (I didnt like the look on the new hourly page),
on line or about line 1381 you can add that class to it like
Code: Select all
<table style="border: 0" width="640px" class="PWforecast w3-table w3-hoverable">
Re: New PW-forecast.php script for international/multilingual forecasts
Posted: Mon 01 May 2023 10:20 pm
by Mapantz
Hi Ken
I've just noticed that the sunrise and sunset times in the current conditions are not taking daylight savings in to account.
Re: New PW-forecast.php script for international/multilingual forecasts
Posted: Mon 01 May 2023 11:01 pm
by saratogaWX
The sunrise/sunset times come from Pirateweather and are formatted by
Code: Select all
if(isset($JSON['daily']['data'][0]['sunriseTime']) and
isset($JSON['daily']['data'][0]['sunsetTime']) ) {
$PWcurrentConditions .=
$tranTab['Sunrise'].': <b>'.
date($tFMT,$JSON['daily']['data'][0]['sunriseTime']) .
"</b><br/>\n" .
$tranTab['Sunset'].': <b>'.
date($tFMT,$JSON['daily']['data'][0]['sunsetTime']) .
"</b><br/>\n" ;
}
Sounds like an API bug to me.
The API doc just saysat
https://pirateweather.net/en/latest/API/
sunriseTime
Only on daily. The time when the sun rises for a given day represented in UNIX time.
sunsetTime
Only on daily. The time when the sun sets for a given day represented in UNIX time.
I suggest you open an issue at
https://github.com/alexander0042/pirateweather/issues/ and see what the author of the API has to say. My code assumed the data was the UTC unix timestamp and the date() function (along with your timezone setting) would correctly display the data.