deeplycloudy / lmatools

Python code for working with VHF Lightning Mapping Array data
BSD 2-Clause "Simplified" License
22 stars 23 forks source link

Traceback in __iter__(self) #18

Closed ldfowler58 closed 6 years ago

ldfowler58 commented 6 years ago

I am getting the following Traceback in:

File "/Users/laura/.local/lib/python2.7/site-packages/lmatools/io/LMA_h5_file.py", line 245, in read_flashes for push_out in h5s: # get a stream of events, flashes File "/Users/laura/.local/lib/python2.7/site-packages/lmatools/io/LMA_h5_file.py", line 139, in iter flashes['flash_id'].max()) File "/Users/laura/anaconda2/lib/python2.7/site-packages/numpy/core/_methods.py", line 26, in _amax return umr_maximum(a, axis, None, out, keepdims)

but cannot figure out why for the specific hdf5 file I am using. Looks like it happens for some hdf5 files while I do not have issues otherwise. For that specific file, I do not have any issues reading events['flash_id'] but flashes['flash_id'] is empty. Therefore, we cannot find the max value between events and flashes.

events flash_id = [ 1 2 2 3 4 5 6 7 8 9 10 10 11 12 13 14 15 16 17 18 19 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 38 39 40 41 42 43 44 45 46 47 48 49 50 . .

flashes flash_id = [] flashes ctr_alt = [] Traceback (most recent call last): File "flash_sort_and_grid.py", line 191, in ctr_lat=params['ctr_lat'], ctr_lon=params['ctr_lon'], center_ID=center_ID)

However, when reading the hdf5 file outside of lmatools, flashes['flash_id'] is definitely not empty? I would really appreciate a hint on what to do next?

Thanks, Laura

PS: I am using the branch flashsortrefactor

deeplycloudy commented 6 years ago

This was an error caused for files where there were no flashes larger than the required minimum number of points per flash (default 10). Thanks for all the detailed debugging. It made this fast to track down.

In your example above, all the events in the file are returned from the file (each of which is probably a single-point "flash", i.e., a noise point, which I infer from the constantly incrementing flash_id. The flashes table is filtered on the number of sources per flash, and so winds up empty.

I have fixed this error in a commit to flashsortrefactor just a moment ago: https://github.com/deeplycloudy/lmatools/commit/2f416a9d507a533d46c5ca3235bb9f5b6e2e68d9

That commit also fixes a Python 2.7 compatibility issue related to generator .next() calls.