deeplycloudy / lmatools

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

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

Closed wx4stg closed 1 year ago

wx4stg commented 1 year ago
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

deeplycloudy commented 1 year ago

I think I fixed this same problem in xlma-python by requiring an additional point for calculating the areas and volumes - one more than is strictly necessary.

The try-except might still be a good idea; how does this relate to what you have in #37?

wx4stg commented 1 year ago

I think I fixed this same problem in xlma-python by requiring an additional point for calculating the areas and volumes - one more than is strictly necessary.

Requiring an additional point also seems to fix it on my end. the try/except/pass was just a band-aid to get it to process a dataset overnight without stopping, I didn't really understand what I was doing there.

The try-except might still be a good idea; how does this relate to what you have in https://github.com/deeplycloudy/lmatools/pull/37?

Oops, I didn't actually mean to include the try/except in the pull request.

deeplycloudy commented 1 year ago

I believe we can close this now that #37 is merged, but lmk if that's incorrect!