Computing stuff tied to the physical world

Tricky graphs – part 2

In Software on May 20, 2013 at 00:01

As noted in a recent post, graphs can be very tricky – “intuitive” plots are a funny thing!

Screen Shot 2013-05-14 at 10.35.43

I’ve started implementing the display of multiple series in one graph (which is surprisingly complex with Dygraphs, because of the way it wants the data points to be organised). And as you can see, it works – here with solar power generation measured two different ways:

  • using the pulse counter downstairs, reported up to every 3 seconds (green)
  • using the values read out from the SB5000TL inverter via Bluetooth (blue)

In principle, these represent the same information, and they do match more-or-less, but the problem mentioned before makes the rectangles show up after each point in time:

Screen Shot 2013-05-14 at 10.40.11

Using a tip from a recent comment, I hacked in a way to shift each rectangle to the left:

Screen Shot 2013-05-14 at 10.40.34

Now the intuition should be that the area in the coarser green rectangles should be the same as the blue area they overlap. But as you can see, that’s not the case. Note that the latter is the proper way to represent what was measured: a measurement corresponds to the area preceding it, i.e. that hack is an improvement.

So what’s going on, eh?

Nice puzzle. The explanation is that the second set of readings is incomplete: the smaRelay sketch only obtains a reading from the inverter ever 5 minutes or so, but that’s merely an instantaneous power estimate, not an averaged reading since the previous readout!

So there’s not really enough data in the second series to produce an estimate over each 5-minute period. All we have is a sample of the power generation, taken once every so often.

Conclusion: there’s no way to draw the green rectangles to match our intuition – not with the data as it is being collected right now anyway. In fact, it’ probably more appropriate to draw an interpolated line graph for that second series, or better still: dots

Update – Oops, the graphs are coloured differently, my apologies for the extra confusion.

  1. Don’t you want to shift the readings half a unit to the left? This would place the centre of the green rectangles on the point you want

    • Halfway and as average of the points before and after would be an estimate (the same area as when connecting before and after by a straight line), but it doesn’t solve the core issue, which is that the green readings don’t represent cumulative energy but periodic readouts of the instant power.

  2. Hi, maybe a bit off topic,

    I had the same problems, only with a lower scale, my PV is only a proof of concept (260W). However, i remembered the ‘Energy Count 3000’, and this one gave me quite good results. I’ve just had to open it and switch the cables, but the resulting granlarity is much better the than 5 min. And the chip on it seems to be well suited for this.

    Regards Nik

  3. Hi jcw,

    Could it be that you mixed up the legenda of the two lines?

    using the pulse counter downstairs, reported up to every 3 seconds (green) using the values read out from the SB5000TL inverter via Bluetooth (blue)

    If the SMA is reported every five minutes, It would be the green line.

    And if this is indeed an (instantenious) power, than of course it should be drawn at its recorded time stamp (not half way), using a marker, line or spline (but not the step option). The blue line I assume to be the energy reading fropm the pulse counter, and there you should use the step-option, with shifted time stamp to correct for the DyGraph step implementation.

    Regards, SevenW

    • The trouble is that I coloured the 1st and 2nd graphs differently. Thanks for spotting this!

  4. The SB5000TL readouts every 5 minutes are indeed instantaneous power production figures, so dots would be the best—it really is a sampled signal of the finer, pulse counter measurement.

    If really you want to reconstruct some continuous signal from these samples, you could use some knowledge of the “system” you’re reconstructing: the sun doesn’t generally instantaneously turn off or on, so rectangles aren’t very good. Linear interpolations are better, but they still result in very sharp peaks (sudden changes in the solar intensity variation).

    The blue graph seems pretty smooth, so why not choose an interpolation method that results in a smooth graph, like Bezier curves? Yes, you will be inventing data and curves in-between the data points of which you have no knowledge, but you’re also doing that with the squares, or with straight lines.

    Of course, the pulse counter is a different story: there you know in fact the area underneath, and should make use of that by plotting squares.

Comments are closed.