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 weewx-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/e4914b23-6a2a-41ab-93bf-d25622d19540n%40googlegroups.com.

Reply via email to