deformed-offering

Weather station scripts - Forecast Canada

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.

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.

This page was updated Monday, 20-Nov-2017 12:34 PM

Environment Canada forecast script (for www.weatheroffice.gc.ca)

This script is along the lines of the carterlake.org NOAA 5-day script especially for the Canadian stations using Environment Canada as the source of the data. It uses a new set of customized icons with PoP displayed like the www.crh.noaa.gov website used by Tom's script. Examples:

Partly Cloudy PoP: 40% ==> Partly Cloudy
Rain and snow PoP: 100% ==> Rain and snow
Thunderstorm PoP: 70% ==> Thunderstorm

To use it, you need to download the ec-forecast-V5-02.zip file and unzip, then upload to your website. The scripts and GIF icons are included in the zip file. The script also requires the URL for the printable forecast for your area. Instructions are included with the source file and the ec-forecast-README.txt for the script.

As of V2.16, ec-forecast.php now supports the new transparent PNG icons created by Thayer Fox who has kindly permitted distribution from this site.
As of V3.00, the ZIP version contains these PNG icons.

Partly Cloudy PoP: 40% ==> Partly Cloudy
Rain and snow PoP: 100% ==> Rain and snow
Thunderstorm PoP: 70% ==> Thunderstorm

Download and unpack the ec-icons-png.zip and configure the ec-forecast.php to use the .png images in the settings area.

The script supports both English and French languages via the lang=en or lang=fr parameter. A live example of the French version (with lang=fr) is shown below.

Observed at: Hamilton Munro Int'l Airport
Date: Sunday July 22, 2018 at 19:00 EDT
Mostly Cloudy
Mostly Cloudy
Temp.: 21.4 °C
Humidex: 27
Wind: SSE 20 km/h
Humidity: 79 %
Dew point: 17.6 °C
Pressure: 101.1 kPa
Tendency: rising
Visibility: 24.1 km
Sunrise: 06:00
Sunset: 20:53
Normals:
Max 27°C Min 16°C
Yesterday
  Max: 27.2 °C
  Min: 16.7 °C
  Rainfall: 1.6 mm

 Extended Forecast - Environment Canada
  Monday
Chance of showers (40%)
Chance of showers
Max: 27°C
Tuesday
Chance of showers or thundershowers (60%)
Chance of showers or thundershowers
Max: 25°C
Wednesday
Chance of showers (40%)
Chance of showers
Max: 25°C
Thursday
Chance of showers (30%)
Chance of showers
Max: 26°C
Friday
Chance of showers (30%)
Chance of showers
Max: 23°C
Saturday
A mix of sun and cloud
A mix of sun and cloud
Max: 25°C
Sunday night
Chance of showers (30%)
Chance of showers
Min: 20°C
Monday night
Chance of showers (40%)
Chance of showers
Min: 21°C
Tuesday night
Chance of showers or thundershowers (60%)
Chance of showers or thundershowers
Min: 20°C
Wednesday night
Cloudy periods
Cloudy periods
Min: 19°C
Thursday night
Chance of showers (30%)
Chance of showers
Min: 18°C
Friday night
Chance of showers (30%)
Chance of showers
Min: 17°C

Forecast

Hamilton, ON (Issued: Sunday July 22, 2018 at 15:30 EDT)

Tonight
Mainly cloudy. 30 percent chance of showers late this evening and overnight. Wind southeast 20 km/h becoming light this evening. Low 20.
Monday
Mainly cloudy with 40 percent chance of showers. Risk of a thunderstorm in the afternoon. Wind becoming southeast 20 km/h near noon. High 27. Humidex 32. UV index 8 or very high.
Monday night
Cloudy with 40 percent chance of showers and risk of a thunderstorm. Low 21.
Tuesday
A mix of sun and cloud with 60 percent chance of showers or thunderstorms. High 25.
Tuesday night
Cloudy periods with 60 percent chance of showers or thunderstorms. Low 20.
Wednesday
A mix of sun and cloud with 40 percent chance of showers. High 25.
Wednesday night
Cloudy periods. Low 19.
Thursday
A mix of sun and cloud with 30 percent chance of showers. High 26.
Thursday night
Cloudy periods with 30 percent chance of showers. Low 18.
Friday
A mix of sun and cloud with 30 percent chance of showers. High 23.
Friday night
Cloudy periods with 30 percent chance of showers. Low 17.
Saturday
A mix of sun and cloud. High 25.
Averages and extremes
Highest temperature(1960-2011)33.9 °C2011
Lowest temperature(1960-2011)8.7 °C1992
Average high26.6 °C 
Average low15.5 °C 
Average21.1 °C 
Greatest rainfall(1960-2011)45.2 mm1960
Greatest snowfall(1960-2011)0.0 cm1960
Greatest precipitation(1960-2011)45.2 mm1960
Most snow on the ground(1970-2010)0.0 cm1970
Monthly frequency of precipitation36.0 % 

24 Hour Forecast - Hamilton, ON

Date/Time
(EDT)
Temp.
(°C)

Weather Conditions

LOP †
Wind
(km/h)

Humidex
22 July 2018
20:00 21 Mainly cloudy (20%)  Mainly cloudy Low SE 15 26
21:00 21 Mainly cloudy (20%)  Mainly cloudy Low SE 15 26
22:00 20 Chance of showers (30%)  Chance of showers Low SE 15 25
23:00 20 Chance of showers (30%)  Chance of showers Low SE 15 25
23 July 2018
00:00 20 Chance of showers (30%)  Chance of showers Low SE 15 25
01:00 20 Chance of showers (30%)  Chance of showers Low SE 15
02:00 20 Chance of showers (30%)  Chance of showers Low SE 15
03:00 20 Chance of showers (30%)  Chance of showers Low SE 15
04:00 20 Chance of showers (30%)  Chance of showers Low SE 15
05:00 20 Chance of showers (30%)  Chance of showers Low SE 15
06:00 20 Chance of showers (40%)  Chance of showers Low SE 15
07:00 21 Chance of showers (40%)  Chance of showers Low SE 15 25
08:00 21 Chance of showers (40%)  Chance of showers Low SE 15 26
09:00 22 Chance of showers (40%)  Chance of showers Low SE 15 27
10:00 22 Chance of showers (40%)  Chance of showers Low SE 15 27
11:00 23 Chance of showers (40%)  Chance of showers Low SE 15 28
12:00 24 Chance of showers. Risk of thunderstorms (40%)  Chance of showers. Risk of thunderstorms Low SE 20 29
13:00 24 Chance of showers. Risk of thunderstorms (40%)  Chance of showers. Risk of thunderstorms Low SE 20 29
14:00 25 Chance of showers. Risk of thunderstorms (40%)  Chance of showers. Risk of thunderstorms Low SE 20 30
15:00 26 Chance of showers. Risk of thunderstorms (40%)  Chance of showers. Risk of thunderstorms Low SE 20 31
16:00 26 Chance of showers. Risk of thunderstorms (40%)  Chance of showers. Risk of thunderstorms Low SE 20 31
17:00 27 Chance of showers. Risk of thunderstorms (40%)  Chance of showers. Risk of thunderstorms Low SE 20 32
18:00 26 Chance of showers. Risk of thunderstorms (40%)  Chance of showers. Risk of thunderstorms Low SE 15 32
19:00 25 Chance of showers. Risk of thunderstorms (40%)  Chance of showers. Risk of thunderstorms Low SE 15 32
 
† Likelihood of Precipitation (LOP) as described in the public forecast as a chance of measurable precipitation for a period of time.
  Nil: 0%
  Low: 40% or below
  Medium: 60% or 70%
  High: Above 70%
‡ Value not significant

Environment Canada

With Version 1.08, a new $currentConditions string is formatted with the current conditions of the selected city. If the city's conditions are based on a nearby airport, then a current conditions icon and short weather description are included. You can enable automatic printout by using $showConditions = true; in the ec-forecast.php script which will cause it to print before the alerts and forecast section. If you're 'quitely' including the script on your page, you can still print $currentConditions; where you'd like the conditions display to appear.

Version 2.00 brings a major rewrite of the script to accomodate a major change in the EC Forecast pages. Included with the .ZIP distribution are the new icons now in use by EC for the forecast site. The V2.00 script is compatible with the prior icon set distributed with the Version 1.nn script.

Version 2.16 included multi-forecast capability, improved diagnostics, support for the new transparent PNG icons, and additional settings for display of date with icon and/or detail forecast legend.

Version 3.00 is a major rewrite to support the EC website changes in October, 2014. The .zip distribution now includes the current .PNG format weather icons with POP stamps.

Version 3.02 has a major change in display of the temperature forecasts with the icons. It is now done by an extract of the value from the detail text forecast instead of the old method of using the values from the icon HTML. This should provide a more consistent presentation of Min/Max values for the icons.

Version 4.02 now uses cURL functions and uses HTTPS to access the EC website.

Version 5.00 is a major rewrite of the script to use the EC XML data instead of page scraping the EC website. V5.00 includes an Almanac and a 24-hour rolling forecast that can be displayed via new settings (default is to display both). The XML parsing should insulate us from further tweaks with the EC website page design as the XML format is unchanged for many years.

Observed at: Hamilton Munro Int'l Airport
Date: Sunday July 22, 2018 at 19:00 EDT
Mostly Cloudy
Mostly Cloudy
Temp.: 21.4 °C
Humidex: 27
Wind: SSE 20 km/h
Humidity: 79 %
Dew point: 17.6 °C
Pressure: 101.1 kPa
Tendency: rising
Visibility: 24.1 km
Sunrise: 06:00
Sunset: 20:53
Normals:
Max 27°C Min 16°C
Yesterday
  Max: 27.2 °C
  Min: 16.7 °C
  Rainfall: 1.6 mm

You can also access the 'maxmin' for the location (where available on the EC site) by using

 <?php
print "For this date:<br/>\n";
print $conditions['maxmin'] . "<br/>\n";
?>

which would show:

For this date:
Normals: Max 27°C Min 16°C

Environment Canada Forecast PHP script: demo, in-page demo, and download package ,
download ec-forecast.php source only
download required ec-forecast-lookup.txt source only [ see version history ].

Version history

  • Version 5.02 - 20-Nov-2017 - added wind-gust display to conditions box and hourly display, fix no conds icon issue
  • Version 5.01 - 07-Nov-2017 - added windchill display to conditions box
  • Version 5.00 - 27-Sep-2017 - major rewrite of the script to use EC XML data instead of page scraping the EC website. Added Almanac and 24-hour rolling forecast displays.
  • Version 4.03 - 31-Aug-2017 - fixes for icons due to EC website changes
  • Version 4.02 - 22-Feb-2017 - force HTTPS to EC website, improved error handling
  • Version 4.01 - 27-Oct-2016 - fix for conditions icon extract, yesterday data, use curl fetch for URL
  • Version 4.00 - 22-Oct-2016 - rewrite for major EC website design changes
  • Version 3.05 - 16-Dec-2015 - fixes for temperature forecast wording changes+extraction
  • Version 3.04 - 14-Dec-2015 - fixes for change in EC website (chunked+gzipped response)
  • Version 3.03 - 01-Dec-2015 - fixes for current conditions due to EC website changes.
  • Version 3.02 - 29-Apr-2015 - fixes for major change in EC website. Temperatures now extracted from detailed text forecasts.
  • Version 3.01 - 23-Dec-2014 - fixes for 'Normals'/'Sun times' extracts, text forecast, and .png PoP icons
  • Version 3.00 - 17-Oct-2014 - major rewrite of the script to support major EC website structure changes.
  • Version 2.17 - 15-May-2013 - fixes for changes in EC website structure (again)
  • Version 2.16 - 13-May-2013 - added settings to display days of week w/o day month for icons and detail area;
    icon type selection for .gif/.png; added debugging code for EC website fetch; added multi-forecast capability
  • Version 2.15 - 17-Apr-2013 - fixes for $title display with new EC website structure
  • Version 2.14 - 16-Apr-2013 - fixes for changes in EC website structure and UTF-8 conversion
  • Version 2.13 - 30-May-2011 - fixed handling of $SITE['fcsticonsdirEC'] when used with template
  • Version 2.12 - 19-Feb-2011 - added color formatting to watch/warning/ended alerts from EC in $alertstring output
  • Version 2.11 - 26-May-2010 - fixed to handle changes to EC website for humidex/wind-chill

 

deformed-offering