I started this script based on an idea from doornenburgweer – He had adapted Jordan Gerth’s wsofd.php script to convert the plaintext.txt English forecast into Dutch. (see this thread).
I thought it was a great idea to make WXSIM output available in multiple languages. I wrote the plaintext-parser.php to create a carterlake-style forecast output that would use the carterlake (NOAA) icon set, would be easy to include in a weather website, generate XHTML 1.0-Strict output, and have built-in support for translations to other languages. It also has the ability to display sky condition instead of the ‘rain’ icon for ‘Chance rain’ conditions where PoP is < 40% (adjustable in a setting in the script)… this idea was thanks to ‘stuntman’. An add-on set of PoP-stamped sky condition icons is included for folks already using the carterlake advforecast NOAA script.
My special thanks go to Jordan Gerth for creating the first set of plaintext.txt parsing/display functions, to doornenburgweer for his pioneering work on a Dutch translation, and to the folks who generated the language translation files (listed below) that this script uses and for testing the script set.
Thanks to your all! I hope you enjoy the script/translations … this was truly an international effort.
Excellent script Ken, so far I have been using the WD created image for my forecasts but I think this is much better. The main problem with the WD image is the icons which have text on them dont scale well, but doing it this way is so much better. I’ll have to try it out on my pages.
Jack (and others), I noticed that the split icons (sky/fog) also needed to be PoP stamped too, so please download the updated add-on Icons for your site… ( http://saratoga-weather.org/carterlake-icons-addon.zip ) – both the addon and the full set now include the sctfg, nbknfg, fg, nfg Icons with PoP stamps.
Jacks display without the new icons:
and after the new icons (disregard the change in background color… my testing script was used)
You’re very welcome John! Your page looks great too… except for the weather forecast itself…
You haven’t started believing in Spring either (Snow, rain, mix, thunder… you’ve got it all). Ahhhh… California is nice this time of the year (and most times too )
Hi Ken!
I have a question concerning the forecast icons. Wouldn’t the rasn.jpg icon be more appropriate for when the forecast says “rain/snow mixed”? Currently the icon being used is mix.jpg, which I would think should be for “ice/snow mixed”? I saved a copy of a partial forecast showing the difference between the nws and wxsim icons used when those forecast conditions are present, at:http://rockcreekweather.com/forecasts.html
TIA
–Kevin H.
I thought I’d share the PHP code that lets me do the ‘select a language’ on my example and WXSIM forecast page on my site – you might find use for it too.
<p>Language:
<?php
$selected = 'en';
$available = array(
'en' => 'English',
'fr' => 'French',
'dk' => 'Danish',
'nl' => 'Dutch',
'it' => 'Italian',
'no' => 'Norwegian',
'pt' => 'Portuguese',
'es' => 'Spanish',
'se' => 'Swedish'
);
if (isset($_REQUEST['lang']) ) {
$selected = substr(strtolower($_REQUEST['lang']),0,2);
}
if (! isset($available[$selected]) ) {
echo "<b>Sorry: '$selected'</b> is not available. Using English instead.
\n";
$selected = 'en';
}
echo "Language: | ";
foreach ($available as $arg => $langName) {
if ($arg == $selected) {
echo "<a href=\"?lang=${arg}\" title=\"Click to show forecast in $langName\"><b> $langName </b> </a> | \n";
} else {
echo "<a href=\"?lang=${arg}\" title=\"Click to show forecast in $langName\"> $langName </a> | \n";
}
}
?>
</p>
I was kicking this around my head over the weekend and would love to see somebody who is code talented give this a whirl…
Would it be possible to store forecasts in a DB?? Perhaps in the MySQL DB that WD already can use so effeciently? I’d love to be able to go back and check, or trend forecasts…
For example, how cool would it be to be able to see what the forecasted high and low was for March 1st, compared to the actual recorded values? Perhaps even chart how those played out? I would love to see how accurate WXSim is vs. the NWS in my area!
Logically I haven’t been able to figure out how best to do this… Since I run a 7 day forecast every day, you could end up with 7 forecasts for each day… one from 7 days out, the next from 6 days out, the next from 5… etc…
I’m sure there is a way to store and present such information, but I can’t figure it out!!
On my to-do list is to put together a spreadsheet to manually track on a once-per-day basis, but I haven’t done that either. I think it’s a great project if we can figure out where to begin.
If you get WXSim to archive the forecast datasets it saves 3 files one of which is a .csv file. You could use this to import into an appropriate MySQL database, although it might need some tweaking if you run more than one per day.
It would be quite simply to archive the plain text file in a database but I think the .csv would be more useful.
My thought was to schedule an event to take the forecast (if you run multiple times a day) at the most accurate time (for me that is about 14:30) and use that forecast as ‘the one’ that gets recorded… I just think a running forecast accuracy statistic would be a handy thing to have… would also help for tweaking forecasts… if I knew that in March WXSIM or the NWS were ‘usually’ a couple degrees this way or that way… I could use that information… also I’d bet Tom could use such information in his WXSim software development.