harmonica icon indicating copy to clipboard operation
harmonica copied to clipboard

Raise error when GRD file is corrupted

Open santisoler opened this issue 1 year ago • 4 comments

Description of the desired feature:

In case the GRD file that is intended to be read is corrupted and there are missing elements in the grid, our hm.load_oasis_montaj_grid function will fail, raising an error complaining about not being able to reshape the grid to the expected shape.

We could improve the user interface by checking if the number of elements in the read 1d array matches the expected shape and raise an error with an informative error message if it doesn't. It could be a ValueError with a message like:

f"Encountered grid with {n} elements that doesn't match the expected shape ({shape}). The '{filename}' file is possibly corrupted."

The idea for this new feature was triggered after a conversation with @marcoutojr

Are you willing to help implement and maintain this feature?

Yes, sure! Although I'd love to see someone else tackling this issue.

santisoler avatar Jan 18 '24 00:01 santisoler

Good catch! Nice to see @marcoutojr here 🥳

leouieda avatar Jan 18 '24 11:01 leouieda

Hi @santisoler , I’d be happy to tackle this—do you still needed !!

Nanakjoth avatar May 13 '25 12:05 Nanakjoth

Hi @Nanakjoth! Thanks for volunteering for it. Feel free to start a PR for this.

santisoler avatar May 13 '25 16:05 santisoler

Hi @santisoler I’ve just pushed this PR, Sorry for the delay I got caught up with another project and it slipped my mind for a bit.

This change is ready for review, I’ve kept it simple and tested it manually with a fake .grd file to confirm the new check works as expected.

Looking forward to your feedback/suggestion, happy to tweak anything if needed!

Nanakjoth avatar Jul 03 '25 12:07 Nanakjoth