Calibrating Old Data

When I inspected and updated the weather station at the end of July 2019, I discovered that the wind sensor had been calibrated to read much too low. 

After quite a few head-scratching hours, and revisiting some neglected hacking skills, I have now managed to update all the existing wind data to match the new calibration. Records and statistics are now comparable for all measurements since 1 March 2018. In the process of doing this, I discovered that the data file for February 2018 (the first month that the station was in operation here) was quite badly corrupted. It was not possible to fix it, since it was impossible to know what data had been changed within it. Rather than guess wha tthe readings might have been, I have now deleted it.

If anyone is interested, I used Apple's JXA (Javascript for automation) which is included in all fairly new Macs. The documentation and tutorials for this are very thin on the ground, so it felt like proper hacking, with a lot of trial and error. I could have used Applescript, but I have been using much more Javascript than Applescript recently so I preferred to stick with that.

Weathercat data files are plain text with a header and then a line for each snapshot (5 minutes apart) with the data listed as, for example "...W:3.75 Wg: 10.12..." for the 10-minute wind average and the 10-minute gust. 

The code I wrote was simple and used brute force, working through the file writing text to a new file but extracting and scaling the numbers after W: and Wg: until there was no more text.

I was pleased with JXA which has some nice features (like having a function to choose a file to process from a list and returning the file name) and was more than fast enough for this job.


This article was updated on Saturday, 14 September 2019