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.

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 Thursday, 18-May-2023 9:22 AM

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-06.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: Winnipeg Richardson Int'l Airport
Date: Friday December 08, 2023 at 03:00 CST
Mostly Cloudy
Mostly Cloudy
Temp.: 0.7 °C
Wind: NE 15 km/h
Humidity: 87 %
Dew point: -1.2 °C
Pressure: 99.2 kPa
Tendency: falling
Visibility: 24.1 km
Sunrise: 08:13
Sunset: 16:27
Normals:
Max -9°C Min -18°C
Yesterday
  Max: 8.6 °C
  Min: -1.3 °C
  Rainfall: 0.0 mm

 Extended Forecast - Environment Canada
  Friday
Periods of rain or snow
Periods of rain or snow
Max: 1°C
Saturday
Cloudy
Cloudy
Max: -7°C
Sunday
A mix of sun and cloud
A mix of sun and cloud
Max: -8°C
Monday
Sunny
Sunny
Max: -4°C
Tuesday
Sunny
Sunny
Max: -12°C
Wednesday
Sunny
Sunny
Max: -1°C
Thursday night
Mainly cloudy
Mainly cloudy
Min: 0°C
Friday night
Snow and blowing snow
Snow and blowing snow
Min: -8°C
Saturday night
Cloudy periods
Cloudy periods
Min: -13°C
Sunday night
Clear
Clear
Min: -8°C
Monday night
Clear
Clear
Min: -17°C
Tuesday night
Clear
Clear
Min: -13°C

Forecast

Winnipeg, MB (Issued: Thursday December 07, 2023 at 16:00 CST)

Tonight
Mainly cloudy. Wind southeast 20 km/h becoming light overnight. Low zero.
Friday
Periods of rain changing to snow in the afternoon. Risk of freezing rain early in the morning. Snowfall amount 2 cm. Wind becoming northwest 30 km/h gusting to 50 near noon. High plus 1. Wind chill minus 11 in the afternoon.
Friday night
Snow ending overnight then cloudy. Blowing snow. Amount 2 to 4 cm. Wind north 50 km/h gusting to 70. Low minus 8. Wind chill minus 11 in the evening and minus 18 overnight.
Saturday
Cloudy. High minus 7.
Saturday night
Cloudy periods. Low minus 13.
Sunday
A mix of sun and cloud. High minus 8.
Sunday night
Clear. Low minus 8.
Monday
Sunny. High minus 4.
Monday night
Clear. Low minus 17.
Tuesday
Sunny. High minus 12.
Tuesday night
Clear. Low minus 13.
Wednesday
Sunny. High minus 1.
Averages and extremes
Highest temperature(1938-2007)5.6 °C1939
Lowest temperature(1938-2007)-34.4 °C1976
Average high-8.1 °C 
Average low-17.2 °C 
Average-12.7 °C 
Greatest rainfall(1938-2006)5.8 mm1973
Greatest snowfall(1938-2006)7.6 cm1940
Greatest precipitation(1938-2007)10.2 mm1973
Most snow on the ground(1955-2002)56.0 cm1958
Monthly frequency of precipitation38.0 % 

24 Hour Forecast - Winnipeg, MB

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

Weather Conditions

LOP †
Wind
(km/h)
Wind
Chill
8 December 2023
04:00 1 Mainly cloudy (20%)  Mainly cloudy Low NE 10
05:00 0 Mainly cloudy (20%)  Mainly cloudy Low NE 10
06:00 0 Periods of rain. Risk of freezing rain (100%)  Periods of rain. Risk of freezing rain High NE 10
07:00 0 Periods of rain. Risk of freezing rain (100%)  Periods of rain. Risk of freezing rain High NE 10
08:00 0 Periods of rain. Risk of freezing rain (100%)  Periods of rain. Risk of freezing rain High NE 10
09:00 0 Periods of rain (100%)  Periods of rain High NE 10
10:00 0 Periods of rain (100%)  Periods of rain High NE 10
11:00 1 Periods of rain (100%)  Periods of rain High NE 10
12:00 1 Periods of rain (100%)  Periods of rain High NW 30 gust 50
13:00 1 Periods of rain (100%)  Periods of rain High NW 30 gust 50
14:00 1 Periods of rain (100%)  Periods of rain High NW 30 gust 50
15:00 1 Snow (100%)  Snow High NW 30 gust 50
16:00 0 Snow (100%)  Snow High NW 30 gust 50
17:00 -1 Snow (100%)  Snow High NW 30 gust 50 -8
18:00 -2 Snow and blowing snow (100%)  Snow and blowing snow High N 50 gust 70 -11
19:00 -3 Snow and blowing snow (100%)  Snow and blowing snow High N 50 gust 70 -12
20:00 -3 Snow and blowing snow (100%)  Snow and blowing snow High N 50 gust 70 -13
21:00 -4 Snow and blowing snow (100%)  Snow and blowing snow High N 50 gust 70 -14
22:00 -4 Snow and blowing snow (100%)  Snow and blowing snow High N 50 gust 70 -14
23:00 -5 Snow and blowing snow (100%)  Snow and blowing snow High N 50 gust 70 -15
9 December 2023
00:00 -5 Snow and blowing snow (100%)  Snow and blowing snow High N 50 gust 70 -15
01:00 -6 Snow and blowing snow (100%)  Snow and blowing snow High N 50 gust 70 -16
02:00 -6 Snow and blowing snow (100%)  Snow and blowing snow High N 50 gust 70 -17
03:00 -7 Blowing snow (20%)  Blowing snow Low N 40 gust 60 -17
 
† 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: Winnipeg Richardson Int'l Airport
Date: Friday December 08, 2023 at 03:00 CST
Mostly Cloudy
Mostly Cloudy
Temp.: 0.7 °C
Wind: NE 15 km/h
Humidity: 87 %
Dew point: -1.2 °C
Pressure: 99.2 kPa
Tendency: falling
Visibility: 24.1 km
Sunrise: 08:13
Sunset: 16:27
Normals:
Max -9°C Min -18°C
Yesterday
  Max: 8.6 °C
  Min: -1.3 °C
  Rainfall: 0.0 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 -9°C Min -18°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.06 - 18-May-2023 - added 'advisory' alert display formatting to be same as 'statement' type display
  • Version 5.05 - 09-Feb-2023 - fixes for .png icons and PHP 8.2
  • Version 5.04 - 27-Dec-2022 - fixes for PHP 8.1
  • Version 5.03 - 16-Oct-2019 - change XML access URL to https on EC site
  • 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

 

deformed-offering