emoncms: phpfiwa and dat files

Hello 

I was curious to look "inside" these binary dat files.
There are some nice php scripts for this task. So, I downloaded from https://github.com/emoncms/usefulscripts the whole bunch of scripts.
In the "enginereaders" folder, I found phpfiwa.php. You set the location of your dat files and the feed ID et voilà. You point to phpfina.php with your browser and the script unpack everything for you in a human readable format.

Below, I copied a small part. 

Question: What are these NAN values and why have they not been recognized as valid numbers?

1435149300 212
1435149310 216
1435149320 NAN
1435149330 217
1435149340 NAN
1435149350 222
1435149360 210
1435149370 NAN
1435149380 211
1435149390 216
1435149400 NAN
1435149410 211
1435149420 211
1435149430 NAN
1435149440 215
1435149450 218
1435149460 NAN
1435149470 217
1435149480 217
1435149490 NAN 
1435149500 215 
1435149510 215 

Thanks for your support.

Walter

pb66's picture

Re: emoncms: phpfiwa and dat files

The fixed interval feeds must have every data point recorded even if it doesn't actually have a value to maintain the timestamps.

So for example ff you powerdown your monitor for 2mins and have feeds set at an interval of 10 seconds, when you power back up and you are missing 12 datapoints the engine will pack it out with NAN's so that the 12 missing values do not cause new data to be recorded incorrectly with a timestamp of 2mins earlier.

Without knowing the exact set up it's difficult to guess why the data wasn't available.

Paul

daturach's picture

Re: emoncms: phpfiwa and dat files

Thanks for your quick answer.

I send data every 15 secs. Should I modify the interval to be equal or bigger than 15?

pb66's picture

Re: emoncms: phpfiwa and dat files

Once created the interval cannot be changed as it would throw out the timestamping. If you had 1 days worth of data 1 datapoint per hour starting yesterday and you change the interval to 1 interval per day, the 24 "hourly" datapoints would now represent 24 days reaching 22 days into the future.

There is no perfect solution to your question if you send more frequently than you save some data is lost as it changes before it is saved, if you save more than you send the same values could get saved multiple times. If you try and match them you may get a slightly better result. But over time the variation shouldn't be much and the law of averages kicks in to say you will probably get as many high errors as low errors.

so you could change your sending interval to 10secs so if you wanted to match them or start a new feed.

If you want every value recorded as faithfully as possible the you should use phptimeseries but whether that actually achieves any greater accuracy is another question.

This isn't the reason for the NAN's though.

Paul

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.