deformed-offering

Weather station scripts

They're free, but use at your own risk

The scripts referenced here are used in the operation of this weather station, and may be freely copied and used to support your station. Please note that you use these scripts at your own risk. No warranty is expressed or implied. I accept no liability for any damages that may ensue from their use.
You will need to configure them for your own particular weather station website.
RSS feed for Scripts Updates A RSS Feed is available to help keep you informed on updates to the scripts.

Many of these scripts are now available on GitHub at https://github.com/ktrue

Buy Me A Coffee If you find one or more of the scripts useful to you, please consider making a donation to help offset the routine expenses of operation of this website.
Thanks for your kind support!

A Version History is available -- check back from time to time to see if there are updates to scripts you have downloaded earlier. Announcements of version updates and new scripts are made on WXForum.net and Weather-Watch forums and saratogaWXPHP Twitter account as they become available.

Note: Twitter widget has been disabled 3-Jul-2023 since it no longer displays the recent update Tweets.

This page was updated Wednesday, 01-Jul-2020 10:57 AM

WXSIM forecast formatting scripts

Tom Ehrensberger has created a great program called WXSIM to create text weather forecasts based on observation data from public sources and your own weather station. The program produces a text file (plaintext.txt) that has a detailed forecast like this:

   WXSIM text forecast for Saratoga, initialized at  8:00 AM Mar 24, 2007
 _______________________________________________________________________________
 
 Today: Partly cloudy in the morning, becoming partly to mostly cloudy in the
 afternoon. Patchy light fog in the morning. High 71. UV index up to 6. Wind west
 around 2 mph in the morning, becoming 7 mph in the afternoon.
 
 Tonight: Mostly cloudy to cloudy in the evening, becoming cloudy after midnight.
 A slight chance of rain. Low 51. Wind west around 4 mph. Chance of precipitation
 less than 20 percent. Precipitation mostly less than a tenth of an inch.
 
 Sunday: Cloudy. A slight chance of rain. High 63. Wind west around 3 mph. Chance
 of precipitation less than 20 percent. Precipitation mostly less than a tenth of
 an inch.
 
 Sunday night: Cloudy. A slight chance of rain. Low 50. Wind west around 2 mph in
 the evening, becoming south-southwest after midnight. Chance of precipitation
 less than 20 percent. Precipitation mostly less than a tenth of an inch.
 
 Monday: Cloudy in the morning, becoming mostly cloudy to cloudy in the
 afternoon. Patchy light fog in the afternoon. A chance of rain in the morning,
 then rain likely in the afternoon. High 57. Wind southwest around 7 mph, gusting
 to 14 mph, in the morning, becoming 12 mph in the afternoon. Chance of
 precipitation 70 percent. Precipitation mostly between half an inch and one inch.
 
 Monday night: Cloudy. Light to moderate fog. Rain likely. Low 50. Wind west
 around 6 mph. Chance of precipitation 60 percent. Precipitation mostly around a
 quarter of an inch.
 
 Tuesday: Mostly cloudy in the morning, becoming partly to mostly cloudy in the
 afternoon. Light to moderate fog in the morning. A chance of rain. High 58. UV
 index up to 6. Wind west around 6 mph, gusting to 13 mph, in the morning,
 becoming 15 mph in the afternoon. Chance of precipitation 20 percent.
 Precipitation mostly less than a tenth of an inch.
 
 Tuesday night: Partly to mostly cloudy in the evening, becoming fair to partly
 cloudy after midnight. Low 41. Wind northwest around 10 mph, gusting to 16 mph,
 in the evening, becoming 6 mph after midnight.
 
 Wednesday: Mostly sunny in the morning, becoming sunny in the afternoon. High
 61. UV index up to 8. Wind north-northwest around 5 mph.
 
 Wednesday night: Clear. Low 38. Wind northwest around 6 mph.
 
 * THIS FORECAST WAS MADE IN AUTOMATED MODE AND MAY BE LESS ACCURATE THAN OTHERWISE *

These scripts will read the plaintext.txt forecast and produce other displays of the information including condition icons, and translate the English to other languages.

plaintext-parser.php (NOAA-style WXSIM forecast display - multilingual)

I started this script based on an idea from Gerard in the Netherlands. He had adapted Jordan Gerth's wsofd.php script to convert the plaintext.txt English forecast into Dutch. (see the Weather-Watch.com thread here).
I thought this 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 Saratoga icon set, would be easy to include in a weather website, and have built-in support for translations to other languages.

My special thanks go to Jordan Gerth for creating the first set of plaintext.txt parsing/display functions, to Gerard for his pioneering work on a Dutch translation, and to the folks who generated the language translation files (listed below) that this script uses. Thanks to your all! I hope you enjoy the script/translations .. this was truly an international effort.

The plaintext.txt forecast by WXSIM is a shorthand form of the English language which is easily recognizable by native speakers, as similar words/phrases are used by our National Weather Service, TV, radio and newspapers. This "weather speak" usually has only nouns and adjectives (with prepositions, conjunctions and articles) and no verbs, so it is not necessarily a fully grammatical English sentence. Likewise, the translations are not intended to be full translations (since they also have no verbs), but are recognizable and informative to native speakers as "weather speak", just like the English "weather speak' from which they are derived.

The translation is performed by an ordered set of substitutions arranged in the plaintext-parser-lang-XX.txt file which is applied to the English plaintext.txt output of WXSIM. The result is a set of Icons depicting the prevailing condition during the period, along with the High/Low temperature and UV Index forecast. The text part of the forecast is translated in the same manner. If no language file is found, the forecast defaults to English.

Settings in the plaintext-parser.php script

// Settings ---------------------------------------------------------------
$iconDir ='./forecast/images/';           // directory for carterlake icons
$iconType = '.jpg';        // default type='.jpg' -- use '.gif' for animated icons from http://www.meteotreviglio.com/
$WXSIMstation = "Saratoga-Weather.org";   // name of your weather station
$plaintextFile = './plaintext.txt';       // location of the WXSIM plaintext.txt
$lang = 'en';                             // default language is 'en' = English
$tempDegrees = '°';                   // set to '' to omit degree sign
//                                        //   or set to '°', '°F' or '°C'
$maxIcons = 10;                           // set to maximum number of icons to display
$maxWidth = '640px';                      // max width of tables (could be '100%')
$minPoP = '40';                           // PoP must be this or above to display
//                                        // rain icon, otherwise sky icon w/PoP displayed.
$showBeaufort = 'T';					  // set to false to not display Beaufort at all
//										  // ='V' for 'n Bft', ='T' for translated name
$showHumidex = true;                      // =true to display Humidex (Hdx), =false to suppress display
$showFrost = true;                        // =true to display frost, =false to suppress display
$showHeatIDX = true;                      // =true to display Heat-Index (HI), =false to suppress display
$showHotIconF = 100;                      // show Hot icon if Heat-Index >= value
$showHotIconC = 37.7;                     // show Hot icon if Humidex >= value
//
$showWindChill = true;                    // =true to display Wind-Chill, =false to suppress display
$showColdvalF = 26;                      // show Cold! if Wind-Chill <= value in F
$showColdvalC = -3;                      // show Cold! if Wind-Chill <= value in C
$uomTemp   = 'C';                        // ='C' if forecast temperature in Centigrade, ='F' if in Fahrenheit
// ---- end of settings ---------------------------------------------------

Make sure that $iconDir points to the relative URL address of your carterlake Icon set, and that $plaintextFile points to the relative URL address of your WXSIM plaintext.txt file on your website.
Change $WXSIMstation to the text you'd like to appear in the heading of the forecast page.
Change $lang to to the ISO abbreviation for the country from the language files listed below (if you want to change the default language from English).

More documentation is contained in the script itself about variable names/arrays made available, and the contents. The samples below serve to illustrate some of the possible usages on your weather website.

Usage samples

<?php
$doInclude = true;
include_once("plaintext-parser.php"); ?>

will show:
Language: | Afrikaans | български език | Català | Dansk | Nederlands | English | Suomi | Français | Deutsch | Ελληνικά | עִבְרִית | Italiano | Norsk | Polski | Português | Español | Svenska | Sloveňšcina |

WXSIM Прогноза за: Saratoga
Публикувана от: Saratoga-Weather.org
Актуализирана: Четвъртък, 28-Mar-2024 02:00 pm
 
Този
следобед
Предимно облачно
Предимно облачно
Довечера

Предимно облачно
Предимно облачно
Петък

Вероятност за дъжд
Вероятност за дъжд
Петък
вечер
Вероятност за дъжд
Вероятност за дъжд
Събота

Вероятен дъжд
Вероятен дъжд
Събота
вечер
Мъгла по-късно
Мъгла по-късно
Неделя

Мъгла преди обяд
Мъгла преди обяд
Неделя
вечер
Частична облачност
Частична облачност
Понеделник

Слънчево
Слънчево
Понеделник
вечер
Ясно
Ясно
<.1 in. .5 in. .25 in. .1 in. <.1 in. <.1 in.
Макс. 64° Мин. 45° Макс. 47° Мин. 46° Макс. 59° Мин. 45° Макс. 54° Мин. 42° Макс. 68° Мин. 45°
                   
СЗ
6-16
mph
Умерен бриз
ЗСЗ
3-15
mph
Умерен бриз
ЮИ
4-15→9-15
mph
Умерен бриз
ЮЮИ
9-16
mph
Умерен бриз
И
4
mph
Лек бриз
С
тихо

Тихо
ЗЮЗ
2→8-18
mph
Умерен бриз
З→ССЗ
2-16
mph
Умерен бриз
СЗ→ЮЮИ
тихо

Тихо
СЗ
2
mph
Лек полъх
UV: 6
 Висок 

 

Този следобед
 
Предимно облачно. Макс.t: 64°. Вятър СЗ около 6 mph, с пориви до 16 mph.
Довечера
 
Предимно облачно през вечерта, преминавайки в облачно след полунощ. Незначителна вероятност за дъжд след полунощ. Мин.t: 45°. Вятър западно-СЗ около 3 mph, с пориви до 15 mph. Възможни превалявания по-малко от 20 %. Превалявания не повече от 0.1 един инч.
Петък
 
Гъста облачност през сутринта, преминавайки в облачно през следобеда. Разкъсана облачност лека мъгла през следобеда. вероятност за дъжд през сутринта, и дъжд вероятно през следобеда. Макс.t: 47°. Вятър ЮИ около 4 mph, с пориви до 15 mph, през сутринта, преминавайки в 9 mph, с пориви до 15 mph, през следобеда. Възможни превалявания 80 %. Превалявания предимно около 0.5 инч.
Петък вечер
 
Частично до предимно облачно през вечерта, преминавайки в предимно облачно до облачно след полунощ. Лека до умерен мъгла. Дъжд предимно. Мин.t: 46°, ,но повишение на температурите след полунощ. Вятър юго-ЮИ около 9 mph, с пориви до 16 mph. Възможни превалявания 70 %. Превалявания предимно около 0.25 един инч.
Събота
 
Предимно облачно до облачно през сутринта, преминавайки в облачно през следобеда. Лека до умерен мъгла през сутринта. Незначителна вероятност за дъжд през сутринта, след това вероятност за дъжд през следобеда. Макс.t: 59°. Вятър изток около 4 mph. Възможни превалявания 50 %. Превалявания предимно около 0.1 един инч.
Събота вечер
 
Предимно облачно до облачно през вечерта, преминавайки в частично облачно след полунощ. Разкъсана облачност лека мъгла след полунощ. Незначителна вероятност за дъжд през вечерта. Мин.t: 45°. Вятър север около тихо. Възможни превалявания 30 %. Превалявания не повече от 0.1 един инч.
Неделя
 
Облачно сутрин, преминавайки в гъста облачност през следобеда. Разкъсана облачност лека мъгла през сутринта. Незначителна вероятност за дъжд. Макс.t: 54°. Вятър западно-ЮЗ около 2 mph през сутринта, преминавайки в 8 mph, с пориви до 18 mph, през следобеда. Възможни превалявания 20 %. Превалявания не повече от 0.1 един инч.
Неделя вечер
 
Тихо до частично облачно през вечерта, преминавайки в ясно след полунощ. Мин.t: 42°. Вятър запад около 2 mph, с пориви до 16 mph, през вечерта, преминавайки в северо-СЗ след полунощ.
Понеделник
 
Слънчево. Макс.t: 68°. UV index до 6. Вятър СЗ около тихо през сутринта, преминавайки в юго-ЮИ през следобеда.
Понеделник вечер
 
Ясно. Мин.t: 45°. Вятър СЗ около 2 mph.
Вторник
 
Слънчево. Макс.t: 72°. UV index до 7. Вятър СЗ около 3 mph, с пориви до 15 mph, през сутринта, преминавайки в юго-ЮИ през следобеда.
Вторник вечер
 
Ясно. Мин.t: 46°. Вятър западно-СЗ около 2 mph.
Сряда
 
Слънчево през сутринта, преминавайки в частично до предимно слънчево през следобеда. Макс.t: 74°. UV index до 7. Вятър западно-СЗ около 2 mph през сутринта, преминавайки в юг през следобеда.
Сряда вечер
 
Предимно облачно. Незначителна вероятност за дъжд след полунощ. Мин.t: 51°. Вятър западно-СЗ около 2 mph. Възможни превалявания по-малко от 20 %. Превалявания не повече от 0.1 един инч.

WXSIM forecast formatting script by Saratoga-Weather.org.

You can also include it 'silently' and print just a few (or all) the contents where you'd like it on the page

<?php
$doPrint = false;
include_once("plaintext-parser.php"); ?>

then on your page, the following code would display just the current and next time period forecast:

 <table>
<tr align="center" valign="top">
<?php print "<td>$WXSIMicons[0]</td><td>$WXSIMicons[1]</td>\n"; ?>
</tr>
<tr align="center" valign="top">
<?php print "<td>$WXSIMtemp[0]</td><td>$WXSIMtemp[1]</td>\n"; ?>
</tr>
</table>
Този
следобед
Предимно облачно
Предимно облачно
Довечера

Предимно облачно
Предимно облачно
Макс. 64°Мин. 45°

Or if you'd like to include the immediate forecast with text for the next two cycles:

<table>
<tr valign="top">
<?php print "<td align=\"center\">$WXSIMicons[0]<br />$WXSIMtemp[0]</td>\n"; ?>
<?php print "<td align=\"left\" valign=\"middle\">$WXSIMtext[0]</td>\n"; ?>
</tr>
<tr valign="top">
<?php print "<td align=\"center\">$WXSIMicons[1]<br />$WXSIMtemp[1]</td>\n"; ?>
<?php print "<td align=\"left\" valign=\"middle\">$WXSIMtext[1]</td>\n"; ?>
</tr>
</table>

Този
следобед
Предимно облачно
Предимно облачно
Макс. 64°
Предимно облачно. Макс.t: 64°. Вятър СЗ около 6 mph, с пориви до 16 mph.
Довечера

Предимно облачно
Предимно облачно
Мин. 45°
Предимно облачно през вечерта, преминавайки в облачно след полунощ. Незначителна вероятност за дъжд след полунощ. Мин.t: 45°. Вятър западно-СЗ около 3 mph, с пориви до 15 mph. Възможни превалявания по-малко от 20 %. Превалявания не повече от 0.1 един инч.

You can also present the NWS and WXSIM forecasts together by using:

<?php $doPrintNWS = false; include_once("advforecast2.php"); ?>
<?php $doPrint = false; include_once("plaintext-parser.php"); ?>

<table>
<tr><th align="center">NWS</th><th align="center">WXSIM</th><th>Forecast</th></tr>
<tr valign="top">
<?php print "<td align=\"center\">$forecasticons[0]<br />$forecasttemp[0]</td>\n"; ?>
<?php print "<td align=\"center\">$WXSIMicons[0]<br />$WXSIMtemp[0]</td>\n"; ?>
<?php print "<td align=\"left\" valign=\"middle\">NWS: $forecasttext[0]<br/><br/>
WXSIM: $WXSIMtext[0]</td>\n"; ?>
</tr>
<tr valign="top">
<?php print "<td align=\"center\">$forecasticons[1]<br />$forecasttemp[1]</td>\n"; ?>
<?php print "<td align=\"center\">$WXSIMicons[1]<br />$WXSIMtemp[1]</td>\n"; ?>
<?php print "<td align=\"left\" valign=\"middle\">NWS: $forecasttext[1]<br/><br/>
WXSIM: $WXSIMtext[1]</td>\n"; ?>
</tr>
</table>

NWSWXSIMForecast
This
Afternoon
This Afternoon: Slight Chance Rain Showers
Slight Chance Rain Showers

Hi 61 °F ↓
Този
следобед
Предимно облачно
Предимно облачно
Макс. 64°
NWS: A slight chance of rain showers before 5pm. Mostly cloudy. High near 61, with temperatures falling to around 59 in the afternoon. West northwest wind around 9 mph. Chance of precipitation is 20%.

WXSIM: Предимно облачно. Макс.t: 64°. Вятър СЗ около 6 mph, с пориви до 16 mph.
Tonight

Tonight: Mostly Cloudy then Light Rain Likely
Mostly Cloudy then Light Rain Likely

Lo 46 °F
Довечера

Предимно облачно
Предимно облачно
Мин. 45°
NWS: Rain likely after 5am. Mostly cloudy, with a low around 46. West southwest wind 2 to 8 mph. Chance of precipitation is 70%. New rainfall amounts between a tenth and quarter of an inch possible.

WXSIM: Предимно облачно през вечерта, преминавайки в облачно след полунощ. Незначителна вероятност за дъжд след полунощ. Мин.t: 45°. Вятър западно-СЗ около 3 mph, с пориви до 15 mph. Възможни превалявания по-малко от 20 %. Превалявания не повече от 0.1 един инч.

If you'd like to style the output, you can easily do so by setting a CSS for class WXSIMforecast either in your CSS file or on the page including the plaintext-parser.php (in include mode):

<style type="text/css">  
.WXSIMforecast {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 9pt;
}
</style>

Installation of plaintext-parser.php

Download plaintext-parser.php and plaintext-parser-data.txt from links below and place in same directory on your website. The document root directory is prefered, although the script can be located in a subdirectory as long as the relative addressing of the icons is changed in the script.

Download the Icon set (or just the Add-on Icons if you already have the Carterlake NOAA Icon set), and upload to /forecast/images directory.

Change settings in plaintext-parser.php to reflect location of your plaintext.txt file from WXSIM and the relative URL address of the icons if necessary and upload the modified plaintext-parser.php to your website.

For additional languages, download one or more language plugin files and upload to the same directory as the plaintext-parser.php. You can change plaintext-parser '$lang =' setting to the default language of your choice.

Download: plaintext-parser.php (Version 1.31) and plaintext-parser-data.txt (Version 1.07) (both files are required)
Download: Icon Set (upload to your website in the /forecast/images directory)
Note: If you have the icon set from Tom ( http://members.cox.net/carterlakeweather/forecasticons.zip)
then please download Add-on Icons to Tom's set and upload to your /forecast/images directory.
It contains images to support the "show sky conditions when chance rain and PoP < $minPoP" logic.

Optional language translation plugins: (install in same directory as plaintext-parser.php)

Language Demo Download
(right click, save file)
Updated (UTC) Translation thanks to:
Afrikaans Demo plaintext-parser-lang-af.txt 22 Feb 2019 19:03:18 Jens at Namibia Weather
Bulgarian Demo plaintext-parser-lang-bg.txt 22 Feb 2019 19:03:18 Radmil at vremeto.org
Catalan Demo plaintext-parser-lang-ct.txt 22 Feb 2019 19:03:18 Pere at casacota.cat
Danish Demo plaintext-parser-lang-dk.txt 22 Feb 2019 19:03:18 Henrik at silkeborg-vejret.dk
Dutch Demo plaintext-parser-lang-nl.txt 22 Feb 2019 19:03:18 Oebel at Weerstation Marsdijk.nl
Finnish Demo plaintext-parser-lang-fi.txt 22 Feb 2019 19:03:18 Henkka at nordicweather.net
French Demo plaintext-parser-lang-fr.txt 22 Feb 2019 19:03:18 Brian at cypenv.org
German Demo plaintext-parser-lang-de.txt 22 Feb 2019 19:03:18 Fredi at abc-laboratory.com
Greek Demo plaintext-parser-lang-el.txt 22 Feb 2019 19:03:18 Thanos at meteothes.gr
Italian Demo plaintext-parser-lang-it.txt 22 Feb 2019 19:03:18 Alessandro at meteocarmignano.it
Hebrew Demo plaintext-parser-lang-he.txt 22 Feb 2019 19:03:18 Eli at evweather.info
Hungarian Demo plaintext-parser-lang-hu.txt 22 Feb 2019 19:03:18 Attila at huweather.com
Norwegian Demo plaintext-parser-lang-no.txt 22 Feb 2019 19:03:18 Ronny at lynradar.no
Polish Demo plaintext-parser-lang-pl.txt 22 Feb 2019 19:03:18 Andrezej at Andretti.pl
Portuguese Demo plaintext-parser-lang-pt.txt 22 Feb 2019 19:03:18 Hщlder at Meteoabrantes
Spanish Demo plaintext-parser-lang-es.txt 22 Feb 2019 19:03:18 Luis at Aerolugo
Swedish Demo plaintext-parser-lang-se.txt 22 Feb 2019 19:03:18 Bo at Lerum
Slovenian Demo plaintext-parser-lang-si.txt 22 Feb 2019 19:03:18 Markos at Okroglo

Note: if you'd like to generate a language translation file for a new language, please let me know .. I'm happy to support your efforts!


plaintext-rss.php - WXSIM Forecast RSS Feed Script

This script is an add-on to the plaintext-parser.php script described above. The script will generate a valid RSS 2.0 XML feed for your forecast. with full support for all language translations supplied with plaintext-parser.php.

To install, download the script (link below) and place in SAME DIRECTORY as plaintext-parser.php. You'll also need to use V1.03 or later of the plaintext-parser.php script as it has some minor changes to make the XML generation work properly. Then change the settings in plaintext-rss.php to match your local configuration:

 

// Settings ---------------------------------------------------------------
//
  $ourTZ = "PST8PDT";  //NOTE: this *MUST* be set correctly to
// translate UTC times to your LOCAL time for the displays.
//  http://saratoga-weather.org/timezone.txt  has the list of timezone names
//  pick the one that is closest to your location and put in $ourTZ
// also available is the list of country codes (helpful to pick your zone
//  from the timezone.txt table
//  http://saratoga-weather.org/country-codes.txt : list of country codes
  $ourLinkPage = '/WXSIM-forecast.php'; // set to your page name to display
//				// the full forecast using your template
  $ourEmail = 'webmaster@saratoga-weather.org';  // set to your email address
//
  $absIconDir = '/forecast/images/'; // set to absolute web address of images
//                                       without './' or '../' and include
//                                       trailing '/'
// ---- end of settings ---------------------------------------------------

Set $ourTZ to the timezone for your forecast.
Set $ourLinkPage to the relative (from the document root of your website) address for your detailed WXSIM forecast page.
Set $ourEmail to YOUR email address (webmaster@your.site.com).
Set $absIconDir to the web address of your Icons directory (starting at the document root of your website). This is probably the most vexing setting to make as it has to be perfect to make the images appear in the RSS feed. It should be the same as the plaintext-parser.php $iconDir with all the relative addressing resolved. Here's some samples to give you an idea about how it should be set. it assumes that the icons are in ./forecast/images/ dir :

 

Website URL

plaintext-parser.php
$iconDir

plaintext-rss.php
$absIconDir
http://some.site.com/plaintext-rss.php ./forecast/images/ /forecast/images/
http://some.site.com/subdir/plaintext-rss.php ./forecast/images/ /subdir/forecast/images/
http://some.site.com/subdir/plaintext-rss.php /forecast/images/ /forecast/images/
http://some.site.com/subdir/dir2/plaintext-rss.php ../forecast/images/ /subdir/forecast/images/

Download plaintext-rss.php (V1.10 - 29-Jan-2019) Version History

Demo of script:
Language: | Afrikaans | български език | Català | Dansk | Nederlands | English | Suomi | Français | Deutsch | Ελληνικά | עִבְרִית | Italiano | Norsk | Polski | Português | Español | Svenska | Sloveňšcina |

deformed-offering