PHP for WXSIM icons/forecast (carterlake style) - multi-lingual

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.

Language plugins available for:

Danish thanks to jwwd
Dutch thanks to doornenburgweer
French thanks to Devil
Italian thanks to MD5
Norwegian thanks to Rush
Spanish thanks to Breitling
Swedish thanks to sm6kiw

The script, icons/add-on icons to the carterlake set, and language plugins along with demos are available at Saratoga-Weather.org - Scripts - WXSIM display utility

If you’d like to create a language translation plugin for other languages, please PM or email me – I’d be pleased to support your effort!

Best regards,
Ken

Woo hoo! Cool, Ken! Thanks! I can’t wait to try it.

Chris

It’s sweet, good job Ken :slight_smile:

Until I get the time to integrate it on my site, ere is the working Norwegian version.

To see it in english for example, just add ?lang=en after the url:

Norwegian
http://www.lynradar.no/wxparser/wxparser.php

English
http://www.lynradar.no/wxparser/wxparser.php?lang=en

Wow, this is great Ken, nice job. Now I have to find the time to integrate it into the site.

Thanks for another great script!

Jack

Didn’t take too much time after all…

http://www.branfordfire.com/weather/wx16.php

Another fine job, Ken! :slight_smile:

I have the script working on my site at: http://rockcreekweather.com/plaintext-parser.php

Thanks!
–Kevin H.

Thanks Jack!
Your page looks great!

You can see the effect of the PoP filter by going to
http://www.branfordfire.com/weather/wx16.php?minpop=10

Stuntman had a great idea for that… makes the forecast much more readible.

Thanks Kevin! I really think Oregon hasn’t agreed with us about Spring yet, looking at your forecast :lol:

Here’s what Spring looks like…

Best regards,
Ken

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.

Stuart

I have it working (integrated with html code) at http://www.cypenv.org/wxfcast/forecast.php or, in French, at http://www.cypenv.org/wxfcast/forecast-fr.php

IMHO, best one yet!

Rush and Devil, THANKS for your translation work!

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)

Best regards,
Ken

Got it Ken, thanks!

Jack

:smiley: :smiley: Nice job Ken you can see it working at http://www.johnsnhweather.com/advforecast.php

Thanks

John

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 ) :slight_smile:

Hope your weather improves…

Best regards,
Ken

(Snow, rain, mix, thunder.. you've got it all).

It just wouldn’t be New England without weather like this! #-o

You have got to love this time of year. 8O :? I don’t think I should put the snow plow away just yet.

John

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.


mix.jpg

rasn.jpg

Kevin,
You have a point. It’s an easy change in the plaintext-parser-data.txt file, just change

cond|mix|mix|mix|Mix|

to

cond|mix|rasn|rasn|Mix|

and that will do it. Don’t change the last ‘Mix’ in the line as it is used as a lookup key for the translation files.

Thanks to [b]meteoabrantes[/b] , we now have a Portuguese translation file for the script too.

http://saratoga-weather.org/plaintext-parser-lang-pt.txt or from the home page for the scripts,

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>

Best regards,
Ken

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!!

Any ideas???

I had thought about something like that in the past http://discourse.weather-watch.com/p/122577 but could never quite figure out where to start.

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.

  • Jim

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.

Stuart

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.

:slight_smile: