gempy
gempy copied to clipboard
Error When Loading a Raster File
Dear all,
I've started working with Gempy a while ago. Thanks to the wonderful documentation, it all went well so far. But now I am facing troubles when loading a raster file. I've checked the issues here but I didn't 't find a solution yet and would like to ask for your help. Thank you in advance for your time.
Best regards,
Mike
Describe the bug I want to load the topography via a raster (GeoTiff) to build a 3D geological model. Unfortunately, I received both a runtime error and an import error.
To Reproduce
- So this is code responsible for the error:
fp = "C:/topography03.tif"
geo_model.set_topography(source='gdal', filepath=fp)
resulting in this error:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
RuntimeError: module compiled against API version 0xf but this version of numpy is 0xe
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Input In [8], in <cell line: 1>()
----> 1 geo_model.set_topography(source='gdal', filepath=fp)
File ~\miniconda3\envs\gempy_21\lib\site-packages\gempy\plot\decorators.py:108, in plot_set_topography.<locals>.pst(*args, **kwargs)
105 @wraps(func)
106 def pst(*args, **kwargs):
107 plot_object = kwargs.pop('plot_object') if 'plot_object' in kwargs else None
--> 108 topography = func(*args, **kwargs)
110 if plot_object is not None:
111 if isinstance(plot_object, GemPyToVista):
File ~\miniconda3\envs\gempy_21\lib\site-packages\gempy\core\model.py:428, in ImplicitCoKriging.set_topography(self, source, set_mask, **kwargs)
384 @plot_set_topography
385 def set_topography(self, source='random', set_mask=True, **kwargs):
386 """Create a topography grid and activate it.
387
388 Args:
(...)
425
426 """
--> 428 self._grid.create_topography(source, **kwargs)
429 if set_mask is True:
430 try:
File ~\miniconda3\envs\gempy_21\lib\site-packages\gempy\core\data.py:183, in Grid.create_topography(self, source, **kwargs)
181 filepath = kwargs.get('filepath', None)
182 if filepath is not None:
--> 183 self.topography.load_from_gdal(filepath)
184 else:
185 print('to load a raster file, a path to the file must be provided')
File ~\miniconda3\envs\gempy_21\lib\site-packages\gempy\core\grid_modules\topography.py:122, in Topography.load_from_gdal(self, filepath)
121 def load_from_gdal(self, filepath):
--> 122 dem = LoadDEMGDAL(filepath, extent=self.extent)
123 self._x, self._y = None, None
124 self.set_values(dem.get_values())
File ~\miniconda3\envs\gempy_21\lib\site-packages\gempy\core\grid_modules\create_topography.py:44, in LoadDEMGDAL.__init__(self, path_dem, grid, extent, delete_temp)
39 raise AttributeError('Raster file could not be opened {}. Check if the filepath is correct. If yes,'
40 'check if your file fits the requirements of GDALs raster file formats.'.format(
41 path_dem))
43 try:
---> 44 self.dem_zval = self.dem.ReadAsArray()
45 except AttributeError:
46 raise AttributeError('Filepath seems to be wrong.')
File ~\miniconda3\envs\gempy_21\lib\site-packages\osgeo\gdal.py:2337, in Dataset.ReadAsArray(self, xoff, yoff, xsize, ysize, buf_obj, buf_xsize, buf_ysize, buf_type, resample_alg, callback, callback_data, interleave, band_list)
2327 def ReadAsArray(self, xoff=0, yoff=0, xsize=None, ysize=None, buf_obj=None,
2328 buf_xsize=None, buf_ysize=None, buf_type=None,
2329 resample_alg=gdalconst.GRIORA_NearestNeighbour,
(...)
2332 interleave='band',
2333 band_list=None):
2334 """ Reading a chunk of a GDAL band into a numpy array. The optional (buf_xsize,buf_ysize,buf_type)
2335 parameters should generally not be specified if buf_obj is specified. The array is returned"""
-> 2337 from osgeo import gdal_array
2338 return gdal_array.DatasetReadAsArray(self, xoff, yoff, xsize, ysize, buf_obj,
2339 buf_xsize, buf_ysize, buf_type,
2340 resample_alg=resample_alg,
(...)
2343 interleave=interleave,
2344 band_list=band_list)
File ~\miniconda3\envs\gempy_21\lib\site-packages\osgeo\gdal_array.py:13, in <module>
11 # Import the low-level C/C++ module
12 if __package__ or "." in __name__:
---> 13 from . import _gdal_array
14 else:
15 import _gdal_array
ImportError: numpy.core.multiarray failed to import
-
I've figured out that fixing the first error would require me to update numpy to at 1.22.x (=API version 0xf). After updating numpy, pip returns an error stating that this version is incompatible (which it really is.) and recommending me to install version 1.21.6 (which is API version 0xe).
-
For the second error, I have no idea.
Desktop (please complete the following information):
- OS: Windows 10 (64 bit)
- GemPy Version: 2.2.12
- Jupyter Version: 6.4.12
Hi @marcogilberto
both errors seem to be related to numpy (and GDAL). I assume that there is a requirement conflict or some sort?
What are your versions of numpy, osgeo, gdal etc? Can you give a conda list
of your environment?
Hi @Japhiolite
thank you for getting back to me. Actually, I cloned my environment and downgraded gempy to 2.2.10. With this version, it's working smoothly now.
Here's the pip list: aiohttp 3.8.1 aiosignal 1.2.0 anyio 3.5.0 appdirs 1.4.4 argon2-cffi 21.3.0 argon2-cffi-bindings 21.2.0 asttokens 2.0.8 async-timeout 4.0.2 atomicwrites 1.4.1 attrs 22.1.0 Babel 2.9.1 backcall 0.2.0 beautifulsoup4 4.11.1 bleach 4.1.0 brotlipy 0.7.0 certifi 2022.6.15 cffi 1.15.1 charset-normalizer 2.1.1 colorama 0.4.5 cryptography 37.0.1 cycler 0.11.0 debugpy 1.5.1 decorator 5.1.1 defusedxml 0.7.1 entrypoints 0.4 executing 1.0.0 fastjsonschema 2.16.2 fonttools 4.37.1 frozenlist 1.3.1 GDAL 3.4.3 gempy 2.2.12 idna 3.3 imageio 2.21.2 importlib-resources 5.2.0 iniconfig 1.1.1 ipykernel 6.9.1 ipython 8.4.0 ipython-genutils 0.2.0 ipywidgets 7.6.5 jedi 0.18.1 Jinja2 3.0.3 json5 0.9.6 jsonschema 4.4.0 jupyter 1.0.0 jupyter_client 7.3.4 jupyter-console 6.4.3 jupyter-core 4.10.0 jupyter-server 1.18.1 jupyterlab 3.4.4 jupyterlab-pygments 0.1.2 jupyterlab-server 2.12.0 jupyterlab-widgets 1.0.0 kiwisolver 1.4.4 lasio 0.30 Mako 1.1.4 MarkupSafe 2.1.1 matplotlib 3.5.3 matplotlib-inline 0.1.6 mistune 0.8.4 mkl-fft 1.3.1 mkl-random 1.2.2 mkl-service 2.4.0 multidict 6.0.2 nbclassic 0.3.5 nbclient 0.5.13 nbconvert 6.4.4 nbformat 5.3.0 nest-asyncio 1.5.5 networkx 2.8.6 notebook 6.4.12 numpy 1.21.6 packaging 21.3 pandas 1.3.4 pandocfilters 1.5.0 parso 0.8.3 pickleshare 0.7.5 Pillow 9.2.0 pip 22.1.2 pluggy 1.0.0 ply 3.11 prometheus-client 0.14.1 prompt-toolkit 3.0.30 pure-eval 0.2.2 py 1.11.0 pycparser 2.21 Pygments 2.13.0 pygpu 0.7.6 pyOpenSSL 22.0.0 pyparsing 3.0.9 PyQt5 5.15.7 PyQt5-Qt5 5.15.2 PyQt5-sip 12.11.0 pyrsistent 0.18.0 PySocks 1.7.1 pytest 7.1.2 python-dateutil 2.8.2 pytz 2022.2.1 pyvista 0.36.1 pyvistaqt 0.9.0 PyWavelets 1.3.0 pywin32 302 pywinpty 2.0.2 pyzmq 23.2.0 qtconsole 5.3.2 QtPy 2.2.0 requests 2.28.1 scikit-image 0.19.3 scipy 1.9.1 scooby 0.6.0 seaborn 0.11.2 Send2Trash 1.8.0 setuptools 63.4.1 sip 6.6.2 six 1.16.0 sniffio 1.2.0 soupsieve 2.3.1 stack-data 0.5.0 striplog 0.9.2 subsurface 0.2.9 terminado 0.13.1 testpath 0.6.0 Theano 1.0.5 tifffile 2022.8.12 toml 0.10.2 tomli 2.0.1 tornado 6.1 tqdm 4.64.0 traitlets 5.3.0 typing_extensions 4.3.0 urllib3 1.26.11 vtk 9.2.0rc2 wcwidth 0.2.5 webencodings 0.5.1 websocket-client 0.58.0 wellpathpy 0.5.0 welly 0.5.2 wheel 0.37.1 widgetsnbextension 3.5.2 win-inet-pton 1.1.0 wincertstore 0.2 wslink 1.8.2 xarray 2022.3.0 yarl 1.8.1 zipp 3.8.0
And conda list: Name Version Build Channel aiohttp 3.8.1 pypi_0 pypi aiosignal 1.2.0 pypi_0 pypi anyio 3.5.0 py38haa95532_0 appdirs 1.4.4 pypi_0 pypi argon2-cffi 21.3.0 pyhd3eb1b0_0 argon2-cffi-bindings 21.2.0 py38h2bbff1b_0 asttokens 2.0.8 pypi_0 pypi async-timeout 4.0.2 pypi_0 pypi atomicwrites 1.4.1 pypi_0 pypi attrs 22.1.0 pypi_0 pypi babel 2.9.1 pyhd3eb1b0_0 backcall 0.2.0 pyhd3eb1b0_0 beautifulsoup4 4.11.1 py38haa95532_0 blas 1.0 mkl bleach 4.1.0 pyhd3eb1b0_0 brotlipy 0.7.0 py38h2bbff1b_1003 bzip2 1.0.8 he774522_0 ca-certificates 2022.07.19 haa95532_0 certifi 2022.6.15 py38haa95532_0 cffi 1.15.1 py38h2bbff1b_0 cfitsio 3.470 h2bbff1b_7 charset-normalizer 2.1.1 pypi_0 pypi colorama 0.4.5 py38haa95532_0 cryptography 37.0.1 py38h21b164f_0 curl 7.84.0 h2bbff1b_0 cycler 0.11.0 pypi_0 pypi debugpy 1.5.1 py38hd77b12b_0 decorator 5.1.1 pyhd3eb1b0_0 defusedxml 0.7.1 pyhd3eb1b0_0 entrypoints 0.4 py38haa95532_0 executing 1.0.0 pypi_0 pypi expat 2.4.4 h6c2663c_0 fftw 3.3.9 h2bbff1b_1 fonttools 4.37.1 pypi_0 pypi freexl 1.0.6 h2bbff1b_0 frozenlist 1.3.1 pypi_0 pypi gdal 3.4.3 pypi_0 pypi gempy 2.2.12 pypi_0 pypi geos 3.8.0 h33f27b4_0 geotiff 1.7.0 h4545760_0 glib 2.69.1 h5dc1a3c_1 gst-plugins-base 1.18.5 h9e645db_0 gstreamer 1.18.5 hd78058f_0 hdf4 4.2.13 h712560f_2 hdf5 1.10.6 h1756f20_1 icc_rt 2019.0.0 h0cc432a_1 icu 58.2 ha925a31_3 idna 3.3 pyhd3eb1b0_0 imageio 2.21.2 pypi_0 pypi importlib_resources 5.2.0 pyhd3eb1b0_1 iniconfig 1.1.1 pypi_0 pypi intel-openmp 2021.4.0 haa95532_3556 ipykernel 6.9.1 py38haa95532_0 ipython 8.4.0 py38haa95532_0 ipython_genutils 0.2.0 pyhd3eb1b0_1 ipywidgets 7.6.5 pyhd3eb1b0_1 jedi 0.18.1 py38haa95532_1 jinja2 3.0.3 pyhd3eb1b0_0 jpeg 9e h2bbff1b_0 json5 0.9.6 pyhd3eb1b0_0 jsonschema 4.4.0 py38haa95532_0 jupyter 1.0.0 py38haa95532_8 jupyter_client 7.3.4 py38haa95532_0 jupyter_console 6.4.3 pyhd3eb1b0_0 jupyter_core 4.10.0 py38haa95532_0 jupyter_server 1.18.1 py38haa95532_0 jupyterlab 3.4.4 py38haa95532_0 jupyterlab_pygments 0.1.2 py_0 jupyterlab_server 2.12.0 py38haa95532_0 jupyterlab_widgets 1.0.0 pyhd3eb1b0_1 kealib 1.4.14 hde4a422_1 kiwisolver 1.4.4 pypi_0 pypi lasio 0.30 pypi_0 pypi lerc 3.0 hd77b12b_0 libclang 12.0.0 default_h627e005_2 libcurl 7.84.0 h86230a5_0 libdeflate 1.8 h2bbff1b_5 libffi 3.4.2 hd77b12b_4 libgdal 3.4.1 h9b24a9a_2 libgpuarray 0.7.6 h2bbff1b_1 libiconv 1.16 h2bbff1b_2 libnetcdf 4.8.1 h6685c40_1 libogg 1.3.5 h2bbff1b_1 libpng 1.6.37 h2a8f88b_0 libpq 12.9 hb652d5d_3 libpython 2.1 py38_0 libsodium 1.0.18 h62dcd97_0 libspatialite 4.3.0a h14feca5_20 libssh2 1.10.0 hcd4344a_0 libtiff 4.4.0 h8a3f274_0 libvorbis 1.3.7 he774522_0 libwebp 1.2.2 h2bbff1b_0 libxml2 2.9.14 h0ad7f3c_0 libxslt 1.1.35 h2bbff1b_0 libzip 1.8.0 h49b8836_0 lz4-c 1.9.3 h2bbff1b_1 m2w64-binutils 2.25.1 5 m2w64-bzip2 1.0.6 6 m2w64-crt-git 5.0.0.4636.2595836 2 m2w64-expat 2.1.1 2 m2w64-gcc 5.3.0 6 m2w64-gcc-ada 5.3.0 6 m2w64-gcc-fortran 5.3.0 6 m2w64-gcc-libgfortran 5.3.0 6 m2w64-gcc-libs 5.3.0 7 m2w64-gcc-libs-core 5.3.0 7 m2w64-gcc-objc 5.3.0 6 m2w64-gettext 0.19.7 2 m2w64-gmp 6.1.0 2 m2w64-headers-git 5.0.0.4636.c0ad18a 2 m2w64-isl 0.16.1 2 m2w64-libiconv 1.14 6 m2w64-libmangle-git 5.0.0.4509.2e5a9a2 2 m2w64-libwinpthread-git 5.0.0.4634.697f757 2 m2w64-make 4.1.2351.a80a8b8 2 m2w64-mpc 1.0.3 3 m2w64-mpfr 3.1.4 4 m2w64-pkg-config 0.29.1 2 m2w64-toolchain 5.3.0 7 m2w64-tools-git 5.0.0.4592.90b8472 2 m2w64-windows-default-manifest 6.4 3 m2w64-winpthreads-git 5.0.0.4634.697f757 2 m2w64-xz 5.2.2 2 m2w64-zlib 1.2.8 10 mako 1.1.4 pyhd3eb1b0_0 markupsafe 2.1.1 py38h2bbff1b_0 matplotlib 3.5.3 pypi_0 pypi matplotlib-inline 0.1.6 py38haa95532_0 mistune 0.8.4 py38he774522_1000 mkl 2021.4.0 haa95532_640 mkl-service 2.4.0 py38h2bbff1b_0 mkl_fft 1.3.1 py38h277e83a_0 mkl_random 1.2.2 py38hf11a4ad_0 msys2-conda-epoch 20160418 1 multidict 6.0.2 pypi_0 pypi nbclassic 0.3.5 pyhd3eb1b0_0 nbclient 0.5.13 py38haa95532_0 nbconvert 6.4.4 py38haa95532_0 nbformat 5.3.0 py38haa95532_0 nest-asyncio 1.5.5 py38haa95532_0 networkx 2.8.6 pypi_0 pypi notebook 6.4.12 py38haa95532_0 numpy 1.21.6 pypi_0 pypi openjpeg 2.4.0 h4fc8c34_0 openssl 1.1.1q h2bbff1b_0 packaging 21.3 pyhd3eb1b0_0 pandas 1.3.4 pypi_0 pypi pandocfilters 1.5.0 pyhd3eb1b0_0 parso 0.8.3 pyhd3eb1b0_0 pcre 8.45 hd77b12b_0 pickleshare 0.7.5 pyhd3eb1b0_1003 pillow 9.2.0 pypi_0 pypi pip 22.1.2 py38haa95532_0 pluggy 1.0.0 pypi_0 pypi ply 3.11 py38_0 proj 6.2.1 h3758d61_0 prometheus_client 0.14.1 py38haa95532_0 prompt-toolkit 3.0.30 pypi_0 pypi prompt_toolkit 3.0.20 hd3eb1b0_0 pure_eval 0.2.2 pyhd3eb1b0_0 py 1.11.0 pypi_0 pypi pycparser 2.21 pyhd3eb1b0_0 pygments 2.13.0 pypi_0 pypi pygpu 0.7.6 py38h080aedc_1 pyopenssl 22.0.0 pyhd3eb1b0_0 pyparsing 3.0.9 py38haa95532_0 pyqt 5.15.7 py38hd77b12b_0 pyqt5-qt5 5.15.2 pypi_0 pypi pyqt5-sip 12.11.0 py38hd77b12b_0 pyrsistent 0.18.0 py38h196d8e1_0 pysocks 1.7.1 py38haa95532_0 pytest 7.1.2 pypi_0 pypi python 3.8.5 h5fd99cc_1 python-dateutil 2.8.2 pyhd3eb1b0_0 python-fastjsonschema 2.16.2 py38haa95532_0 pytz 2022.2.1 pypi_0 pypi pyvista 0.36.1 pypi_0 pypi pyvistaqt 0.9.0 pypi_0 pypi pywavelets 1.3.0 pypi_0 pypi pywin32 302 py38h2bbff1b_2 pywinpty 2.0.2 py38h5da7b33_0 pyzmq 23.2.0 py38hd77b12b_0 qt-main 5.15.2 he8e5bd7_7 qt-webengine 5.15.9 hb9a9bb5_4 qtconsole 5.3.2 py38haa95532_0 qtpy 2.2.0 py38haa95532_0 qtwebkit 5.212 h3ad3cdb_4 requests 2.28.1 py38haa95532_0 scikit-image 0.19.3 pypi_0 pypi scipy 1.9.1 pypi_0 pypi scooby 0.6.0 pypi_0 pypi seaborn 0.11.2 pypi_0 pypi send2trash 1.8.0 pyhd3eb1b0_1 setuptools 63.4.1 py38haa95532_0 sip 6.6.2 py38hd77b12b_0 six 1.16.0 pyhd3eb1b0_1 sniffio 1.2.0 py38haa95532_1 soupsieve 2.3.1 pyhd3eb1b0_0 sqlite 3.39.2 h2bbff1b_0 stack-data 0.5.0 pypi_0 pypi stack_data 0.2.0 pyhd3eb1b0_0 striplog 0.9.2 pypi_0 pypi subsurface 0.2.9 pypi_0 pypi terminado 0.13.1 py38haa95532_0 testpath 0.6.0 py38haa95532_0 theano 1.0.5 pypi_0 pypi tifffile 2022.8.12 pypi_0 pypi tiledb 2.3.3 h3649cd2_2 toml 0.10.2 pyhd3eb1b0_0 tomli 2.0.1 pypi_0 pypi tornado 6.1 py38h2bbff1b_0 tqdm 4.64.0 pypi_0 pypi traitlets 5.3.0 pypi_0 pypi typing-extensions 4.3.0 py38haa95532_0 typing_extensions 4.3.0 py38haa95532_0 urllib3 1.26.11 py38haa95532_0 vc 14.2 h21ff451_1 vs2015_runtime 14.27.29016 h5e58377_2 vtk 9.2.0rc2 pypi_0 pypi wcwidth 0.2.5 pyhd3eb1b0_0 webencodings 0.5.1 py38_1 websocket-client 0.58.0 py38haa95532_4 wellpathpy 0.5.0 pypi_0 pypi welly 0.5.2 pypi_0 pypi wheel 0.37.1 pyhd3eb1b0_0 widgetsnbextension 3.5.2 py38haa95532_0 win_inet_pton 1.1.0 py38haa95532_0 wincertstore 0.2 py38haa95532_2 winpty 0.4.3 4 wslink 1.8.2 pypi_0 pypi xarray 2022.3.0 pypi_0 pypi xerces-c 3.2.3 ha925a31_0 xz 5.2.5 h8cc25b3_1 yarl 1.8.1 pypi_0 pypi zeromq 4.3.4 hd77b12b_0 zipp 3.8.0 py38haa95532_0 zlib 1.2.12 h8cc25b3_2 zstd 1.5.2 h19a0ad4_0
Good to know, I'll look into it, whether that may be a bug with 2.2.12
@Japhiolite, did you get a chance to check the issue out?
No, not yet
GemPy 2.3 has been released and the issue should have been solved now! Please reopen if you still have issues with the installation.
See https://github.com/cgre-aachen/gempy/releases/tag/v2.3.0 for more information