Monday, December 3, 2012

I've been discovering new things in Javascript. I have been much constrained by data download time. JS frowns on interactive downloading - you generally have to download all data initially, as part of the code. However, there is a newish feature, XMLHTTPRequest, which allows download in response to user choices (with restrictions on domains). This means I can make very large datasets available to select from. I've also found new ways of compacting them, which I'll write about later.

My initial exercise was the plot that I have sometimes shown for recent months (eg June). It's based solely on the data reported for that month (plus the anomaly base). But now you can select any month you like (currently only for this century). The data is downloaded when you ask, so there isn't a huge initial wait. It's a plot based purely on the station data for GHCN V3 unadjusted and ERSST. For SST a "station" is a 4°x4° lat/lon cell. A triangle mesh is fitted and used for color shading between stations.

As before, you can rotate the globe by selecting focus points on the top right map. You can magnify, display stations and mesh, and click to print numerical data (on the right). There are more details of that below.

The plot is below. You can also click here to see it in a separate tab/window. More discussion and user guidance follows.

How it works - details

The flat map at top right is your navigator. If you click a point in that, the sphere will rotate so that point appears in the centre.
The buttons below allow modification. Set what you want, and press refresh. You can show stations, and the mesh, and magnify 2×, 4×, or 8× (by setting both). You can click again to unset (and press refresh).

When you select a month/year, you also have to refresh. Using the navigator automatically refreshes.

Then you can click in the sphere. At the bottom on the right, the nearest station name and anomaly will appear. Lat/Lon and date are also shown. You may want to have stations displayed when you click.

Data details

Anomalies are relative to the 1961-1990 period. Where stations did not have enough data there, I took extra years and did a linear regression, and used the 1975 value.Update - as foreshadowed in later posts, I've now switched to a weighted linear regression estimate of present month value as the basis for the anomaly. The weight function is an exponential with a time constant of thirty years. The results are smoother.

As mentioned, I'm using GHCN v3 for station data. I've downloaded late Nov 2012, and I probably won't update past months regularly, but I'll try to add future months as they appear. I'll update older data occasionally, since late stations will appear. I have taken a more conservative approach to GHCN - anything with a quality flag is not shown. That loses some good data, and I may review.

ERSST shows frozen sea as -1.8°C, the temperature below the ice. I've eliminated these readings, as they don't reflect climate.

The shading is not ideal, but is what HTML 5 provides. It gets two nodes in the triangle exactly right, and I've done the best I could with the third. Where there are big variations, you'll sometimes see nodes with adjacent shading which differs in some triangles. Usually the majority is correct.

2 comments:

Oh yes, the XMLHTTPrequest stuff is nice. I used it in the SkS trend calculator to avoid the problem of cacheing of out-of-date data. (Now I just need to update the xml files regularly!)

The other real life-changing feature is web workers, which allow you to do big calculations in the background without using callbacks. Support is even more limited than XML - just chrome, firefox and safari so far.

I've used them in a cool new toy which will appear at SkS at the end of the week. I think you'll like it!