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.
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
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
Friday, 29-Mar-2024 2:45 PM
Aerisweather International forecast formatting script - multilingual
Aerisweather was acquired by Vaisala and rebranded as XWeather on 29-Mar-2024. I don't yet know if this changes the API endpoint as the current Aerisweather API endpoint still works. The signup (below) has changed URL to an xweather.com host.
This script is the third provider to be used for worldwide forecasts, and I hope Aerisweather will continue to offer the API. It is free for weather stations that upload to PWSweather.com and for-fee to others. While this script can be used for USA and Canada forecasts, the USA advforecast2.php and Canada EC-forecast.php scripts provide more data and alerts and should be used for those geographies.
Aerisweather DOES NOT provide international versions of the English forecast text -- it is is only one short sentence and used as the icon description.
The AW-forecast-lang.php provides translation capabilities for Saratoga Template languages for additional text added to the text forecast from data provided by Aerisweather API (i.e. Temperature High/Low, Probibility of precipation, Wind direction, speed and gust, UV index ). The AW-forecast-lang.php which has the encoded lookups for boilerplate language translations is provided as a separate script for easy update as new languages are added.
In addition, the AW-forecast.php uses the translation feature from the WXSIM plaintext-parser so you can add missing English forecast text translations easily to the associated language file.
Be sure to read/heed the ./AWlang/README-before-updating-these-files.txt file before updating the plaintext-parser-lang-LL-txt files to maintain the proper ISO-8859-n character set in the file. Otherwise, the translation may fail with odd characters in the forecast text. Yes, you can use a copy of your existing updated plaintext-parser-lang-LL-txt if you have the plaintext-parser.php script installed. Just copy it to the ./AWlang/ directory and do updates there for the AW-forecast.php use.
Currently, AW-forecast.php supports the following languages (in addition to English): af,bg,cs,ct,de,dk,el,es,fi,fr,he,hu,it,nl,no,pl,pt,ro,se,si,sk,sr
In order to use this script you need to:
- Register for and acquire a free Aerisweather API key IF your weather station is uploading to PWSweather.com.
- Browse to https://signup.xweather.com/pws-contributor and associate your pwsweather.com User ID to get your Access ID and Secret Key.
- insert the Access ID in $AWAPIkey in the AW-forecast.php script or as $SITE['AWAPIkey'] in Settings.php for Saratoga template users.
and insert the Secret Key in $AWAPIsecret in the AW-forecast.php script or as $SITE['AWAPIsecret'] in Settings.php for Saratoga template users.
- Customize the $AWforecasts array (or $SITE['AWforecasts'] in Settings.php) with the location names, latitude/longitude for your forecasts. The first entry will be the default one used for forecasts.
- Select the default units for display - 4 different unit selections are available (see below).
- Use this script ONLY on your personal, non-commercial weather station website.
- Leave attribution (and hotlink) to Aerisweather as the source of the data in the output of the script.
Adhere to these three requirements, and you should have fair use of this data from Aerisweather.
Settings in the AW-forecast.php script
// Settings ---------------------------------------------------------------
// REQUIRED: api.aerisapi.com API Access ID and Secret keys.
// If you are uploading to pwsweather.com, you can get a free key at https://www.aerisweather.com/signup/pws/
$AWAPIkey = 'specify-for-standalone-use-here'; // Aeris Access ID; use this only for standalone / non-template use
$AWAPIsecret = 'specify-for-standalone-use-here'; // Aeris Secret Key; use this only for standalone / non-template use
// NOTE: if using the Saratoga template, add to Settings.php a line with:
// $SITE['AWAPIkey'] = 'your-api-client-key-here';
// $SITE['AWAPIsecret'] = 'your-api-secret-key-here';
// and that will enable the script to operate correctly in your template
//
$iconDir ='./forecast/images/'; // directory for carterlake icons './forecast/images/'
$iconType = '.jpg'; // default type='.jpg'
// use '.gif' for animated icons fromhttp://www.meteotreviglio.com/
//
// The forecast(s) .. make sure the first entry is the default forecast location.
// The contents will be replaced by $SITE['AWforecasts'] if specified in your Settings.php
$AWforecasts = array(
// Location|lat,long (separated by | characters)
'Saratoga, CA, USA|37.27465,-122.02295',
'Auckland, NZ|-36.910,174.771', // Awhitu, Waiuku New Zealand
'Assen, NL|53.02277,6.59037',
'Blankenburg, DE|51.8089941,10.9080649',
'Cheyenne, WY, USA|41.144259,-104.83497',
'Carcassonne, FR|43.2077801,2.2790407',
'Braniewo, PL|54.3793635,19.7853585',
'Omaha, NE, USA|41.19043,-96.13114',
'Johanngeorgenstadt, DE|50.439339,12.706085',
'Athens, GR|37.97830,23.715363',
'Haifa, IL|32.7996029,34.9467358',
'Greenville, ME|45.4608,-69.5904',
'Tehachapi, CA|35.1322,-118.4491',
);
//
$maxWidth = '640px'; // max width of tables (could be '100%')
$maxIcons = 10; // max number of icons to display
$maxForecasts = 14; // max number of Text forecast periods to display
$maxForecastLegendWords = 4; // more words in forecast legend than this number will use our forecast words
$numIconsInFoldedRow = 10; // if words cause overflow of $maxWidth pixels, then put this num of icons in rows
$autoSetTemplate = true; // =true set icons based on wide/narrow template design
$cacheFileDir = './'; // default cache file directory
$cacheName = "AW-forecast-json.txt"; // locally cached page from AW
$refetchSeconds = 3600; // cache lifetime (3600sec = 60 minutes)
//
// Units:
// si: SI units (C,m/s,hPa,mm,km)
// ca: same as si, except that windSpeed and windGust are in kilometers per hour
// uk2: same as si, except that nearestStormDistance and visibility are in miles, and windSpeed and windGust in miles per hour
// us: Imperial units (F,mph,inHg,in,miles)
//
$showUnitsAs = 'ca'; // ='us' for imperial, , ='si' for metric, ='ca' for canada, ='uk2' for UK
//
$charsetOutput = 'ISO-8859-1'; // default character encoding of output
//$charsetOutput = 'UTF-8'; // for standalone use if desired
$lang = 'en'; // default language
$foldIconRow = false; // =true to display icons in rows of 5 if long texts are found
$timeFormat = 'Y-m-d H:i T'; // default time display format
$showConditions = true; // set to true to show current conditions box
// ---- end of settings ---------------------------------------------------
For Saratoga template users, you normally do not have to customize the script itself as the most common configurable settings are maintained in your Settings.php file. This allows you to just replace the AW-forecast.php on your site when new versions are released.
You DO have to add a
$SITE['AWAPIkey'] = 'your-key-here'; and a $SITE['AWforecasts] = array( ...); entries to your Settings.php file to support this and future releases of the script.
- $AWAPIkey = 'specify-for-standalone-use-here';
- This setting is for standalone use (do not change this for Saratoga templates).
Register for a Aerisweather Access ID and Secret Key at https://www.aerisweather.com/signup/pws/ and replace specify-for-standalone-use-here with the registered API Access ID. The script will nag you if this has not been done.
For Saratoga template users, do the registration at the Aerisweather API site above, then put your Access ID in your Settings.php as:
$SITE['AWAPIkey'] = 'your-key-here';
to allow easy future updates of the AW-forecast.php script by simple replacement.
- $AWAPIsecret = 'specify-for-standalone-use-here';
- This setting is for standalone use (do not change this for Saratoga templates).
Register for a Aerisweather Access ID at https://www.aerisweather.com/signup/pws/ and replace specify-for-standalone-use-here with the registered Secret Key. The script will nag you if this has not been done.
For Saratoga template users, do the registration at the Aerisweather API site above, then put your Secret Key in your Settings.php as:
$SITE['AWAPIsecret'] = 'your-key-here';
to allow easy future updates of the AW-forecast.php script by simple replacement.
- $iconDir
-
This setting controls whether to display the NOAA-styled icons on the forecast display.
Set $iconDir to the relative file path to the Saratoga Icon set (same set as used with the WXSIM plaintext-parser.php script).
Be sure to include the trailing slash in the directory specification as shown in the example above.
Saratoga template users: Use the Settings.php entry for $SITE['fcsticonsdir'] to specify this value.
- $iconType
- This setting controls the extension (type) for the icon to be displayed.
='.jpg'; for the default Saratoga JPG icon set.
='.gif'; for the Meteotriviglio animated GIF icon set.
Saratoga template users: Use the Settings.php entry for $SITE['fcsticonstype'] to specify this value.
-
- $AWforecasts = array(
// Location|forecast-URL (separated by | characters)
'Saratoga, CA, USA|37.27465,-122.02295',
'Auckland, NZ|-36.910,174.771', // Awhitu, Waiuku New Zealand
...
);
- This setting is the primary method of specifying the locations for forecasts. It allows the viewer to choose between forecasts for different areas based on a drop-down list box selection.
Each entry has the format '<location name>|<latitude>,<longitude>'. Note that latitude and longitude must use decimal-period format as shown, and positive numbers omit the '+' sign. For latitude, positive is North/negative is South of the Equator. For longitude, positive is East of GMT/negative is West of GMT.
Saratoga template users: Use the Settings.php entry for $SITE['AWforecasts'] = array(...); to specify the list of sites and URLs.
- $maxWidth
- This variable controls the maximum width of the tables for the icons and text display. It may be in pixels (as shown), or '100%'. The Saratoga/NOAA icons are 55px wide and there are up to 10 icons, so beware setting this width too small as the display may be quite strange.
- $maxIcons
- This variable specifies the maximum number of icons to display in the graphical part of the forecast. Some forecast locations may have up to 10 days of forecast (10 icons) so be careful how wide the forecast may become on the page.
- $cacheFileDir
- This setting specifies the directory to store the cache files. The default is the same directory in which the script is located.
Include the trailing slash in the directory specification.
Saratoga template users: Use the Settings.php entry for $SITE['cacheFileDir'] to specify this value.
- $cacheName
- This variable specifies the name of the cache file for the AW forecast page.
- $refetchSeconds
- This variable specifies the cache lifetime, or how long to use the cache before reloading a copy from Aerisweather. The default is 3600 seconds (60 minutes). Forecasts don't change very often, so please don't reduce it below 60 minutes to minimize your API access count and keep it to the free API usage range.
- $showUnitsAs
- This setting controls the units of measure for the forecasts.
='si' SI units (C,m/s,hPa,mm,km)
='ca' same as si, except that windSpeed and windGust are in kilometers per hour
='uk2' same as si, except that nearestStormDistance and visibility are in miles, and windSpeed and windGust in miles per hour
='us' Imperial units (F,mph,inHg,in,miles)
Saratoga template users: This setting will be overridden by the $SITE['AWshowUnitsAs'] specified in your Settings.php.
- $foldIconRow
- This setting controls 'folding' of the icons into two rows if the aggregate width of characters exceeds the $maxSize dimension in pixels.
= true; is the default (fold the row)
= false; to select not to fold the row.
Saratoga template users: Use the Settings.php entry for $SITE['foldIconRow'] to specify this value.
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. To customize translations, the appropriate language file in ./AWlang/ directory needs to be changed. See the caution in the README file in the directory before doing changes to those files.
Usage samples
<?php
$doIncludeAW = true;
include_once("AW-forecast.php");
?>
|
|
Aerisweather Forecast for:
Saratoga, CA, USA
Updated: Mon, 09-Dec-2024 7:00pm PST
|
Daily Forecast
Monday night |
Tuesday |
Tuesday night |
Wednesday |
Wednesday night |
Thursday |
Thursday night |
Friday |
Friday night |
Saturday |
|
|
|
|
|
|
|
|
|
|
Clear |
Mostly Sunny |
Partly Cloudy |
Partly Cloudy, Showers |
Mostly Cloudy, Showers |
Partly Cloudy, Scattered Showers |
Partly Cloudy, Showers |
Partly Cloudy, Showers |
Mostly Cloudy, Scattered Showers |
Mostly Cloudy, Light Rain Likely |
4.5°C |
18.4°C |
6.4°C |
18.6°C |
7.9°C |
15.5°C |
6.4°C |
15.0°C |
9.1°C |
14.6°C |
|
Monday night
|
Clear. Low: 4.5°C. Wind WNW 13.3->19.8 km/h. |
Tuesday
|
Mostly Sunny. High: 18.4°C. Wind SE 4.9->9.1 km/h. UV Index 2. |
Tuesday night
|
Partly Cloudy. Low: 6.4°C. Wind E 3.6->7.2 km/h. |
Wednesday
|
Partly Cloudy, Showers. Chance of precipitation 10%. High: 18.6°C. Wind ESE 3.6->10.8 km/h. rain ≈ 0.1mm. |
Wednesday night
|
Mostly Cloudy, Showers. Chance of precipitation 40%. Low: 7.9°C. Wind S 3.6->10.3 km/h. rain ≈ 1.6mm. |
Thursday
|
Partly Cloudy, Scattered Showers. Chance of precipitation 40%. High: 15.5°C. Wind WSW 4.3->18 km/h. UV Index 2. rain ≈ 0.3mm. |
Thursday night
|
Partly Cloudy, Showers. Chance of precipitation 10%. Low: 6.4°C. Wind NW 6.3->10.2 km/h. rain ≈ 0.2mm. |
Friday
|
Partly Cloudy, Showers. Chance of precipitation 20%. High: 15.0°C. Wind E 4.5->15.4 km/h. UV Index 2. rain ≈ 1.1mm. |
Friday night
|
Mostly Cloudy, Scattered Showers. Chance of precipitation 40%. Low: 9.1°C. Wind S 9.3->20.5 km/h. rain ≈ 3.9mm. |
Saturday
|
Mostly Cloudy, Light Rain Likely. Chance of precipitation 60%. High: 14.6°C. Wind S 9.9->21.7 km/h. rain ≈ 6.7mm. |
Saturday night
|
Partly Cloudy, Scattered Showers. Chance of precipitation 60%. Low: 8.4°C. Wind SSW 9->16.2 km/h. rain ≈ 4.9mm. |
Sunday
|
Partly Cloudy, Isolated Showers. Chance of precipitation 50%. High: 15.8°C. Wind ESE 4.8->11.4 km/h. rain ≈ 1.9mm. |
Sunday night
|
Partly Cloudy, Showers. Chance of precipitation 20%. Low: 6.9°C. Wind NNW 5.7->10.2 km/h. rain ≈ 0.1mm. |
Monday
|
Partly Cloudy, Showers. Chance of precipitation 20%. High: 15.0°C. Wind E 4.8->12.6 km/h. rain ≈ 2.6mm. |
Saratoga, CA, USA forecast by Aerisweather.com.
You can also include it 'silently' and print just a few (or all) the contents where you'd like it on the page
<?php
$doPrintAW = false;
include_once("AW-forecast.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>$AWforecasticons[0]</td><td>$AWforecasticons[1]</td>\n"; ?>
</tr>
<tr align="center" valign="top">
<?php print "<td>$AWforecasttemp[0]</td><td>$AWforecasttemp[1]</td>\n"; ?>
</tr>
</table>
Monday night
Clear | Tuesday
Mostly Sunny |
4.5°C | 18.4°C |
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\">$AWforecasticons[0]<br />$AWforecasttemp[0]</td>\n"; ?>
<?php print "<td align=\"left\" valign=\"middle\">$AWforecasttext[0]</td>\n"; ?>
</tr>
<tr valign="top">
<?php print "<td align=\"center\">$AWforecasticons[1]<br />$AWforecasttemp[1]</td>\n"; ?>
<?php print "<td align=\"left\" valign=\"middle\">$AWforecasttext[1]</td>\n"; ?>
</tr>
</table>
Monday night
Clear 4.5°C |
Clear. Low: 4.5°C. Wind WNW 13.3->19.8 km/h. |
Tuesday
Mostly Sunny 18.4°C |
Mostly Sunny. High: 18.4°C. Wind SE 4.9->9.1 km/h. UV Index 2. |
If you'd like to style the output, you can easily do so by setting a CSS for class AWforecast either in your CSS file or on the page including the AW-forecast.php (in include mode):
<style type="text/css">
.AWforecast {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9pt;
}
</style>
Installation of AW-forecast.php
Download AW-forecast.zip Package from the link below.
Optionally, 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. If you already have the plaintext-parser.php WXSIM script installed, you can use the existing icon set (no need to download again).
Change settings in AW-forecast.php for the $AWforecast address(s) and the address of the icons if necessary and upload the modified AW-forecast.php to your website.
Upload AW-forecast-lang.php and the ./AWlang directory and contents (the WXSIM translation files).
Ensure the permission on "AW-forecast.txt" cache file are at least 666 or 766 so the file is writable by the AW-forecst.php script
Download Package: AW-forecast.zip (note: contains the ./AWlang/plaintext-parser-lang-LL.txt translation files)
Demo: AW-forecast-demo.php (note: uses UTF-8 only mode)
(optional, for future updates after installing the .zip package):
Download: AW-forecast.php (Version V1.03 - 27-Dec-2022)
Download: AW-forecast-lang.php (Version 1.00 - 10-Apr-2020)
If Standalone and running in a custom page:
Download: Icon Set
(upload to your website in the /forecast/images directory)
Version history
- Version 1.03 - 27-Dec-2022 fixes for PHP 8.2
- Version 1.02 - 19-Jan-2022 fixes for PHP 8.1 Deprecated errata messagages
- Version 1.01 - 13-Apr-2020 fix for day icon shown at night with some forecasts
- Version 1.00 - 10-Apr-2020 initial release