Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: index 4 is out of bounds for axis 0 with size 4 #38

Open
EChenevert opened this issue May 18, 2022 · 2 comments
Open

IndexError: index 4 is out of bounds for axis 0 with size 4 #38

EChenevert opened this issue May 18, 2022 · 2 comments

Comments

@EChenevert
Copy link

I am trying to implement the declustering function on my dataframe which consists of longitude, latitude, and sediment accumulation variables, but I am getting an out of index error. I am having trouble fixing this error myself, could someone help me figure this out? Below is the traceback:

Traceback (most recent call last):
File "", line 1, in
File "C:\Users\etachen\AppData\Local\JetBrains\PyCharm 2021.2.2\plugins\python\helpers\pydev_pydev_bundle\pydev_umd.py", line 198, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "C:\Users\etachen\AppData\Local\JetBrains\PyCharm 2021.2.2\plugins\python\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/etachen/PycharmProjects/ai_algo_tests/declustering_medium_test.py", line 21, in
W, Csize, Dmean = geostat.declus(df,'Longitude', 'Latitude', 'Average Accretion (mm)',
File "C:\Users\etachen\Anaconda3\envs\ai_algo_tests\lib\site-packages\geostatspy\geostats.py", line 1607, in declus
cellwt[icell] = cellwt[icell] + 1.0
IndexError: index 4 is out of bounds for axis 0 with size 4

@EChenevert
Copy link
Author

Okay I was able to find a solution by reducing the noff parameter to only 5. Any value greater than 5 gave me back the same error

@jonm3D
Copy link

jonm3D commented Sep 15, 2023

I am also getting this error, but changing noff doesn't fix the issue for me. I'm using a geodataframe with dimension (515,20) and the following DECLUS inputs:

weights, cell_sizes, dmeans = geostats.declus(ddf,'X','Y','dZ',
iminmax = 1,
noff= 10, ncell=1000,
cmin=1, cmax=50)

The problematic dataframe can be downloaded here (link to download gpkg from box).

I've tried resetting the dataframe index, using a different subset of rows/columns, converting to a standard Dataframe, varying the values for iminmax/noff/ncell/cmin/cmax but I haven't been able to isolate the cause.

Here is the specific error message I am getting:

IndexError                                Traceback (most recent call last)
Cell In [33], line 1
----> 1 weights, cell_sizes, dmeans = geostats.declus(ddf.loc[:, ['X', 'Y', 'dZ']],'X','Y','dZ',
      2                                           iminmax = 1, 
      3                                           noff= 10, ncell=1000,
      4                                           cmin=1, cmax=50)
      6 ddf['W'] = weights
      7 ddf.head()                                  

File /srv/conda/envs/notebook/lib/python3.10/site-packages/geostatspy/geostats.py:1607, in declus(df, xcol, ycol, vcol, iminmax, noff, ncell, cmin, cmax)
   1605     icell = icellx + (icelly - 1) * ncellx
   1606     index[i] = icell
-> 1607     cellwt[icell] = cellwt[icell] + 1.0
   1609 # The weight assigned to each datum is inversely proportional to the
   1610 # number of data in the cell. We first need to get the sum of
   1611 # weights so that we can normalize the weights to sum to one
   1612 sumw = 0.0

IndexError: index 3109994 is out of bounds for axis 0 with size 3109994```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants