Comments 1. No need to convert to float. These variables will already be float. 2. Your code has an implicit assumption that the second of two observation values is always the faulty one, but it could as easily be the first value. 3. The variables self.last_outTemp and last_outHumidity do not have a value on startup, so you will get an AttributeError. 4. These tests should be applied only to the LOOP packets. The archive records are derived from the LOOP packets. So, of the LOOP packets are OK, the archive values will be OK. 5. If you're going to do peak detection, you need to retain the last value and emit it in the next LOOP packet, once you're sure it's OK. This means the stream of LOOP packets are delayed by one cycle. 6. Finally, some instruments do not emit all observation types with every LOOP packet. So, how long you wait to emit a final, known good, value will depend on how often the type is emitted.
Keep plugging at it! -tk On Wed, Dec 7, 2016 at 10:57 AM, Alberto Serra <[email protected]> wrote: > What do you think about this code? > > if (data_type=='Archive'): > self.last_outTemp = data_dict['outTemp'] > self.last_outHumidity = data_dict['outHumidity'] > elif self.last_outTemp and self.last_outHumidity: > > difference = abs(float(self.last_outTemp) - > float(data_dict['outTemp'])) > syslog.syslog(syslog.LOG_NOTICE, "difference is: %s" > %difference ) > > if difference > self.delta_temp: > data_dict['outTemp'] = None > syslog.syslog(syslog.LOG_NOTICE, "difference is > delta > PROBABLE PEAK---VALUE DELETED" ) > else: > syslog.syslog(syslog.LOG_NOTICE, "difference is ok. No > Peak" ) > > > On Wed, Dec 7, 2016 at 7:14 PM, Alberto Serra <[email protected]> > wrote: > >> ok I can get the current value in qc.py. thank you >> >> but what is the differente between an archive value and a loop value? is >> the archive value the last value stored? >> >> def new_loop_packet(self, event): >> """Apply quality check to the data in a loop packet""" >> >> self.qc.apply_qc(event.packet, 'LOOP') >> >> def new_archive_record(self, event): >> """Apply quality check to the data in an archive record""" >> >> self.qc.apply_qc(event.record, 'Archive') >> >> >> if so it is simpy to check the difference between the two values :) >> >> correct me if I'm wrong >> >> >> On Wed, Dec 7, 2016 at 5:46 PM, Thomas Keffer <[email protected]> wrote: >> >>> See this issue: https://github.com/weewx/weewx/issues/3 >>> >>> If you want to give this a try, the code should go in the StdQC service. >>> >>> -tk >>> >>> On Wed, Dec 7, 2016 at 8:30 AM, albes <[email protected]> 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? >>>> >>>> >>>> >>> >> >> >> -- >> *Alberto Serra* >> ------------------------------------------- >> >> *Before you print think about the ENVIRONMENT - Prima di stampare pensa >> all'AMBIENTE* >> >> Ai sensi del D. Lgs. n.196 del 30/06/2003 si precisa che le informazioni >> contenute in questo messaggio sono riservate e ad uso esclusivo del >> destinatario. Qualora il messaggio in parola Le fosse pervenuto per errore, >> La preghiamo di eliminarlo senza copiarlo e di non inoltrarlo a terzi, >> dandocene gentilmente comunicazione. Grazie >> >> This message, for the D. Lgs. n.196 of 30/06/2003, may contain >> confidential and/or privileged information. If you are not the addressee or >> authorized to receive this for the addressee, you must not use, copy, >> disclose or take any action based on this message or any information >> herein. If you have received this message in error, please advise the >> sender immediately by reply e-mail and delete this message. Thank you for >> your cooperation. >> >> > > > -- > *Alberto Serra* > ------------------------------------------- > > *Before you print think about the ENVIRONMENT - Prima di stampare pensa > all'AMBIENTE* > > Ai sensi del D. Lgs. n.196 del 30/06/2003 si precisa che le informazioni > contenute in questo messaggio sono riservate e ad uso esclusivo del > destinatario. Qualora il messaggio in parola Le fosse pervenuto per errore, > La preghiamo di eliminarlo senza copiarlo e di non inoltrarlo a terzi, > dandocene gentilmente comunicazione. Grazie > > This message, for the D. Lgs. n.196 of 30/06/2003, may contain > confidential and/or privileged information. If you are not the addressee or > authorized to receive this for the addressee, you must not use, copy, > disclose or take any action based on this message or any information > herein. If you have received this message in error, please advise the > sender immediately by reply e-mail and delete this message. Thank you for > your cooperation. > >
