# Computing stuff tied to the physical world

## Tricky graphs

In Software on May 12, 2013 at 00:01

Yesterday’s post introduced the new graph style I’ve added to HouseMon. As mentioned, I am using step-style graphs for the power (i.e. Watt) based displays. Zooming in a bit on the one shown yesterday, we get:

There’s something really odd going on here, as can be seen in the blocky lines up until about 15:00. The blocks indicate that there are many missing data points in the measurement data (normally there should be several measurements per minute). But in itself these rectangular shapes are in fact very accurate: the area is Watt times duration, which is the amount of energy (usually expressed in Joules, Wh, or kWh).

So rectangles are in fact exactly right for graphing power levels: we want to represent each measurement as an area which matches the amount of energy used. If there are fewer measurements, the rectangles will be wider, but the area will still represent our best estimate of the energy consumption.

But not all is well – here’s a more detailed example:

The cursor in the screenshot indicates that the power usage is 100.1 W at 19:16:18. The problem is that the rectangle drawn is wrong: it should precede the cursor position, not follow it. Because the measurement is the result of sampling power and returning the cumulative power level at the end of that measurement period. So the rectangle which is 100.1 W high should really be drawn from 19:18:00 to 19:18:16, i.e. from the time of the previous measurement.

I have yet to find a graphing system which gets this right.

Tomorrow: another oddity, not in the graph, but related to how power is measured…

1. I can’t speak for Dutch or German (though would be interested to know) but in English and French the names of units are conventionally written in all lower case (except at the start of sentences, in titles, etc), even if the units are named after people. So “joules”, not “Joules”, etc.

http://www.bipm.org/en/si/si_brochure/chapter5/5-2.html

• Aha – thank you, I’ll apply these rules in future posts and writings. Great reference link!

I suspect it’s the same for Dutch and German… just plain ignorance on my part.

2. I don’t know Dutch either, but at least in German all nouns (and Names) begin with an upper-case letter. So following the rules at bipm.org Watt is correct in German.

3. HouseMon, great expectations for the system in the future. SI units work well here. E.g. http://en.wikipedia.org/wiki/International_System_of_Units

4. On the missing data points and correctness of the graph: This holds under the assumption that you do not miss pulses from the power meter, when you miss measurements in your housemon logging. When you really miss data, it is better to show it as a gap.

• I’m assuming the JeeNode counting the pulses is not missing any. From there to HouseMon, there may be lost packets, but on a larger scale it does not matter, as the values are passed as counts, not pulses. So as long as the JN doesn’t get reset, the accumulated energy measurements remain accurate.

5. Why would you need to “find a graphing system that gets this right”? Simply shift the values column down by one position, assuming the table is sorted chronologically.

• Hmm… bit messy, as it affects only data points for watts, but interesting idea!