How It Works

Interested in the inner workings of this website? Let me explain how the magic happens.

The Overview

How this web site works can be a complicated question to answer. If you just want to understand how to use it, that's easy. If you want to understand how the web site actually gathers and makes predictions, things can get rather complicated. This site is testing area for me to try new geeky things.

How to use Weather Pirace

It's best to start at the homepage and choose the location on the map. Clicking on the location will give you a link to the prediction page where you'll be given a bunch of information about the weather. It’s this prediction page that you may want to bookmark. The prediction page updates regularly, currently it will never be more than an hour old, noted at the top of the page when it was last updated. You’re first given information like the sunrise and sunset along with the tide times and heights. Of course those aren’t really predictions, more like information. The rest of the page gives the predictions.

The graphs on the page show many days out as noted on the bottom of the graph. The day shown with the vertical line marks midnight of the new day. For example, when you see "Thurs" on the bottom of the graph, the line above it to the next vertical line to the right is the entire Thursday prediction. The center of the space between the vertical lines would be noon. On the left of the graph you’ll see the measurement like feet or MPH with the accompanying numbers. Keep in mind the numbers will be adjusted to make the graph useful. If the wave height across the span of days will only reach a maximum of 4 feet, the graph will adjust to only display a range of 4 feet. Keep this in mind as the graphs are redrawn every time a new update is posted. So although the plotted lines on two graphs can look similar, their measurements (on the left of the graph) may be entirely different.

Once you read the predictions a few times, you’ll understand how quickly you can stay informed on the weather outlook. It only takes a few seconds to glance over the charts to know when it’s the best time for you to be on the water.

How Weather Pirate Works

To get into the technical end, I wrote the web site in Perl, and it uses API's to fetch weather data from multiple sources. The sources are combined and averaged to give predictions the most accurate way possible. It's not always right, but it's the best guess science has for us.

When you load the homepage there are a few Apache server side includes directives that load. The simple ones are the overall site templates allowing changes to one file to update things like the menu on all pages of the site. The more interesting one loads all the prediction locations into the on page JavaScript for the MapBox globe. This allows the globe to be moved around by the visitor showing marks for the locations of all the predictions that can be clicked on and followed to the prediction pages.

When a prediction page is loaded, the Perl script checks to see when the last time the weather data was created. If it’s stale, over an hour old, it will re-fetch all the weather data then average it together, draw all the graphs, and give you the new weather prediction. This happens very quickly so you likely won’t notice a difference in page load time from a pre-loaded prediction to one that was generated specifically for your inquiry.

Adding a new location to the predictions is also a little tricky. A user can go to the add a location page, simply click on the globe on where they would like a prediction. The longitude and latitude are recorded from the globe click and saved for review. There is a backend admin review page that shows where the new location request is suggested. It calculates the time zone for that location, and allows it to be approved or denied for inclusion in the weather predictions.

Of course that’s just a brief overview for a bunch of code and CentOS Linux server settings that make the website work. It’s an experimental place for me to try new things, so if the website isn’t working when you’re on it, give it a few minutes because I’m probably playing with something.

Weather predictions for water locations helping you to enjoy being on the water