Closed johnjarmitage closed 3 years ago
Thanks for this John. I had a fix in the develop
branch, but I have not tested it rigorously. It was a different approach to you. If you get a chance to try it out, I'd be interested in knowing if it fixes the problem you were experiencing.
You'd install with python -m pip install --upgrade https://github.com/agile-geoscience/striplog/archive/develop.zip
Hi Matt, it is possible your fix does not work as I get the out of bounds error message. Is there a way to check that I am using the develop branch after running the pip command? (Sorry that I have a slow return around time on this issue)
Hi John, you can check the version with the following in a python interpreter:
import striplog
striplog.__version__
for me that is 0.8.8
, which is the most recent development version. I am not sure exactly when the fix Matt mentions above went in, since the last commit is dated to January 12th.
Yep that is the version number I have. I am testing the modifications on the develop branch, so before replying that it does not work I would like to be sure. I had a look at the repo and it says that for the develop branch: "This branch is even with master." Does this perhaps mean that Matt's modifications have not been pushed to the repo?
Oops, my bad, I think I was in master
, sorry about that. Anyway, develop
is now synced and both are pushed.
I have not had success:
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-6-771446b87056> in <module>
1 from striplog import Striplog
2
----> 3 strip = Striplog.from_image(infile,
4 start=0, stop=2631,
5 col_offset=5, # How far across the image to extract pixels.
~/miniconda3/envs/sedlogs/lib/python3.9/site-packages/striplog/striplog.py in from_image(cls, filename, start, stop, legend, source, col_offset, row_offset, tolerance, background)
850
851 # Get the pixels and colour values at 'tops' (i.e. changes).
--> 852 tops, hexes = utils.tops_from_loglike(loglike, offset=row_offset)
853
854 # If there are consecutive tops, we assume it's because there is a
~/miniconda3/envs/sedlogs/lib/python3.9/site-packages/striplog/utils.py in tops_from_loglike(a, offset, null)
476 tops = np.append(0, tops)
477
--> 478 values = a[tops + offset]
479
480 if contains_nans and transformed:
IndexError: index 12413 is out of bounds for axis 0 with size 12413
I attach an image of the log I am trying to digitalise so you can test it at your end to be sure it is not my fault for not managing to update to the most recent version of striplog.
sorry, the attached image comes out huge...
Hi @johnjarmitage I was just taking a look to try and fix this. The code in your error message does not look like the current code that I am seeing in the repo. The current version looks like this for the lines giving the error you posted above:
offs = tops + offset
values = a[offs[offs < a.size]]
This snippet should prevent the IndexError that you are getting. I am not sure which version you are using, but it might not be happening with the newer version. Do you have some shareable data that I can test this with to try and replicate it? I am not sure if the snippet that I am seeing has had a release, but it looks like the change was here: https://github.com/agile-geoscience/striplog/commit/9ef74bf5622397c76750a8081831f6a7029a75e8
Hi @mtb-za
I ran python -m pip install --upgrade https://github.com/agile-geoscience/striplog/archive/develop.zip
and then relaunched my notebook. There is now no error message, so it is possible that this bug has been fixed during the SWUNG meeting.
You can close the issue I think.
I am glad that it seems to have been resolved. Let us know if there is anything more that you come across.
Hi Matt et al. I can propose a solution to the issue I encountered with the sediment log I was testing.
issue Error when
offset
is to large causing the functiontops_from_loglike
inutils.py
to look for values in the arraya
that are out of range.fix I propose to create a while loop that will chop of the last lithology unit if it is too thin for the chosen
offset
(from line 478 inutils.py
)I can make a pull request for this fix if you want, but I am not sure how generic this solution is.