You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The tesseroid forward modelling function checks if no observation point falls inside any tesseroid through the _check_points_outside_tesseroids function:
+"Computation points must be outside of tesseroids.\n"
)
forpoint_i, tess_iinnp.argwhere(inside):
err_msg+="\tComputation point '{}' found inside tesseroid '{}'\n".format(
coordinates[:, point_i], tesseroids[tess_i, :]
)
raiseValueError(err_msg)
This functions makes use of Numpy arrays to run these checks, but this is super inefficient, since Numpy will try to allocate massive arrays of shapes (n_coords, n_tesseroids).
Solution
We should rewrite this function using Numba instead, making sure that we aren't allocating any additional array and the function just checks if observation points don't fall inside any tesseroids. We could also benefit from Numba parallelizations and run the first for loop in parallel (this should follow the user's choice set through the parallel argument in tesseroid_gravity).
Description of the problem:
The tesseroid forward modelling function checks if no observation point falls inside any tesseroid through the
_check_points_outside_tesseroids
function:harmonica/harmonica/_forward/_tesseroid_utils.py
Lines 405 to 461 in b8f037e
This functions makes use of Numpy arrays to run these checks, but this is super inefficient, since Numpy will try to allocate massive arrays of shapes (
n_coords
,n_tesseroids
).Solution
We should rewrite this function using Numba instead, making sure that we aren't allocating any additional array and the function just checks if observation points don't fall inside any tesseroids. We could also benefit from Numba parallelizations and run the first for loop in parallel (this should follow the user's choice set through the
parallel
argument intesseroid_gravity
).As a quick design, we could do something like:
Check out https://github.com/fatiando/harmonica/blob/main/harmonica/_forward/prism.py for inspiration on how to code this.
Temporary solution
For the moment, the check can be bypassed by passing
disable_checks=True
, but it also disables other checks.The text was updated successfully, but these errors were encountered: