On Wednesday, December 7, 2016 at 11:30:51 AM UTC-5, albes wrote: > > Hi Guys, sometimes my weewx reads strange data and generate peaks in the > outtemp history values. How can I avoid these peaks ? > I cannot understand why this is happening and I'm not sure it is related > to hardware... > The best way is to fix it via software. In my opinion it should be > possible to compare the current value with the last valid value registered > and accept it if it is included in a range. > For example: > > range = 2; > last_valid_value =13.3 > current_value = 13 > > if abs(last_valid_value - current_value) < range then OK > > My question is: where I can do this into the weewx code? >
take a look at bin/weewx/qc.py and bin/weewx/engine.py. you're interested in the QC implementation and the StdQC service that uses it. create a new quality control service, say user/spikedetector.py. follow the pattern used by StdQC to create your own quality-control service, then add that to the service list after StdQC in [Engine][[Services]] in your configuration file. the tricky part is that you will need to maintain state to do what you describe. you might want to capture and analyse the bogus data before you do too much coding. how big are the spikes you are trying to detect? can you detect a spike based on a single previous data point, or do you need 2? 3? 100? what parameters will you need to tune the detection algorithm? does this apply only to outTemp, or can the algorithm be used for other observations? which ones? if you've got the data, then you should be able to test your qc algorithm before you ever run the qc algorithm as a weewx service. that should make the whole process much more robust. m
