GeostatsGuy / GeostatsPy

GeostatsPy Python package for spatial data analytics and geostatistics. Started as a reimplementation of GSLIB, Geostatistical Library (Deutsch and Journel, 1992) from Fortran to Python, Geostatistics in a Python package. Now with many additional methods. I hope this resources is helpful, Prof. Michael Pyrcz
https://pypi.org/project/geostatspy/
MIT License
479 stars 183 forks source link

numba acceleration #18

Open dsfulf opened 4 years ago

dsfulf commented 4 years ago

Addition of numba JIT'ing to a number of different functions. JITKW is a constant passed to each @jit decorator to easily enable/disable the compilation.

Several functions also have a parallel kwarg to turn it on and off. I've tested a number of functions with parallel=True, and many of them will crash due to what I believe is accessing mutable objects in a shared memory space. I've added a comment these.

I've also found that several functions run faster without parallelization. I've also added a comment to note these.

In order to add numba acceleration to the kb2d function, I've had to remove all objects from the JIT'ed code. This includes the scipy.cKDTree object, which is instead evaluated prior to being passed into the compiled function. While this increases memory use, the computation time is decreased by a factor of >100, so the trade-off is worth it for most problems. Because of this significant change, I've created a new function kb2d_jit that is accelerated, and left the kb2d function as it was. Reimplementation of the k-d tree to allow numba compilation, would reduce the memory usage, but some language features used by scipy.KDTree aren't currently supported so it would require significant rework.

There's also an immense amount of reformatting, and a lot of unnecessary white space deletion. This is done by an auto-formatting tool, autopep8, to make the code conform to PEP 8 standards.