One thing that is (was) still missing in the template was some more sophisticated forecast. Well, that is no longer true! I would like to introduce the new plugin, which I called “Forecast comparison“. I am sure it will be quite useful and it is again something I haven´t seen anywhere else, though I many times thought I would like to have something like this. Read further to get to know all the features and how to install it.
So what does this new plugin do? When looking at forecasts on the web there is always a problem with deciding which service to use. There is several providers that show you the forecast and often the values differ substantially. So… wouldn´t it be nice to have them all lined up next to each other, being able to see what each shows? OK, but wouldn´t it be even better if you could then also retrospectivally compare these values with the reality measured by your station to see which one was the most accurate? Well if your answer to these questions was yes, then this plugin is for you!
The plugin comprises of three scripts, which however are linked with each other, let me describe them one by one. Also, there are some additoinal features available to you as admin, accessible with your admin password specified in config.php. Everything is easily visible on one easy to understand page with a unified design to make all services easily comparable.
Let me first talk about the general info that applies to all the scripts. All these scripts retrieve weather conditions from several servers. Some of them require an API key, some don´t. The important thing I want to emphasize right at the beginning is that they are all free and the daily limit of calls should not be an issue because all the scripts use data caching. The services available to you are:
– Yahoo Weather
– World Weather Online
– Aeris Weather
– Open Weather Map
Some of them are available “twice” as they offer more detailed short-term forecast as well as long-term daily forecast (OpenWeatherMap and Forecast.io).
For some of them you already have a key, because it is used in other parts of the template, in that case the value from config.php is taken. Those that do not require API are not an issue. For some of them you will just need to go through a very simple registration process.
1. Current conditions comparison
This script takes the current conditions reported by the selected services and compares them to the actual values that are currently observed at your station. In addition to various graphs and tables there is also a “score” assigned to each of these services, based on how accurately the data is (you as an admin have a possibility to control how this score is calcualted, I will mention that later in this post).
2. Forecast comparison
This script retrieves the forecasts from those services for your location. Your station in this case obviously is not included, as this is always future data. Again you will see graphs, tables and be able to see the differences in the forecasts. The forecasts differ only in the intervals, some offer daily data, some hourly. In case of the hourly you can specify the interval you want to use. This is set in the script, but those are only default values, which can be then changed on the actual page by the users themselves. If for example you choose a 3-hour interval and the service provides hourly data, the values will be averaged out and the averages from the three hourly values shown as one single value and in 3-hour intervals (in case of precipitation not an average but a sum of course).
There is however one more extra feature – only available to admin – a “save” button. What this button does is it simply saves all the data you are seeing into a log file, a “snapshot”. This is then very important for the last script.
3. Retrospective forecast analysis
At first sight, this script looks very similar to the previous one – except there is one big difference. In this case, you are first taken on a page with a list of all the available “snapshots” you created as an admin. This snapshot will have date and time of when it was created. You choose the one you want and it will take you to this last script, which will show you exactly the same thing as the forecast script – except it will not retrieve current data, but use the data saved in that particular log file instead. And, of course it will add the appropriate station values – so again – you have the great opportunity to compare what these services forecasted and what the reality was in the end. This will be presented to you in a form of graphs and tables, including deviations from the station values.
As an admin, you will see two changes. On the forecast script, if accessed as admin, you will see the save button to save that particular forecast (obviously we do not want users to save files to our server…). And likewise, if you access the page with the snapshot list as an admin, in addition to the link to use those values, you will see additional link, which will allow you to delete particular snapshots.
I could talk about this for quite long, but the easiest will be if you simply see for yourself how it works and so here are the install instructions.
The install is quite easy, but will require so make some settings in the scripts so please read the following instructions carefully.
1. Download the zip file, unzip it
2. Open the file current.php in a text editor and find the section right at the top, where you do all the settings.
Here is a general description of all the things that need to be specified:
Timezone – this is probably irrelevant, just leave it and use the timezone already specified in the config.php. This is important for the correct time synchronization of the data. The forecasts are always retrieved and converted to UTC and subsequently to your local station time, offset is calculated from this parameter.
Next you see a parameter which will determine the icons. All icons are available as day or night and you can specify the daily interval to be used as “day” or “night”. The first number is the hour when night starts, second one when day begins (make sure you use the 24h system). Last parameter of this first section is graph width – simply the number of pixels to be used for the height of the graph (default recommended value is 600).
Each service has a parameter called “show”, which defines whether you want to use that particular service in the first place. If you set this to false, you can ignore all the other setting for that particular service and it will not be shown on any of the pages. Use this if for example your location is not available and the closest place is way off.
Then you will need to specify the API keys for some of the services. You will see that for some, the script takes values from the config.php as default (you can change them, but I do not recommend creating several accounts). You can also specify caching time for each of the services, I recommend using 30 or 60 minutes, the data is not updated more often anyway and you want to make sure not to run out of the daily allowed number of calls available for the free account. Then, you have to specify the location to be used. This is very important. Some services might offer forecast for your particular place, in others you might have to use some close bigger city etc. This is something you have to find out yourself at their website and then enter this information here. One service uses latitude and longitude, which is taken from config.php as default.
The above parameters are basically same for all the scripts and so when setting up the other ones later, you can just copy/paste those that are the same.
The current conditions script has one more additional set of parameters. These are used for the scores. How the score is calculated is actually described on the page itself. These parameters basically determine, how much “weight” should be given proportionally to the various reported values. For example, you can specify that temperature is twice as important as humidity, by setting maximum score for humidity to 100 and temperature 200 etc. Read the “How is this score calcualted” text that is on the page itself.
Next you set up the forecast.php script. Basically you can copy/paste most of the stuff, there is just additional parameter for specifying the default forecast interval, which is loaded on the first access of that page, users can then change this themselves.
Last open the retrospective.php, where there is only a few parameters to set up, which again can be copied from the other ones filled in already.
The default landing page for this plugin is the index.php. This has links to all the other scripts. However, there is an alternative page, which is called the admin.php and looks exactly the same, exccept that it requires your admin password and the links that go from this page will take you to the same pages, but you will see the extra admin options – i.e. the possibility to save/delete snapshots or empty cache.
Direct way of accessing this page would be to put as your URL: admin.php?password=12345 (replace by your adminPass). However, an alternative option is to add a link in the admin section that will take you directly here. If you want to do this, go to your admin folder, open index.php and enter the following line of code where you want your link to appear (most likely at the end of the page):
<a href="../plugins/forecastComparison/admin.php?password=<?php echo $password ?>">Forecast Administration</a>
I hope I haven´t forgotten anything. If something isn´t clear, I am sure you will understand once you see the script in action and if you want to see it before setting up, simply look at the demo available at meteopage.com. The last script, the retrospective anaylsis, will obviously only become interesting after a few days, if you make a snapshot today, then you will have to wait before you can actually see the station data for the upcoming days. Also, when you load the scripts for the first time or when no-one looks at your web for more than the cache time, the page will take longer to load as the data will have to be retrieved from all the specified services.
Add a link in your menu.
I will also put a poll here on the blog and it will be quite interesting to see which service is the most accurate. Is there an overall winner in terms of accuracy? Are they all more or less the same? Is one substantially better in Europe and other in the USA and Canada? We will see 🙂