Got some data, seems to be doing what I wanted/expected. I was confused by the lightning_first_det_time of 1722466487. One would have thought this should be in the previous archive record. Then I realized that this is probably because of the polling time of 20 seconds. The last loop packet for the archive record of 1722466500 was most likely created prior to 1722466487.
I have thought about increasing the polling frequency, but at this time I don’t think it is worth it to me. +------------+------------------------+--------------------------+--------------------------+-------------------------+-------------------------+------------------------+ | dateTime | lightning_strike_count | lightning_first_det_time | lightning_first_distance | lightning_last_det_time | lightning_last_distance | lightning_min_distance | +------------+------------------------+--------------------------+--------------------------+-------------------------+-------------------------+------------------------+ | 1722462300 | 1.0 | 1722462266.0 | 10.563310264 | 1722462266.0 | 10.563310264 | 10.563310264 | | 1722465000 | 1.0 | 1722464831.0 | 14.912908608 | 1722464831.0 | 14.912908608 | 14.912908608 | | 1722466500 | 1.0 | 1722466382.0 | 12.42742384 | 1722466382.0 | 12.42742384 | 12.42742384 | | 1722466800 | 2.0 | 1722466487.0 | 10.563310264 | 1722466622.0 | 14.912908608 | 10.563310264 | | 1722472800 | 1.0 | 1722472693.0 | 6.21371192 | 1722472693.0 | 6.21371192 | 6.21371192 | | 1722485100 | 1.0 | 1722484859.0 | 6.21371192 | 1722484859.0 | 6.21371192 | 6.21371192 | | 1722485700 | 1.0 | 1722485491.0 | 6.21371192 | 1722485491.0 | 6.21371192 | 6.21371192 | +------------+------------------------+--------------------------+--------------------------+-------------------------+-------------------------+------------------------+ rich On Wednesday 31 July 2024 at 19:52:27 UTC-4 [email protected] wrote: > I finally had some time to experiment with my WH57. Here is what I ended > up doing. > I have the driver polling the 1100 every 20 seconds and my archive > interval is 5 minutes. > > ‘Out of the box’ the number of strikes in an archive interval is persisted > and the distance from the last strike, even if no strikes occurred in the > interval. Like many others, I only wanted the distance if a strike > occurred. In the [StdCalibrate][[Corrections]] I added the following. > lightning_distance = lightning_distance if lightning_strike_count and > lightning_strike_count > 0 else None > This checks that the loop packet field lightning_strike_count has a value > and it is greater than 0. Checking that the field has a value is important > because the first loop packet after starting WeeWX sets it to None. > > Persisting the last strike in an archive interval is nice, but I also > wanted to persist the closest. I also figured if I was capturing the last > strike, I might as well capture the first strike. I also decided to capture > the time of the first and last strike. (Note, without writing some code I > could not figure out a way to capture the time of the min (closest) strike. > > I also decided that the lightning_distance field would persist the average > distance to the strikes in the archive period. I did this for a couple of > reasons. First, for more consistent naming conventions. Second, it would > easily work with the Seasons skin. Note, I have no intention of using the > additional first, last, and min values in the Seasons skin. I will use my > WeeWX-JAS skin to display these. > > The first thing to do is get the data into these additional fields. I used > the [StdCalibrate][[Corrections]] section. I ended up with the following. > lightning_last_distance = lightning_distance if lightning_strike_count and > lightning_strike_count > 0 else None > lightning_last_det_time = lightning_last_det_time if > lightning_strike_count and lightning_strike_count > 0 else None > > lightning_first_distance = lightning_distance if lightning_strike_count > and lightning_strike_count > 0 else None > lightning_first_det_time = lightning_last_det_time if > lightning_strike_count and lightning_strike_count > 0 else None > > lightning_min_distance = lightning_distance if lightning_strike_count and > lightning_strike_count > 0 else None > > lightning_distance = lightning_distance if lightning_strike_count and > lightning_strike_count > 0 else None > > With these ‘corrections’, WeeWX now accumulates the lightning data into > multiple fields. In the loop packet, all of the distance fields have the > same value. Same with the time fields. Using the accumulator function, the > first, last, and min values can be extracted and put into the archive > record. > > My [Accumulator] section looks like the following. > # Additional lightning data, note lightning_last_det_time is below in > the GW1000 section > [[lightning_last_distance]] > extractor = last > [[lightning_first_distance]] > extractor = first > [[lightning_first_det_time]] > extractor = first > [[lightning_min_distance]] > extractor = min > # 'override' the setting that GW1000 driver has (I decided to set it > here and delete from the GW1000 section) > [[lightning_distance]] > extractor = avg > > Next, I used weectl database to add the new fields to the database. > > Finally I updated the bin/user/extensions.py with the units for the new > fields. > import weewx.units > weewx.units.obs_group_dict['lightning_last_distance'] = 'group_distance' > weewx.units.obs_group_dict['lightning_last_det_time'] = 'group_time' > weewx.units.obs_group_dict['lightning_first_distance'] = 'group_distance' > weewx.units.obs_group_dict['lightning_first_det_time'] = 'group_time' > weewx.units.obs_group_dict['lightning_min_distance'] = 'group_distance' > > Known limitations. > If there is more than one strike is in a loop packet interval (20 > seconds), the loop packet will have the number of strikes and the packet > will have the distance to and time of the last strike. > > Now to get some real data to experiment with displaying the data… > rich > -- You received this message because you are subscribed to the Google Groups "weewx-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/8b06ccb8-734f-440e-90c9-012c829bd04fn%40googlegroups.com.
