IMPORTANT! The server may go down soon - possibly permanently. Please read the latest post in Announcements and News

I strongly advise all users using my server for their web site to make alternative arrangements.

Outgoing mail is disabled because of the malware on the server. No new forum registrations are currently possible, and mail to the forum administrator will not work.

Please read the posts in the Announcements section about the current status of Cumulus development now that I have retired

Please read this post before posting

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See this post for download

UK Extremes from the MetOffice

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

Moderators: daj, TNETWeather

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

UK Extremes from the MetOffice

Postby mcrossley » Mon Mar 02, 2015 4:50 pm

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 Sep 17, 2018 8:41 pm, edited 1 time in total.

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

Re: UK Extremes from the MetOffice

Postby mcrossley » Mon Mar 02, 2015 7:23 pm

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 Sep 17, 2018 8:42 pm, edited 1 time in total.

User avatar
duke
Posts: 840
Joined: Sun Jul 03, 2011 6:23 pm
Weather Station: Davis VP2 Plus - 24hr FARS
Operating System: Windows 10 - 64 bit
Location: Eastleigh, Hampshire, UK
Contact:

Re: UK Extremes from the MetOffice

Postby duke » Mon Mar 02, 2015 10:37 pm

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 ;)
Duke

Nightingale Weather
Eastleigh, Hampshire, UK
------------------------------------------------------
Validate your pages - often!

water01
Posts: 1465
Joined: Sat Aug 13, 2011 9:33 am
Weather Station: WH1081
Operating System: Windows 7 64bit HP SP1
Location: Somewhere in the USA
Contact:

Re: UK Extremes from the MetOffice

Postby water01 » Tue Mar 03, 2015 12:35 am

Me included!!

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

Re: UK Extremes from the MetOffice

Postby mcrossley » Tue Mar 03, 2015 10:04 am

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 Sep 17, 2018 8:47 pm, edited 3 times in total.

User avatar
jdc
Posts: 135
Joined: Tue Jun 19, 2012 8:51 pm
Weather Station: Davis VP2 : Instromet
Operating System: Win 10 : Win XP
Location: Berwick-upon-Tweed, England.
Contact:

Re: UK Extremes from the MetOffice

Postby jdc » Tue Mar 03, 2015 5:44 pm

That is rather good!

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

User avatar
duke
Posts: 840
Joined: Sun Jul 03, 2011 6:23 pm
Weather Station: Davis VP2 Plus - 24hr FARS
Operating System: Windows 10 - 64 bit
Location: Eastleigh, Hampshire, UK
Contact:

Re: UK Extremes from the MetOffice

Postby duke » Tue Mar 03, 2015 7:19 pm

Working 'out of the box' here too, thank you Mark :)
Duke

Nightingale Weather
Eastleigh, Hampshire, UK
------------------------------------------------------
Validate your pages - often!

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

Re: UK Extremes from the MetOffice

Postby mcrossley » Tue Mar 03, 2015 7:28 pm

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:

User avatar
duke
Posts: 840
Joined: Sun Jul 03, 2011 6:23 pm
Weather Station: Davis VP2 Plus - 24hr FARS
Operating System: Windows 10 - 64 bit
Location: Eastleigh, Hampshire, UK
Contact:

Re: UK Extremes from the MetOffice

Postby duke » Tue Mar 03, 2015 7:48 pm

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.
Duke

Nightingale Weather
Eastleigh, Hampshire, UK
------------------------------------------------------
Validate your pages - often!

User avatar
jdc
Posts: 135
Joined: Tue Jun 19, 2012 8:51 pm
Weather Station: Davis VP2 : Instromet
Operating System: Win 10 : Win XP
Location: Berwick-upon-Tweed, England.
Contact:

Re: UK Extremes from the MetOffice

Postby jdc » Tue Mar 03, 2015 7:53 pm

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: 5195
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: UK Extremes from the MetOffice

Postby mcrossley » Tue Mar 03, 2015 8:14 pm

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 Sep 17, 2018 8:48 pm, edited 1 time in total.

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

Re: UK Extremes from the MetOffice

Postby mcrossley » Tue Mar 03, 2015 8:31 pm

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: 135
Joined: Tue Jun 19, 2012 8:51 pm
Weather Station: Davis VP2 : Instromet
Operating System: Win 10 : Win XP
Location: Berwick-upon-Tweed, England.
Contact:

Re: UK Extremes from the MetOffice

Postby jdc » Tue Mar 03, 2015 10:36 pm

Thank you again for that. I was looking at the wrong end of the script!

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

Re: UK Extremes from the MetOffice

Postby mcrossley » Wed Mar 04, 2015 9:24 am

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: 5195
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: UK Extremes from the MetOffice

Postby mcrossley » Wed Mar 04, 2015 4:55 pm

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 Sep 17, 2018 8:48 pm, edited 1 time in total.


Return to “Web site - General”

Who is online

Users browsing this forum: No registered users and 3 guests