Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.5 (build 3282) - 23 February 2024

Cumulus MX V4 beta test release 4.0.0 (build 4017) - 17 March 2024

Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

UK Extremes from the MetOffice

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

User avatar
mcrossley
Posts: 12641
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

UK Extremes from the MetOffice

Post by mcrossley »

I'm playing around with a little PHP script that gets regional and UK wide extremes for a limited set of readings from the Met Office.

It is part of their DataPoint offering, you have to sign up to get an API code, but the sign up and data is free.

I am using this dataset: http://www.metoffice.gov.uk/datapoint/p ... servations

And I have it running on this page in the right-hand side bar: https://weather.wilmslowastro.com/today_yest.php
I need to sort out the text lengths somehow...

I can make the PHP class available if people are interested (once I have finalised the code).
As is often the case the data is supplied in a format that is convenient to generate, but no so convenient to use. If you want a specific value for a specific region, you have to walk the regions until you find the right one, then walk the extremes until you find the one you want.

So my code reformats the data so you can index directly in to specific regions and values.
Last edited by mcrossley on Mon 17 Sep 2018 8:41 pm, edited 1 time in total.
User avatar
mcrossley
Posts: 12641
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: UK Extremes from the MetOffice

Post by mcrossley »

Actually this is real test page - just a basic demo of the data: https://weather.wilmslowastro.com/test/ ... mes24h.php
Last edited by mcrossley on Mon 17 Sep 2018 8:42 pm, edited 1 time in total.
duke

Re: UK Extremes from the MetOffice

Post by duke »

I was only looking at the wealth of free data that they offer at the weekend.
mcrossley wrote: I can make the PHP class available if people are interested (once I have finalised the code).
I'm sure there will be a few of us ;)
water01
Posts: 3201
Joined: Sat 13 Aug 2011 9:33 am
Weather Station: Ecowitt HP2551
Operating System: Windows 10 64bit
Location: Burnham-on-Sea
Contact:

Re: UK Extremes from the MetOffice

Post by water01 »

Me included!!
David
Image
User avatar
mcrossley
Posts: 12641
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: UK Extremes from the MetOffice

Post by mcrossley »

Give this a whirl - I'm a bit busy at the mo so limited support. Version 0.2

Warning, there isn't much error checking in there yet!

EDIT: Updated the test file to add example cookie handling.
EDIT2: Updated the class file, if the cache file is stale, but there is no new data it now just performs a touch to reset the cache timer rather than rewriting the file. Ver 0.2
EDIT3: (17 Sept 18) updated sample PHP page to use a newer version of JQuery
You do not have the required permissions to view the files attached to this post.
Last edited by mcrossley on Mon 17 Sep 2018 8:47 pm, edited 3 times in total.
User avatar
jdc
Posts: 142
Joined: Tue 19 Jun 2012 8:51 pm
Weather Station: Davis VP2 : Instromet
Operating System: Win 10
Location: Portsoy,.
Contact:

Re: UK Extremes from the MetOffice

Post by jdc »

That is rather good!

I had a wee play with it this afternoon, simple setup and it's working fine. Neat.
duke

Re: UK Extremes from the MetOffice

Post by duke »

Working 'out of the box' here too, thank you Mark :)
User avatar
mcrossley
Posts: 12641
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: UK Extremes from the MetOffice

Post by mcrossley »

Phew! :lol:

It will be interesting to see how you integrate the data into your web sites.

Now, what else is lurking in DataPoint.... :groan:
duke

Re: UK Extremes from the MetOffice

Post by duke »

mcrossley wrote: It will be interesting to see how you integrate the data into your web sites.
Tomorrow nights task ;)

Mark, just a thought, is it possible to store the selected region in a cookie so a returning visitor automatically sees their last choice? Presumably in most cases this would be the region they live in.
User avatar
jdc
Posts: 142
Joined: Tue 19 Jun 2012 8:51 pm
Weather Station: Davis VP2 : Instromet
Operating System: Win 10
Location: Portsoy,.
Contact:

Re: UK Extremes from the MetOffice

Post by jdc »

mcrossley wrote:Phew! :lol:

It will be interesting to see how you integrate the data into your web sites.
http://lethamshank.co.uk/met/wx_extremes.php

Just some style then I will fit it somewhere! Unless you write something else to fill the page. :)

Knowing nil about js, how would I select only one region to create a snippet? (eg 'dg')
User avatar
mcrossley
Posts: 12641
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: UK Extremes from the MetOffice

Post by mcrossley »

duke wrote:Mark, just a thought, is it possible to store the selected region in a cookie so a returning visitor automatically sees their last choice? Presumably in most cases this would be the region they live in.
What, like this?: https://weather.wilmslowastro.com/test/ ... mes24h.php
Last edited by mcrossley on Mon 17 Sep 2018 8:48 pm, edited 1 time in total.
User avatar
mcrossley
Posts: 12641
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: UK Extremes from the MetOffice

Post by mcrossley »

jdc wrote:
mcrossley wrote:Phew! :lol:

It will be interesting to see how you integrate the data into your web sites.
http://lethamshank.co.uk/met/wx_extremes.php

Just some style then I will fit it somewhere! Unless you write something else to fill the page. :)

Knowing nil about js, how would I select only one region to create a snippet? (eg 'dg')
John, just look a the test page, where it prints out the UK values...

Code: Select all

echo 'UK Extremes for ' . $data->{'UkExtremes'}->{'extremeDate'} . '<br><br>' . PHP_EOL;

echo 'Region name: ' . $data->{'UkExtremes'}->{'Regions'}->{'uk'}->{'name'} . '<br>' . PHP_EOL;
// Just print out each extreme for the UK region as they are stored in the data blob
foreach ($data->{'UkExtremes'}->{'Regions'}->{'uk'}->{'Extremes'} as $extreme => $value) {
	echo $conv[$extreme] . ' ' . $value->{'$'} . ' ' . $value->{'uom'} . ' ' . $value->{'locationName'} . '<br>' . PHP_EOL;
}
Just change all the instances of {'uk'} to {'dg'}.


You can print individual values rather than using the 'blob' order so...

Code: Select all

$regVals = $data->{'UkExtremes'}->{'Regions'}->{'dg'}->{'Extremes'};
echo 'Max temp = ' . $regVals->{'HMAXT'}->{'$'} . ' ' . $regVasl->{'HMAXT'}->{'uom'} . ' at ' . $regVals->{'HMAXT'}->{'locationName'};
//..etc
User avatar
jdc
Posts: 142
Joined: Tue 19 Jun 2012 8:51 pm
Weather Station: Davis VP2 : Instromet
Operating System: Win 10
Location: Portsoy,.
Contact:

Re: UK Extremes from the MetOffice

Post by jdc »

Thank you again for that. I was looking at the wrong end of the script!
User avatar
mcrossley
Posts: 12641
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: UK Extremes from the MetOffice

Post by mcrossley »

I have made a minor optimisation to the zip file above, if the cache file is stale, but there is no new data to just touches the file to reset the time rather than re-saving it.
User avatar
mcrossley
Posts: 12641
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: UK Extremes from the MetOffice

Post by mcrossley »

mcrossley wrote:Now, what else is lurking in DataPoint.... :groan:
I have the 5 day summary day/night data for a specified location working now - just need to figure out how to format it nicely like the Saratoga templates do!
I was surprised Wilmslow was on the location list - there are 5000 entries.

Very basic data presentation as a test...
https://weather.wilmslowastro.com/test/ ... recast.php
Last edited by mcrossley on Mon 17 Sep 2018 8:48 pm, edited 1 time in total.
Post Reply