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 Monday, 28-Oct-2024 2:33 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-V6-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.

Heat Warning
10:28 a.m. EDT Saturday 12 July 2025

Heat Warning in effect for:
  • St. Catharines - Grimsby - Northern Niagara Region
A prolonged period of extreme heat and humidity continues.

What:
Daytime highs of 29 to 32 degrees Celsius and a humidex of 35 to 40.
Overnight lows of 19 to 23 degrees Celsius, providing little relief from the heat.

When:
Continuing through Thursday.

Additional information:
Southern Ontario will experience hot and humid conditions now through much of next week. The heat is expected to ease some for Sunday and Monday with hotter and more humid conditions returning on Tuesday. A shift in the weather pattern late next week will likely end this multi-day period of heat and humidity Thursday night.

Take action to protect yourself and others - extreme heat can affect everyone's health. Determine if you or others around you are at greater risk of heat illness. Check on older adults, those living alone and other at-risk people in-person or on the phone multiple times a day.

Watch for the early signs of heat exhaustion in yourself and others. Signs may include headache, nausea, dizziness, thirst, dark urine and intense fatigue. Stop your activity and drink water.

Heat stroke is a medical emergency! Call 9-1-1 or your emergency health provider if you, or someone around you, is showing signs of heat stroke which can include red and hot skin, dizziness, nausea, confusion and change in consciousness. While you wait for medical attention, try to cool the person by moving them to a cool place, removing extra clothing, applying cold water or ice packs around the body.

Drink water often and before you feel thirsty to replace fluids.

Close blinds, or shades and open windows if outside is cooler than inside.

Turn on air conditioning, use a fan, or move to a cooler area of your living space. If your living space is hot, move to a cool public space such as a cooling centre, community centre, library or shaded park.

Follow the advice of your region's public health authority.

Plan and schedule outdoor activities during the coolest parts of the day.

Limit direct exposure to the sun and heat. Wear lightweight, light-coloured, loose-fitting clothing and a wide-brimmed hat.

Never leave people, especially children, or pets inside a parked vehicle. Check the vehicle before locking to make sure no one is left behind.

For more information: https://www.canada.ca/en/health-canada/services/climate-change-health/extreme-heat/how-protect-yourself.html https://www.canada.ca/en/health-canada/services/climate-change-health/extreme-heat/who-is-at-risk.html

Please continue to monitor alerts and forecasts issued by Environment Canada. To report severe weather, send an email to ONstorm@ec.gc.ca or post reports on X using #ONStorm.

Observed at: St. Catharines / Niagara District Airport
Date: 3:00 PM EDT Saturday 12 July 2025
Mainly Sunny
Mainly Sunny
Temp.: 33 °C
Wind: SW 23 gust 37 km/h
Humidity: 50 %
Dew point: 21 °C
Pressure: 101.3 kPa
Tendency: 0.07 kPa
Visibility: 24 km
Sunrise: 5:48
Sunset: 20:57
Normals:
Max 26°C Min 17°C
 Extended Forecast - Environment Canada
  Sun, 13 Jul
A mix of sun and cloud
A mix of sun and cloud
Max: 31°C
Mon, 14 Jul
Sunny
Sunny
Max: 29°C
Tue, 15 Jul
Chance of showers (30%)
Chance of showers
Max: 31°C
Wed, 16 Jul
Chance of showers (30%)
Chance of showers
Max: 30°C
Thu, 17 Jul
Chance of showers (40%)
Chance of showers
Max: 29°C
Fri, 18 Jul
Chance of showers (40%)
Chance of showers
Max: 24°C
Tonight
Chance of showers (40%)
Chance of showers
Min: 24°C
Night
Partly cloudy
Partly cloudy
Min: 21°C
Night
Clear
Clear
Min: 19°C
Night
Cloudy
Cloudy
Min: 21°C
Night
Chance of showers (40%)
Chance of showers
Min: 21°C
Night
Chance of showers (40%)
Chance of showers
Min: 19°C

Forecast

St. Catharines, ON (Issued: 3:30 PM EDT Saturday 12 July 2025)

Tonight
Partly cloudy. 40 percent chance of showers this evening and after midnight with risk of a thunderstorm. Wind southwest 20 km/h. Low 24.
Sun, 13 Jul
A mix of sun and cloud. Wind southwest 20 km/h. High 31. Humidex 41. UV index 10 or very high.
Night
Partly cloudy. Wind southwest 20 km/h becoming light in the evening. Low 21.
Mon, 14 Jul
Sunny. High 29.
Night
Clear. Low 19.
Tue, 15 Jul
A mix of sun and cloud with 30 percent chance of showers. High 31.
Night
Cloudy. Low 21.
Wed, 16 Jul
Cloudy with 30 percent chance of showers. High 30.
Night
Cloudy with 40 percent chance of showers. Low 21.
Thu, 17 Jul
Cloudy with 40 percent chance of showers. High 29.
Night
Cloudy with 40 percent chance of showers. Low 19.
Fri, 18 Jul
A mix of sun and cloud with 40 percent chance of showers. High 24.

24 Hour Forecast - St. Catharines, ON

Date/Time Temp.
(°C)

Weather Conditions

LOP †
Wind
(km/h)
12 July 2025
4 PM 33 A mix of sun and cloud (10%)  A mix of sun and cloud 10 SW 20
5 PM 33 A mix of sun and cloud (10%)  A mix of sun and cloud 10 SW 20
6 PM 32 A mix of sun and cloud (10%)  A mix of sun and cloud 10 SW 20
7 PM 31 A mix of sun and cloud (10%)  A mix of sun and cloud 10 SW 20
8 PM 30 Chance of showers. Risk of thunderstorms (40%)  Chance of showers. Risk of thunderstorms 40 SW 15
9 PM 29 Chance of showers. Risk of thunderstorms (40%)  Chance of showers. Risk of thunderstorms 40 SW 15
10 PM 27 Chance of showers. Risk of thunderstorms (40%)  Chance of showers. Risk of thunderstorms 40 SW 15
11 PM 26 Chance of showers. Risk of thunderstorms (40%)  Chance of showers. Risk of thunderstorms 40 SW 10
13 July 2025
12 AM 26 Chance of showers. Risk of thunderstorms (30%)  Chance of showers. Risk of thunderstorms 30 SW 10
1 AM 25 Chance of showers. Risk of thunderstorms (30%)  Chance of showers. Risk of thunderstorms 30 SW 10
2 AM 25 Chance of showers. Risk of thunderstorms (30%)  Chance of showers. Risk of thunderstorms 30 SW 20
3 AM 25 Mainly cloudy (20%)  Mainly cloudy 20 SW 20
4 AM 24 Mainly cloudy (20%)  Mainly cloudy 20 SW 20
5 AM 24 Partly cloudy (20%)  Partly cloudy 20 SW 20
6 AM 24 A mix of sun and cloud (20%)  A mix of sun and cloud 20 SW 20
7 AM 25 A mix of sun and cloud (20%)  A mix of sun and cloud 20 SW 20
8 AM 25 A mix of sun and cloud (20%)  A mix of sun and cloud 20 W 20
9 AM 26 A mix of sun and cloud (20%)  A mix of sun and cloud 20 W 20
10 AM 27 A mix of sun and cloud (20%)  A mix of sun and cloud 20 W 20
11 AM 28 A mix of sun and cloud (20%)  A mix of sun and cloud 20 SW 20
12 PM 28 A mix of sun and cloud (20%)  A mix of sun and cloud 20 SW 20
1 PM 29 A mix of sun and cloud (20%)  A mix of sun and cloud 20 SW 20
2 PM 29 A mix of sun and cloud (20%)  A mix of sun and cloud 20 SW 20
3 PM 30 A mix of sun and cloud (20%)  A mix of sun and cloud 20 SW 20
 
† 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%

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.

Version 6.00 is a major rewrite of the script to use EC JSON data instead of the deprecated XML citypage data for forecasts/alerts. The new alert display mimics that display available on the EC website with a bar for each alert that has clickable areas to expand the details of the alert as a dropdown. The $alertstring variable has the HTML and JavaScript to enable this new display.

Observed at: St. Catharines / Niagara District Airport
Date: 3:00 PM EDT Saturday 12 July 2025
Mainly Sunny
Mainly Sunny
Temp.: 33 °C
Wind: SW 23 gust 37 km/h
Humidity: 50 %
Dew point: 21 °C
Pressure: 101.3 kPa
Tendency: 0.07 kPa
Visibility: 24 km
Sunrise: 5:48
Sunset: 20:57
Normals:
Max 26°C Min 17°C

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 26°C Min 17°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 6.02 - 28-Oct-2024 - fixed alert display when there are highway alerts
  • Version 6.01 - 26-Oct-2024 - fix for hourly display icons when using .png icons
  • Version 6.00 - 26-Oct-2024 - rewrite to use new EC JSON return instead of XML citypage
  • Version 5.07 - 02-Jul-2024 - fixes for changes in EC XML returns w/o almanac section
  • 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

 

deformed-offering