Posted tagged ‘Meteorology’

Met Office Weather Maps PHP API

October 17, 2015

For those who want to add detailed weather maps of the UK to their websites an excellent option is to use the Met Office’s DataPoint web service API. Among many other features the API makes available several different types of observation and forecast time series weather maps as detailed images.

However, DataPoint still leaves users with a lot of work to do if they want to utilise the maps on their websites. For example the DataPoint API only provides the map images as simple layers with no underlying map of the UK. This gives users the flexibility of adding their own UK maps but creates one of many common problems that all DataPoint users have to solve individually.

To address this and other website integration issues I’ve made the met-office-weather-maps PHP API available on GitHub under the MIT License. It’s primary use case is to make it easier to incorporate the latest Met Office weather maps into a web site while not requiring users to directly engage with the Datapoint API.

It’s functionality includes:

  1. Wrapping the complexity of underlying JSON web service calls by exposing one simple PHP class for each available map type.
  2. Adding tailored UK map layers to fetched images that obey the required Mercator projection boundary box.
  3. Adding UK timestamps to map images where they are not already present.
  4. Operating caching to allow maps to be requested on a regular schedule. This ensures that the latest maps are fetched without making excessive calls to DataPoint which may breach their fair use agreement.

The met-office-weather-maps API supports all of the DataPoint map types:

  • Infrared satellite
  • Lightning strikes
  • Precipitation forecast
  • Pressure forecast
  • Rainfall radar
  • Surface pressure charts
  • Temperature forecast
  • Total cloud cover forecast
  • Total cloud cover and precipitation forecast
  • Visible satellite

See the met-office-weather-maps Git Hub project page for details of its requirements, installation and API documentation.

I originally wrote met-office-weather-maps for incorporation into my own weather website where I regularly fetch a selection of weather maps. I previously used Weather Underground’s map API but I find DataPoint to be far superior in terms of map selection and the high frequency of map update.

See below for some real examples that demonstrate met-office-weather-map’s capabilities.

Example 1: Surface Pressure Forecast Map

The Surface Pressure Forecast image available from DataPoint is a transparent layer depicting isobars and fronts:

Click to Enlarge

The same image after processing by met-office-weather-maps. Note the addition of a timestamp and a colour base image of the UK:

Click to Enlarge

Example 2: Visible Satellite Map

The Visible Satellite image available from DataPoint is an opaque layer depicting cloud cover:

Click to Enlarge

The same image after processing by met-office-weather-maps. Note the addition of a yellow outline overlay image of the UK which does not obscure the existing image layer’s timestamp and key:

Click to Enlarge

Example 3: Temperature Forecast Map

The Temperature Forecast image available from DataPoint is a partially transparent layer depicting colour-coded screen temperature:

Click to Enlarge

The same image after processing by met-office-weather-maps. Note the addition of a timestamp, a colour base image and a black outline overlay image of the UK:

Click to Enlarge

Example 4: Cloud Cover and Precipitation Forecast Map

The Cloud Cover and Precipitation Forecast image available from DataPoint is a transparent layer depicting cloud cover and colour-coded precipitation rates:

Click to Enlarge

The same image after processing by met-office-weather-maps. Note the addition of a timestamp, a colour base image and a black outline overlay image of the UK:

Click to Enlarge

Advertisements

“F Weather” Pebble Watch Face

March 21, 2015

Hot on the heels of my Cirrus Pebble WatchApp I’ve just completed another creation for the Pebble: “F Weather”. F Weather is my homage to one of my favourite web sites: THE FUCKING WEATHER. THE FUCKING WEATHER tells the weather like it is and so does F Weather except it does so for your current location:

Click to Enlarge

Click to Enlarge

There are a few differences between F Weather and my Cirrus WatchApp. First of all this is a watch face rather than a watch app so it’s not interactive (but then again it doesn’t need to be interactive to relate the current temperature through the medium of swearing). Secondly F Weather is written in C and PebbleKit JS. This makes it much faster than the PebbleJS based Cirrus WatchApp. I haven’t written any C for 13 years or so and thoroughly enjoyed getting back into it.

Current conditions are looked up from Yahoo’s RESTful query services which involves two calls.

The first call takes the current longitude/latitude position available to the Pebble and looks up the corresponding WOEID and city name:

https://query.yahooapis.com/v1/public/yql?q=select city, woeid from geo.placefinder where text=”40.87,-74.16″ and gflags=”R”&format=json

The second call uses the WOEID to look up the current temperature:

https://query.yahooapis.com/v1/public/yql?q=select item.condition.temp from weather.forecast where woeid=12760611 and u=”c”&format=json

This process is repeated every 15 minutes.

My code is open source and hosted on github. It can be found here: pebblec-watchface-fweather. The install PBW can be found under Releases.

Cirrus Pebble WatchApp for Weather Display Live

January 17, 2015

I don’t mind admitting that I am a bit obsessed about the weather. I am especially fastidious in keeping up with the current conditions where I live. This has manifested itself in several of my recent coding projects that display data from my weather station including my own web site, a web service, a PiFaceCAD based console and an android app widget.

I bought a Pebble smart watch last year on a whim and have found it useful for its notifications of texts, emails and phone calls (I keep my phone on silent so the Pebble’s vibration based notifications are especially handy). Given I have access to my weather station’s data on all of my other devices doing the same with the Pebble was a logical choice for a new project.

Previous weather projects I have written have directly fetched and processed Weather Display Live’s clientraw.txt file. For my Pebble watch application I wanted to make more use of my own web service. This would simplify the coding process as the service, unlike clientraw.txt, exposes weather data in a well-defined structure and many different measurement units. In addition PebbleJS toolkit has built-in support for making http calls to JSON-based web services.

I coded the application in Javascript using the CloudPebble website. For a browser based IDE CloudPebble is very feature rich with syntax highlighting, github integration and logging. It also has the ability to deploy directly to a pebble watch provided you have a paired smart phone for the watch on the same wireless network as the computer running CloudPebble.

The only other code that was required was a web page to expose configuration settings for the application. This currently has to be hosted on the web. In my application’s case this page allows the configuration of the web service URL and a choice of metric or imperial weather measurement units.

The finished application makes use of the Pebble’s menu UI. It populates a top-level menu of current weather data including temperature, surface pressure, humidity, rainfall and wind. Selecting any of these top-level menu items displays a sub-menu of more in-depth information for the particular measurement including daily high and low values.

As usual my code is open source and hosted on github. It can be found here: pebblejs-watchapp-cirrus.

Click to Enlarge

Click to Enlarge

Cirrus Android Widget for Weather Display Live

December 13, 2014

One of my recent projects was to develop an Android widget to display the values found in online WD Live clientraw.txt files. It accesses the same data as my other weather related code projects this year: a JSON Web Service for Weather Display Live and a PiFaceCAD Weather Display Console.

I’ve name the Widget “Cirrus” after the cloud genus. The widget supports 18 different weather data points (and displays the current trend for many of these) and 16 different measurement units. It also has colour coding for easy recognition of different temperature ranges (using the BBC Weather temperature colours) and UV index (using the US EPA UV Index colours).

Click to Enlarge

Click to Enlarge

I use the widget to display the current conditions for both my own weather station and others when I travel. So far I have installed and run it successfully on a Samsung Note II (Android 4.4.2), Samsung Galaxy Express (Android 4.1.2) and a 2013 Nexus 7 (Android 5.0.1).

At this time I do not have any plans to publish the widget on the Google Play Store. I have, however, open sourced the code using the MIT License and made it available via GitHub here:

https://github.com/waynedgrant/android-appwidget-cirrus

See the read me for installation and use instructions.

 

Weather Station Winter Report

November 21, 2014

The onset of Meteorological Winter is a little over a week away here in New Jersey (it runs from 1st Dec to 1st March). Last year’s winter here represented a period of prolonged cold and quite sizeable snow fall. It was certainly more severe than anything my weather station setup experienced in the preceding years in Scotland (although note that the station was only installed there in August 2011 after the severe winters of 2009 – 2010 and 2010 – 2011).

This post relates my experiences with my weather station from last year’s winter (2013 – 2014) and is a record of what worked well and what did not work so well. I run a standard Oregon Scientific WMR200 setup and will describe how well each of the sensors stood up to the harsher than normal conditions. I have illustrated the post with pictures taken at the time and supplemented with various charts produced using my Meteo Sheeva setup.

Winter 2013 – 2014 in New Jersey

Last winter New Jersey, like many parts of the USA, was in the grip of a prolonged Polar Vortex. There were certainly colder places in the USA that winter. There were also places that got a lot more snow. Indeed, according to meteorological records, New Jersey has itself had much colder and more snowbound winters in its past. What made it unusual was how prolonged the cold was and, as a result, just how long the deep snow was able to persist.

Click to Enlarge

Click to Enlarge

As I have already mentioned it was very cold. The coldest it got according to my instruments was -15.7°C on the morning of 7th January 2014. What was really extreme was that the temperature could remain entirely below freezing for days at a time. The chart below shows the number days per month from December 2013 to February 2014 when the temperature did not rise above 0°C. January was especially gruelling with 14 of 31 days spent entirely below zero.

Click to Enlarge

Click to Enlarge

The following chart shows the minimum temperature for every day from the start of December 2013 through to the end of February 2014. Extended cold like this quickly becomes wearing on people and machines alike.

dec - feb min temperature

Click to Enlarge

Note the spike in minimum temperature on 22nd December 2013 (to 13.7°C). This is not a sensor anomaly and I remember that day well. Preceded by some rather cold days the temperature got up to 20.6°C. This made for shorts and t-shirt weather for one day in December. As we can see from the chart the warm weather did not last long and temperatures plummeted and stayed cold thereafter.

Then there was the wind chill. This dropped to a low of -21.3°C on the same morning as the lowest temperature was recorded. I suspect that the wind chill was worse than this in reality as my anemometer is not in the most exposed of locations. The graph below shows the daily minimum wind chill from late December 2013 (when the sensor was installed) through to the end of February 2014.

Click to Enlarge

Click to Enlarge

Finally there was the snow. Up to 2 feet was present on the ground for weeks at a time. The problem was not that it snowed an incredible amount. Instead what did fall remained for weeks at a time because of the consistently low temperatures.

snow depth

Click to Enlarge

Weather Station Sensor Location

The siting of my weather station’s sensors has some bearing on my experiences last winter so I will describe that briefly here.

I am not entirely happy with my weather station setup at the moment. Unlike my previous setup in Scotland I am constrained in terms of space having no garden or roof to speak of. The anemometer/wind vane and rain gauge are installed fairly low down on the makeshift box and pole arrangement pictured below (a UV sensor is also pictured but this was not actually installed until mid-2014). The Temperature/Humidity sensor is better situated and can be found round the corner on another pole in a spot well sheltered from the sun.

Click to Enlarge

Click to Enlarge

Batteries

Before I turn to each sensor’s winter performance I will talk a little about batteries. Oregon’s various sensors are wireless and are therefore powered by AA or AAA batteries. Conventional wisdom in weather station circles goes that it is best to swap from alkaline over to lithium batteries when it gets cold as they perform better in such conditions. I stuck it out with normal alkaline batteries last winter and suffered no signal drop-outs from my sensors. Lithium based batteries are no doubt better for extremely cold conditions but they are an unnecessary expense for the kinds of conditions I saw last winter.

Temperature/Humidity Sensor

The WMR200 comes complete with a THGN801 temperature and humidity sensor. The sensor is a relatively small box installed within a plastic weather shield. Mine is mounted on a pole about a metre off the ground. During the winter the shield did its job well as it became heavily encrusted with ice and protected the sensor which kept reporting consistently with no signal drop-outs throughout the winter. The shield even sported a 30cm icicle at times as pictured below.

Click to Enlarge

Click to Enlarge

Ice was a real hazard generally last winter. Indeed the accumulated ice managed to bow the previously vertical trees near the sensor to be almost horizontal under its weight.

winter weather

Click to Enlarge

The only let down with the THGN801 was a strange behavior that manifested whenever the air temperature dropped to -10°C. Whenever this occurred the humidity would continue to be reported by the sensor but would not vary until the temperature rose above -10°C at which point it would start to report the true value again.The following chart shows this behavior starting at just after midnight on the 7th of January and persisting until mid-morning on the 8th of January (where the blue plot goes flat).

Click to Enlarge

Click to Enlarge

Basically the humidity reported by the THGN801 below -10°C will almost certainly be incorrect and as will the associated dew point. Various weather forum searches have informed me (for example, here) that this is not an individual sensor fault but an endemic problem with the THGN801 and other similar sensors . If I lived in an area with frequent -10°C cold I would not be relying on Oregon gear.

Anemometer / Wind Vane

The WGR800 is a combined anemometer and wind vane. Mine is mounted, less than ideally, on a relatively short pole. The sensor performed well with no signal drop-outs all winter. The only issue I had with it was with the wind vane component on top and I put this at least partly down to its low position. When heavy snow fell on it overnight it could become encrusted on the vane which froze and locked into a single fixed position. Pictured below is one occurrence of this (note the rain sensor is starting to disappear beneath the snow. More on this below).

Click to Enlarge

Click to Enlarge

While frozen the wind vane reported a constant (and incorrect) wind direction until it defrosted sufficiently to move again. This wind vane would typically only be frozen for a few overnight hours at a time when there was heavy snowfall. One such instance is charted below when there was wind but a suspiciously constant South-Easterly wind.

wind vane frozen 25 jan

Click to Enlarge

Rain Gauge

The final outdoor sensor I had last winter was the PCR800 rain gauge. There is not much to say here as it was completely buried under deep snow for much of last winter as pictured below. Once it was buried I felt it was safer (for it and for me) to leave it there insulated under the snow until it was revealed in the thaw. Despite its imprisonment it reported (understandably zero rainfall) constantly with no signal drop-outs throughout the winter.

Click to Enlarge

Click to Enlarge

Winter 2014 – 2015 in New Jersey

My setup remains the same as it did last winter apart from the addition of a UVN800 UV sensor. Customer reviews show this to be a particularly delicate sensor prone to permanent failure in colder conditions. Given that temperatures here are already falling frequently below zero and UV is already a distant summer memory I have already mothballed the sensor until spring comes around.

The rain sensor did fail the following May when it was hit by 11.5 cm/hr rain. As a result its innards got a bit wet and no amount of drying could get it to signal consistently again thereafter. I have since replaced it with a spare unit. The question is, did its icy incarceration shorten its time span? I will never know but if my replacement rain gauge starts to become entombed in the same way this winter I will fish it out and bring it inside. There is no point in risking it in conditions where there is no rain to report anyway.

With a week to go and temperatures already plummeting here I have prepared all of the deployed sensors with new batteries. All that remains now is to see what this winter will bring to my corner of New Jersey.

JSON Web Service for Weather Display Live

October 26, 2014

I’ve been busy implementing a new website for my weather station over the last few weeks at Wayne’s Weather.

There are a number of new technologies being employed. I’ve ditched my bespoke (and ugly) HTML and instead use Bootstrap for a client responsive UI. Chart and image viewing is now more user-friendly thanks to Lightbox. I have also made extensive use of JQuery to pull in information from various sources and to provide a more dynamic experience.

The functionality of the site has also been extended. There are now more in-depth current readings supporting both metric and imperial measurements, forecasts and weather maps from Wunderground.com for the local area have been integrated and I have added a weather webcam and a weather almanac. I intend to write posts to cover the wunderground and webcam build outs soon.

For now this post will concentrate on an unexpected off-shoot of my efforts: a Web Service that exposes Weather Display Live data.

Weather Display Live

Weather Display (and its equivalents such as MeteoHub) can generate clientraw.txt files containing a weather station’s readings and can upload them to a web server periodically and frequently via FTP (in some cases every minute). The primary purpose of this is to drive a Weather Display Live (WDL) dashboard:

Click to Enlarge

The WDL clientraw.txt format is well documented and I have previously used the HTTP addressable clientraw.txt to drive a custom Android widget and my PiFaceCAD Weather Display Console. The disappointing aspect is WDL itself. Don’t get me wrong it’s an excellent weather dashboard and I still have it available in my new website. The problem with it is that is Flash based which is not as widely supported as it used to be. It’s pretty much not an option for mobile device clients running IOS or Android, for example.

To counter this I wanted my new website to make far greater use of the information contained in the clientraw.txt files outside of WDL dashboard itself. My old weather website made use of PHP to grab weather readings from clientraw.txt and place them into web pages before serving them up to the client. This was an approach I wanted to move away from.

I’d just cut my teeth on using JSON formatted web services with my experience as a client to the Wunderground API. I liked the idea of having a page load its own data from the client side where it could conceivably be mix and match data from various services. I figured it wouldn’t be too difficult to create my own web services to expose WDL data and call them from my own web site.

json-webservice-wdlive

I settled on using PHP for the implementation for a couple of reasons. Firstly because I’ve used it for server-side processing on-and-off for a few years and know if fairly well. Secondly because I intended to write a general solution which I could open source for others to use and PHP is ubiquitous in the hosting world.

The result was json-webservice-wdlive, a JSON formatted web service API.

The API exposes two URLs. The first URL returns current weather conditions including Temperature, Pressure, Rainfall, Wind, Humidity, Dew Point, Wind Chill, Humidex, Heat Index and UV. The second URL returns a weather almanac for Month-to-Date, Year-to-Date and All Time records. Both JSON and JSONP (enabled with the addition of a callback attribute to the URL) are supported.

Besides exposing the data in the default units found in clientraw the responses also contain many alternative units. For example, clientraw files store wind speeds in knots. The Web Service responses, on the other hand, respond with Bft, knots, km/h, mph, and m/s.

json-webservice-wdlive-output

Click to Enlarge

Note that I only expose the data I need for my own purposes (i.e. what my weather station setup supports). However, it would be a simply matter to expand the service calls to add, say, solar measurements or extend the selection of almanac measurements. Anything else WDL clientraw.txt files provide can be exposed, if required, with minor code additions.

I have made the json-webservice-wdlive source code available as a GitHub project. Have a look in the project’s README for installation instructions. json-webservice-wdlive is also running live on my own weather website. You can try it at by clicking on the links below:

Refer to the GitHub project page for more details on the Web Service’s response fields including the different measurement units and number field formatting details.

I also make use of the service in three places on my own website: the Current Conditions, Weather Almanac (pictured below) and the Forecast page where I mix my service’s results with those from the Wunderground web service.

almanac

Click to Enlarge

If you have a WDL enabled website feel free to install json-webservice-wdlive to expose your weather data to others and/or to include your information in your own pages.

UVN800 Wireless Remote Sensor Review

April 13, 2014

Until recently I lived in Scotland where UV is hardly ever an issue given the hideous weather we tend to get there. However, I now live in New Jersey in the USA where the summers can be very hot and the risks of UV exposure are more of a concern for me. Given that I took my weather station with me when I relocated (which comprises of both the WMR88 and WMR200 base stations) it made sense to consider expanding its capability to record UV.

One of the advantages of Oregon Scientific’s range of wireless weather stations is the ability to add extra sensors. I have, for example, previously taken advantage of this by adding an additional temperature and humidity sensor in the form of a THGR810 unit.

Both of my base stations also support a UV sensor in the form of the UVN800. This sensor is not normally bundled with the WMR88 or WMR200 but I purchased one recently as an add-on. The unit normally retails for $59.99 but I was able to pick it up for $43.79 from Amazon (not including sales tax). Both the full and discounted prices are on par with what I would expect to pay for other additional sensors such as the THGR810 mentioned above. It arrived undamaged and well packaged in a relatively small box:

UVN800 boxed

Click to Enlarge

Upon unboxing I was presented with the UVN800 unit itself, a wall mount with two screws, a ground spike, AA batteries and instructions.

UVN800 unboxed

Click to Enlarge

This provided me with two different installation options. Either use the ground spike to insert the sensor in the ground or the wall mount and screws to attach it to a wall or pole. I chose the wall mount option which I attached to my existing sensor pole. However, I appreciate the flexibility of the ground spike option. The trick with the UVN800 is to orient it such that the UV sensor on top of it has a constant, uninterrupted view of the sky which I could more easily achieve with the pole mounting.

UVN800 mounted

Click to Enlarge

Installation of the UVN800 is fairly straight forward if a little more awkward than it could be due to some weird choices made by the unit’s designers. First of all accessing the battery compartment requires the removal of four small screws from the base of the unit to access the battery compartment. Why the compartment is not accessed by a sliding mechanism like most of Oregon’s sensors is a mystery.

Secondly the wall mount is screwed into place at the bottom of the unit obscuring the battery compartment and reset button. Given my pole mounted configuration changing batteries will be far more time-consuming than it should be. I will have to unscrew the wall mount from the pole, detach the sensor from the wall mount, remove the screws from the battery compartment. Only then can I change the batteries and will then have to reverse the procedure to reinstall the unit.

So far this is my only gripe with the UVN800 and it is not a deal breaker by any means. One the batteries were installed pairing it with my base stations was as simple as hitting the sensor’s reset button and initiating a search from each base station. They both started displaying UV Index readings straight away. On both the WMR88 and WMR200 this takes the form of a live UV Index display and a graph of the last 10 hours of values.

Having UV Index values displayed on my base stations was just the start, however. I publish weather data to my own website and wanted to add UV Index information to it. I use a Meteo Sheeva connected to my WMR200 as a data logger and to do uploads of weather readings and graphs to my website. As expected it was a snap to get it to start logging data from the UVN800. As an example here is one of several graphs I have configured on the Meteo Sheeva which display the last 7 days of maximum UV Index values:

7day_uv

Click to Enlarge

My Meteo Sheeva also uploads data in WD Live’s clientraw.txt format which includes UV Index readings. I have rearranged my existing WD Live console on my website to incorporate a UV Index bar:

wdlive

Click to Enlarge

Returning to the UVN800 itself there is one more thing to note. The reviews on Amazon for the UVN800 indicate that many units permanently fail just after a year of operation. At the time of writing I have only been operating the sensor for a few days but will add a note to this review if and when it fails.

Should the sensor last at least a couple of years (as all my other sensors have already done) then I would not hesitate to recommend the UVN800 as a useful, easy to use addition to an existing Oregon Scientific wireless station.