Code Monkey home page Code Monkey logo

lmatools's Introduction

Gridded Flash Products using lmatools

Requirements

  • python 3.6+ (no support for Python 2)
  • numpy
  • scipy
  • pyproj

For flash sorting and plotting:

  • scikit-learn
  • pytables
  • matplotlib

Usage

See examples/README for an example of how to

  1. Turn LMA ASCII data into HDF5 flash files.
  2. Turn the HDF5 flash data into 2D and 3D grids of flash properties
  3. Make some quick-look plots of the grids.
  4. Use an interactive interface to manually identify cells
  5. Use a log of the cells identified above to calculate flash statistics

Configuration

VHF sources are grouped into flashes by first filtering out noise sources by using the reduced chi-squared value and number of contributing stations for each VHF source. Chi-squared of less than 5.0 is typical; 1.0 is one threshold in wide use. For all but the worst-performing networks, a minimum of six stations should be used; where available, seven or more will give the most noise-free results. These values should be determined by examining the source data for time periods of interest on a case-by-case basis. This step is especially important for networks with frequent station drop-outs, where the network is asymmetric, or where the network has poor sensitivity.

Sources are grouped into flashes using space and time criteria. These default to 3 km spatial and 0.15 second temporal thresholds, with a maximum duration of 3 s. The only fully integrated algorithm in this codebase uses the DBSCAN clustering features in Python's scikit-learn. The flash sorting process is described in Fuchs et al. (2016),

Fuchs, B. R., E. C. Bruning, S. A. Rutledge, L. D. Carey, P. R. Krehbiel, and W. Rison, 2016: Climatological analyses of LMA data with an open-source lightning flash-clustering algorithm. J. Geophys. Res. Atmos., 121, 8625–8648, doi:10.1002/2015JD024663.

There is historical support for the McCaul et al. (2009, Weather and Forecasting) flash sorting algorithm, but it is not included here. The code architecture supports the addition of other algorithms.

Flashes are turned into gridded products by grabbing a flash, including associated VHF source points, performing filtering to select for certain kinds of flashes, doing necessary coordinate transformations, and then determining how each flash contributes to a gridded product field that has some meaning of interest. A requirement is levied on the minimum number of sources per flash, usually ten. The processing is implemented as a coroutine-style pipeline where flashes are pushed down the pipe before landing on a grid.

Grids may be specified in one of the many map projections available through pyproj, or a regular lat/lon grid may be used. The gridding process allows for simultaneous processing of multiple sequential time windows whose duration can be controlled.

Description of Product Types

For each of these products, except for perhaps flash initiation density, a logarithmic color mapping usually works best.

Source density

This product is a simple count of the VHF sources on the grid. It is the most basic form of gridded data that can be derived from the LMA data. It only counts those sources that contributed to a valid flash.

Flash initiation density

For each flash, the first VHF source point in time is taken as the flash initiation location. Therefore, each flash is represented by a single grid cell location A sum of all values on this grid gives the total number of flashes in the domain. The electric field rebuilds relatively rapidly in regions with larger flash initiation rates, since flashes initiate in regions of large electric field.

Flash extent density

Flash extent density gives a column-local flash rate; it is a count of how many flashes passed through that grid cell. This product highlights a key advantage of the LMA: it shows regions where it was energetically favorable (local maximum in electric potential) for flashes to frequently revisit.

Average flash area (footprint)

The average flash area product calculates the average area of all flashes that passed through a grid cell. It is the sum of the areas of all flashes that passed through a grid cell divided by the flash extent density. This product is good at highlighting regions with infrequent but very extensive flashes, such as MCS stratiform regions and supercell anvils. It can also highlight convective regions that have unusually small, frequent flashes.

Product file format

Grids are produced in a Climate and Forecast metadata (CF) compliant NetCDF format. The filename convention is as follows:

WTLMA_20120609_235000_3600_10src_0.0323deg-dx_source.nc

WTLMA: User-selectable prefix, often the network name 20120609: year, month, day 235000: hour, minute, second (start time) 3600: duration, seconds 10src: min points per flash 0.0323deg-dx: grid size in the x direction, in this case 0.0323 deg longitude source: product type (may be source, flash_init, flash_extent, or footprint)

HDF5 flash file format

The flash sorting process creates an intermediate HDF5 file that contains the LMA source data in an "events" table, as well as a "flash" table with flash metadata, such as center location, area, and start time. There is a common flash_id key in both tables that allows the sources for each flash to be retrieved.

Imagery format

Code also exists in the repository to take the NetCDF grid files and produce multi-panel summary images of the grid, with a panel for each time increment. Each file is turned into a single PDF, with control over the number of columns. The scripts that make these plots can serve as the basis for additional types of plots customized to serve other analysis or visualization needs.

lmatools's People

Contributors

deeplycloudy avatar djhoese avatar emmalhung avatar gewitterblitz avatar mbrothers18 avatar vbalderdash avatar vsalinas91 avatar wx4stg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

lmatools's Issues

Setup fails with Anaconda Python 3.8.5

I tried to install lmtools using Anaconda Python 3.8.5 on Debian using the command
python setup.py install

I got several syntax errors. I could fix the syntax error for "print" by adding parentheses.
Another error was for the statement "if weight_key <> None" and I assume that "<>" canbe replaced by "!="
The one error that I could not figure out was about this line:
filename = 'out/LMA-density_%s_%5.2fkm_%5.1fs.pdf' % (start_time.strftime('%Y%m%d_%H%M%S'), dx/1000.0, time_delta.seconds)
which gave invalid syntax

Hopefully you can figure out fixes for such errors.

This is the full output:

running install
running build
running build_py
creating build
creating build/lib
creating build/lib/lmatools
copying coordinateSystems.py -> build/lib/lmatools
copying fakeLMA.py -> build/lib/lmatools
copying AWIPS_tools.py -> build/lib/lmatools
copying multiples_nc.py -> build/lib/lmatools
copying multiples.py -> build/lib/lmatools
copying NLDN.py -> build/lib/lmatools
copying small_multiples.py -> build/lib/lmatools
copying init.py -> build/lib/lmatools
copying make_grids.py -> build/lib/lmatools
copying flash_stats.py -> build/lib/lmatools
copying lma_io.py -> build/lib/lmatools
copying density_tools.py -> build/lib/lmatools
copying grid_collection.py -> build/lib/lmatools
copying density_to_files.py -> build/lib/lmatools
creating build/lib/lmatools/flashsort
copying flashsort/init.py -> build/lib/lmatools/flashsort
creating build/lib/lmatools/flashsort/autosort
copying flashsort/autosort/autorun_mflash.py -> build/lib/lmatools/flashsort/autosort
copying flashsort/autosort/LMAarrayFile.py -> build/lib/lmatools/flashsort/autosort
copying flashsort/autosort/init.py -> build/lib/lmatools/flashsort/autosort
copying flashsort/autosort/flash_stats.py -> build/lib/lmatools/flashsort/autosort
copying flashsort/autosort/autorun_sklearn.py -> build/lib/lmatools/flashsort/autosort
copying flashsort/autosort/autorun.py -> build/lib/lmatools/flashsort/autosort
copying flashsort/autosort/write_flashes.py -> build/lib/lmatools/flashsort/autosort
running install_lib
creating /usr/local/anaconda3/lib/python3.8/site-packages/lmatools
copying build/lib/lmatools/coordinateSystems.py -> /usr/local/anaconda3/lib/python3.8/site-packages/lmatools
copying build/lib/lmatools/fakeLMA.py -> /usr/local/anaconda3/lib/python3.8/site-packages/lmatools
copying build/lib/lmatools/AWIPS_tools.py -> /usr/local/anaconda3/lib/python3.8/site-packages/lmatools
copying build/lib/lmatools/multiples_nc.py -> /usr/local/anaconda3/lib/python3.8/site-packages/lmatools
copying build/lib/lmatools/multiples.py -> /usr/local/anaconda3/lib/python3.8/site-packages/lmatools
copying build/lib/lmatools/NLDN.py -> /usr/local/anaconda3/lib/python3.8/site-packages/lmatools
copying build/lib/lmatools/small_multiples.py -> /usr/local/anaconda3/lib/python3.8/site-packages/lmatools
copying build/lib/lmatools/init.py -> /usr/local/anaconda3/lib/python3.8/site-packages/lmatools
copying build/lib/lmatools/make_grids.py -> /usr/local/anaconda3/lib/python3.8/site-packages/lmatools
creating /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort
copying build/lib/lmatools/flashsort/init.py -> /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort
creating /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort/autosort
copying build/lib/lmatools/flashsort/autosort/autorun_mflash.py -> /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort/autosort
copying build/lib/lmatools/flashsort/autosort/LMAarrayFile.py -> /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort/autosort
copying build/lib/lmatools/flashsort/autosort/init.py -> /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort/autosort
copying build/lib/lmatools/flashsort/autosort/flash_stats.py -> /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort/autosort
copying build/lib/lmatools/flashsort/autosort/autorun_sklearn.py -> /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort/autosort
copying build/lib/lmatools/flashsort/autosort/autorun.py -> /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort/autosort
copying build/lib/lmatools/flashsort/autosort/write_flashes.py -> /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort/autosort
copying build/lib/lmatools/flash_stats.py -> /usr/local/anaconda3/lib/python3.8/site-packages/lmatools
copying build/lib/lmatools/lma_io.py -> /usr/local/anaconda3/lib/python3.8/site-packages/lmatools
copying build/lib/lmatools/density_tools.py -> /usr/local/anaconda3/lib/python3.8/site-packages/lmatools
copying build/lib/lmatools/grid_collection.py -> /usr/local/anaconda3/lib/python3.8/site-packages/lmatools
copying build/lib/lmatools/density_to_files.py -> /usr/local/anaconda3/lib/python3.8/site-packages/lmatools
byte-compiling /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/coordinateSystems.py to coordinateSystems.cpython-38.pyc
byte-compiling /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/fakeLMA.py to fakeLMA.cpython-38.pyc
File "/usr/local/anaconda3/lib/python3.8/site-packages/lmatools/fakeLMA.py", line 18
print "Regenerating preloadable LMA data"
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Regenerating preloadable LMA data")?

byte-compiling /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/AWIPS_tools.py to AWIPS_tools.cpython-38.pyc
File "/usr/local/anaconda3/lib/python3.8/site-packages/lmatools/AWIPS_tools.py", line 106
print h5_filenames
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(h5_filenames)?

byte-compiling /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/multiples_nc.py to multiples_nc.cpython-38.pyc
File "/usr/local/anaconda3/lib/python3.8/site-packages/lmatools/multiples_nc.py", line 215
print label_string, x.shape, density.max(), density.sum()
^
SyntaxError: invalid syntax

byte-compiling /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/multiples.py to multiples.cpython-38.pyc
File "/usr/local/anaconda3/lib/python3.8/site-packages/lmatools/multiples.py", line 195
if len(these_events) <> fl['n_points']:
^
SyntaxError: invalid syntax

byte-compiling /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/NLDN.py to NLDN.cpython-38.pyc
byte-compiling /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/small_multiples.py to small_multiples.cpython-38.pyc
File "/usr/local/anaconda3/lib/python3.8/site-packages/lmatools/small_multiples.py", line 12
raise AssertionError, "A valid figure must be passed in."
^
SyntaxError: invalid syntax

byte-compiling /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/init.py to init.cpython-38.pyc
byte-compiling /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/make_grids.py to make_grids.cpython-38.pyc
File "/usr/local/anaconda3/lib/python3.8/site-packages/lmatools/make_grids.py", line 423
print 'max extent is', extent_density_grid.max()
^
SyntaxError: invalid syntax

byte-compiling /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort/init.py to init.cpython-38.pyc
byte-compiling /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort/autosort/autorun_mflash.py to autorun_mflash.cpython-38.pyc
File "/usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort/autosort/autorun_mflash.py", line 199
print flashes.cols.init_lon[0:10]
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(flashes.cols.init_lon[0:10])?

byte-compiling /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort/autosort/LMAarrayFile.py to LMAarrayFile.cpython-38.pyc
File "/usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort/autosort/LMAarrayFile.py", line 310
print lma.startmonth, lma.startday, lma.startyear
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(lma.startmonth, lma.startday, lma.startyear)?

byte-compiling /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort/autosort/init.py to init.cpython-38.pyc
byte-compiling /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort/autosort/flash_stats.py to flash_stats.cpython-38.pyc
File "/usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort/autosort/flash_stats.py", line 148
print "Perturbing one source to help triangulation for flash with {0} points".format(flash.pointCount)
^
SyntaxError: invalid syntax

byte-compiling /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort/autosort/autorun_sklearn.py to autorun_sklearn.cpython-38.pyc
File "/usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort/autosort/autorun_sklearn.py", line 39
print id1.shape, id2.shape
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(id1.shape, id2.shape)?

byte-compiling /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort/autosort/autorun.py to autorun.cpython-38.pyc
File "/usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort/autosort/autorun.py", line 126
print flashes.cols.init_lon[0:10]
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(flashes.cols.init_lon[0:10])?

byte-compiling /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flashsort/autosort/write_flashes.py to write_flashes.cpython-38.pyc
byte-compiling /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flash_stats.py to flash_stats.cpython-38.pyc
File "/usr/local/anaconda3/lib/python3.8/site-packages/lmatools/flash_stats.py", line 322
print pattern
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(pattern)?

byte-compiling /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/lma_io.py to lma_io.cpython-38.pyc
File "/usr/local/anaconda3/lib/python3.8/site-packages/lmatools/lma_io.py", line 40
print '{0} -- {1} flashes > {2} pts; dt+={3} '.format(filename, n_flashes, min_points, extra_dt)
^
SyntaxError: invalid syntax

byte-compiling /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/density_tools.py to density_tools.cpython-38.pyc
File "/usr/local/anaconda3/lib/python3.8/site-packages/lmatools/density_tools.py", line 148
print "Tests complete."
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Tests complete.")?

byte-compiling /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/grid_collection.py to grid_collection.cpython-38.pyc
byte-compiling /usr/local/anaconda3/lib/python3.8/site-packages/lmatools/density_to_files.py to density_to_files.cpython-38.pyc
File "/usr/local/anaconda3/lib/python3.8/site-packages/lmatools/density_to_files.py", line 141
print flash_count_messages
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(flash_count_messages)?

running install_egg_info
Writing /usr/local/anaconda3/lib/python3.8/site-packages/lmatools-0.1-py3.8.egg-info

Southern hemisphere coordinate transforms

Via @tjlang, "You had a bug in the attached script, which caused the projections to fail in the southern hemisphere (everything was erroneously rotated 180 degrees around the projection center). The specific issue was the definition of localy in the TangentPlaneCartesianSystem class. I fixed it with a simple if-then statement (see lines 277-280) and now the projections essentially match what Basemap does."

    localy = dot(P, northCenterECEF[:,newaxis] )
    if ctrLat >= 0:
        localy = -localy / norm(localy)  # negation gets x and y pointing in the right direction
    else:
        localy = localy / norm(localy)  # No negation in southern hemisphere

Fix error caused by pyproj >= 2.2

First seen in glmtools#31, an API change in pyproj results in a crash due to a check for a mysterious 'time' dimension. I reproduced it today when testing flash sorting on a simple file, as seen below.

Traceback (most recent call last):
  File "flash_sort_and_grid.py", line 187, in <module>
    ctr_lat=params['ctr_lat'], ctr_lon=params['ctr_lon'], center_ID=center_ID)
  File "flash_sort_and_grid.py", line 129, in grid_and_plot
    output_filename_prefix=center_ID, spatial_scale_factor=1.0
  File "/Users/ebruning/code/lmatools/lmatools/grid/make_grids.py", line 631, in grid_h5flashfiles
    gridder.process_flashes(h5_filenames, **process_flash_kwargs)
  File "/Users/ebruning/code/lmatools/lmatools/grid/make_grids.py", line 608, in process_flashes
    read_flashes( h5_filenames, self.framer, base_date=self.t_ref, min_points=min_points_per_flash)
  File "/Users/ebruning/code/lmatools/lmatools/io/LMA_h5_file.py", line 253, in read_flashes
    target.send(push_out)
  File "/Users/ebruning/code/lmatools/lmatools/grid/density_to_files.py", line 215, in flashes_to_frames
    target.send((these_events, these_flashes))
  File "/Users/ebruning/code/lmatools/lmatools/grid/density_to_files.py", line 247, in extract_events_for_flashes
    target.send((events, fls))
  File "/Users/ebruning/code/lmatools/lmatools/stream/subset.py", line 83, in broadcast
    target.send(stuff)
  File "/Users/ebruning/code/lmatools/lmatools/grid/density_to_files.py", line 291, in project
    points[x_coord], points[y_coord], points[z_coord]))
  File "/Users/ebruning/code/lmatools/lmatools/coordinateSystems.py", line 74, in toECEF
    projectedData = array(proj4.transform(self.ERSlla, self.ERSxyz, lon, lat, alt ))
  File "/Users/ebruning/miniconda3/envs/glmval/lib/python3.6/site-packages/pyproj/transformer.py", line 759, in transform
    ).transform(xx=x, yy=y, zz=z, tt=tt, radians=radians, errcheck=errcheck)
  File "/Users/ebruning/miniconda3/envs/glmval/lib/python3.6/site-packages/pyproj/transformer.py", line 445, in transform
    errcheck=errcheck,
  File "pyproj/_transformer.pyx", line 432, in pyproj._transformer._Transformer._transform
pyproj.exceptions.ProjError: x,y,z, and time must be same size

Traceback in __iter__(self)

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

lmatools/examples/flash_sort_and_grid.py

Adding dz as a parameter in the grid_h5flashfiles function (line 125) will provide the user more flexibility to choose a custom value of vertical bin size to group the flash initiation, sources etc.

Flashes that have one source perturbed raises an exception when calculating hull_volume

Perturbing one source to help triangulation for flash with 4 points
QH6154 Qhull precision error: Initial simplex is flat (facet 1 is coplanar with the interior point)

While executing:  | qhull d Qc Qt Qz Qbb Q12
Options selected for Qhull 2019.1.r 2019/06/21:
  run-id 1477540198  delaunay  Qcoplanar-keep  Qtriangulate  Qz-infinity-point
  Qbbound-last  Q12-allow-wide  _pre-merge  _zero-centrum  Qinterior-keep
  Pgood  _max-width 5e+02  Error-roundoff 5.1e-13  _one-merge 4.6e-12
  Visible-distance 3.1e-12  U-max-coplanar 3.1e-12  Width-outside 6.2e-12
  _wide-facet 1.8e-11  _maxoutside 6.2e-12

precision problems (corrected unless 'Q0' or an error)
      3 degenerate hyperplanes recomputed with gaussian elimination
      3 nearly singular or axis-parallel hyperplanes
      3 zero divisors during back substitute
      4 zero divisors during gaussian elimination

The input to qhull appears to be less than 4 dimensional, or a
computation has overflowed.

Qhull could not construct a clearly convex simplex from points:
- p2(v5):   6.2    89  -3.5     0
- p4(v4): 0.054 -0.14 0.0083 2.5e+02
- p1(v3):   6.2    89  -3.5     0
- p3(v2):    46 -1.3e+02 -2.5e+02 2.3e+02
- p0(v1):   -58   -52 2.5e+02 2e+02

The center point is coplanar with a facet, or a vertex is coplanar
with a neighboring facet.  The maximum round off error for
computing distances is 5.1e-13.  The center point, facets and distances
to the center point are as follows:

center point    0.054  -0.1393 0.008251    136.9

facet p4 p1 p3 p0 distance= -2.6e-15
facet p2 p1 p3 p0 distance= -2.8e-15
facet p2 p4 p3 p0 distance= -2.3e-15
facet p2 p4 p1 p0 distance= -1e-15
facet p2 p4 p1 p3 distance= -9.7e-16

These points either have a maximum or minimum x-coordinate, or
they maximize the determinant for k coordinates.  Trial points
are first selected from points that maximize a coordinate.

The min and max coordinates for each dimension are:
  0:    -58.33     46.12  difference= 104.4
  1:    -127.2     89.25  difference= 216.4
  2:    -247.1     254.3  difference= 501.4
  3:         0     254.3  difference= 254.3

If the input should be full dimensional, you have several options that
may determine an initial simplex:
  - use 'QJ'  to joggle the input and make it full dimensional
  - use 'QbB' to scale the points to the unit cube
  - use 'QR0' to randomly rotate the input for different maximum points
  - use 'Qs'  to search all points for the initial simplex
  - use 'En'  to specify a maximum roundoff error less than 5.1e-13.
  - trace execution with 'T3' to see the determinant for each point.

If the input is lower dimensional:
  - use 'QJ' to joggle the input and make it full dimensional
  - use 'Qbk:0Bk:0' to delete coordinate k from the input.  You should
    pick the coordinate with the least range.  The hull will have the
    correct topology.
  - determine the flat containing the points, rotate the points
    into a coordinate plane, and delete the other coordinates.
  - add one or more points to make the input full dimensional.

I've attached a file which reproduces this error. The way I "fixed" it was to simply add a try-except block around the hull volume function call and skip it if an exception occurs, but this probably isn't the greatest idea.

LYLOUT_220322_30000_0600.exported.dat.gz

Isolate matplotlib dependency

Certain parts of lmatools rely on matplotlib. Those parts of lmatools are not used by glmtools, but the imports are convolved, and so matplotlib becomes a dependency for glmtools. It would be good to do some work to better isolate matplotlib.

If I uninstall matplotlib and run glmtools to create some grids in its usual mode, the first place it throws an error is:

Traceback (most recent call last):
  File "./grid/make_GLM_grids.py", line 300, in <module>
    gridder, glm_filenames, start_time, end_time, grid_kwargs = grid_setup(args)
  File "./grid/make_GLM_grids.py", line 134, in grid_setup
    from glmtools.grid.make_grids import grid_GLM_flashes
  File "/Users/ebruning/anaconda/envs/glmval-prod-test/lib/python3.7/site-packages/glmtools-0.1.dev0-py3.7.egg/glmtools/grid/make_grids.py", line 13, in <module>
    from glmtools.io.mimic_lma import read_flashes
  File "/Users/ebruning/anaconda/envs/glmval-prod-test/lib/python3.7/site-packages/glmtools-0.1.dev0-py3.7.egg/glmtools/io/mimic_lma.py", line 18, in <module>
    from lmatools.lasso.cell_lasso_timeseries import TimeSeriesGenericFlashSubset
  File "/Users/ebruning/code/lmatools/lasso/cell_lasso_timeseries.py", line 9, in <module>
    from lmatools.lasso.energy_stats import TimeSeriesPolygonLassoFilter 
  File "/Users/ebruning/code/lmatools/lasso/energy_stats.py", line 18, in <module>
    from stormdrain.support.matplotlib.formatters import SecDayFormatter
  File "/Users/ebruning/code/stormdrain/support/matplotlib/formatters.py", line 5, in <module>
    from matplotlib.ticker import Formatter, EngFormatter
ModuleNotFoundError: No module named 'matplotlib'

TimeSeriesGenericFlashSubset does not require the point-in-polygon features used from Matplotlib, nor does an application not requiring plots need a matplolib tick formatter. So, this is the first place to start to remove the matplotlib dependency.

ENH: Add test dataset

Add WTLMA data from 2014 May 26, 0940Z-1000Z. Process two files to show that it works.

ASCII LMA -> HDF5 + grids

Modify GUI example to use these data by default.

Don't forget to scrub station location information.

BUG: indexing assumption for flash initial position

It applies to data sorted with the mflash clustering method. It may also apply to the sklearn clustering method, but this has not been verified.

The point data are recorded out of order to the HDF5 file, because I sort the mflash output (which I verified is in time order) by flash_id to split the flashes up.
https://github.com/deeplycloudy/lmatools/blob/master/flashsort/autosort/autorun_mflash.py#L114
That sort algorithm, when applied to flash_id, isn’t guaranteed to preserve the original time order.

The time is still calculated correctly, since I take the minimum of the time:
https://github.com/deeplycloudy/lmatools/blob/master/flashsort/autosort/flash_stats.py#L142

But the initial position is taken to be the first index, which isn’t guaranteed to be the minimum since the time is not sorted in order:
https://github.com/deeplycloudy/lmatools/blob/master/flashsort/autosort/flash_stats.py#L146

The thing to do would be to use argmin instead of min to find the time index that is minimum, and then use that index to get the time and position of the first source.

In summary:

  1. The flash IDs go with the correct sources
  2. The start time is correct
  3. The start lat/lon/alt is incorrect when using mflash
  4. The problem could be corrected by manually recalculating the flash metadata table after applying my suggested fix.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.