techmatters / soil-id-algorithm

GNU Affero General Public License v3.0
1 stars 0 forks source link

bug: algorithm crash "Could not broadcast input array" #112

Closed shrouxm closed 2 months ago

shrouxm commented 3 months ago

Description

The algorithm crashes on some coordinates with the message "Could not broadcast input array..."

Steps To Reproduce

Query the algorithm with the following coordinates:

{"lat": 42.494912, "lon": -123.064531}

Expected behavior

The algorithm returns successfully.

Actual behavior

The algorithm crashes with the following traceback:

Traceback (most recent call last):
  File "/app/terraso_backend/apps/soil_id/graphql/soil_id.py", line 242, in resolve_location_based_soil_matches
    result = list_soils(lat=latitude, lon=longitude)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/terraso/.local/lib/python3.12/site-packages/soil_id/us_soil.py", line 418, in list_soils
    aws_PIW90, var_imp = soil_sim(muhorzdata_pd)
                         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/terraso/.local/lib/python3.12/site-packages/soil_id/soil_sim.py", line 256, in soil_sim
    simulate_correlated_triangular(
  File "/home/terraso/.local/lib/python3.12/site-packages/soil_id/utils.py", line 2122, in simulate_correlated_triangular
    samples[condition, i] = a + np.sqrt(u[condition] * (c - a) * (b - a))
    ~~~~~~~^^^^^^^^^^^^^^
ValueError: could not broadcast input array from shape (1,135) into shape (1,3)

Additional context

These coordinates are in a normal map unit as far as I can tell (see on SoilWeb), so it seems fairly high priority to me.