Occasional Weather Errors (Re-using Old Data)


#1

1) Give a description of the problem
Every hour, I am querying $weather.conditions.current_observation.pressure_in, and using the results to draw a graph. It’s been working beautifully for the past 3 months, but about 2-3 times a month, WUnderground returns a zero (or maybe it’s a null). Now, honestly, that is an acceptable tolerance of errors (2-3 bad out of 728 polled), but each time it happens, it TRASHES my graph, which stays sloppy (and unusable) for 47 hours, at which time the bad data finally scrolls off the side of my graph.

2) What is the expected behavior?
What I have done to try to solve this is: in the last few steps in the piston, I store the current ‘myPressure’ number into 'myPressureOld", and add +10 to create ‘myPressureOldMax’, and subtract -10 to create ‘myPressureOldMin’.

Then, at the beginning of the piston (when it runs next) it checks to see if the NEW number is inside the range of ‘Min’ and ‘Max’. If it is, I can assume it is good data, and to carry on like normal. If it is outside that range, I can assume it is a glitch in WUnderground, and we re-use the ‘Old’ data one time.

3) What is happening/not happening?
About 2-3 times a month, a -1692.44 slips past somehow. (all my numbers should fall between 0 and 100) When I examine the math a bit, I notice that if wuPressure is 0, then myPressure would be -1692.44. This leads me to think that WUnderground returned a zero or null.

So I guess my question is, why is my IF statement not catching the negative number after the math, and re-using the old (yet still fairly accurate) number?

4) Post a Green Snapshot of the piston

Is there a better way to code that IF statement?

(In case you are wondering, wuPressure is data straight from WUnderground, and myPressure is my custom math to make it fall between 0-100 for my location)

Just to show you the descrepancy, here is 7 hours of data, with the error in the middle:

45.35
46.51
46.51
-1692.44
50.58
51.16
51.74

Finding the SECOND lowest number in an array
#2

Surely someone can point out where I went wrong…


#3

why the 2 waits?

where are you setting old, min and max?


#4

I have a bunch of other queries unrelated to pressure (so not seen here). The tiny wait is just to make sure everything is caught up before continuing.

Here is the code again with the extra 3 steps I forgot to include last time:

…and at the very bottom, the following lines prepares the variables for the next time it is run:

temp


#5

Could it have something to do with your conversion subtracting 29.xx and multiplying by 58.xx? If the pressure drops below 29, wouldn’t that give you a rather large negative number?


#6

Well that is my dilemma. If the wuPressure coming in is accurate, then myPressure will always be between 0-100. It is on the rare occasions (2-3 times a month) that either WUnderground returns a 0 or a null. When doing the math on 0, myPressure ends up being -1692.44

My IF statement shown above is supposed to catch the crazy number, and re-use the data from the previous hour. Unfortunately, it is not. Is there a better way to write that IF statement?


#7

Can you post up the whole piston? Curious to see if something further down is defeating your safeguard step.


#8

I could but all the data gathering and storing is shown above. The full piston will likely be confusing.

But at your request, here’s the whole piston, although I did have to block out a bunch of lines since this is going to a private server to draw a graph based on the numbers gathered. That sections works perfectly, and my PHP draws a graph based on the numbers that webCoRE has accumulated.

And, for the record, I have recently learned a better way to do lines 114-159, but there is no need for me to worry about that until I can catch the bad data that slips past first.

Here is the current tile, with all good data:

temp2


#9

I made a change to my code, so now the ENTIRE code is indented right after this:

temp

The downfall to this method though is that no data gets written or stored when bad data comes in. But I guess it’s better to loose one data point than to have inaccurate data. If this turns out to be reliable, I might code in the ELSE section to reuse the previous hours data.