GenericMappingTools / pygmt

A Python interface for the Generic Mapping Tools.
https://www.pygmt.org
BSD 3-Clause "New" or "Revised" License
747 stars 216 forks source link

Error while using the DEM.grd as a numpy variable #717

Closed vivigb closed 3 years ago

vivigb commented 3 years ago

Description of the problem

import pygmt
region=[77, 79, 29.5, 30.5]
fig= pygmt.Figure()
ctopo=pygmt.makecpt(cmap="himalaya.cpt")
grid = pygmt.datasets.load_earth_relief(resolution='01s', region=region)
KWARGS = dict(grid=grid,region=region, projection='M4i',frame=True, E=300)
fig.grdimage(**KWARGS,cmap=ctopo,shading=True)
fig.show()

Giving me the following error

Traceback (most recent call last):
  File "<ipython-input-11-78e4c4e19ed9>", line 1, in <module>
    fig.grdimage(**KWARGS,cmap=ctopo,shading=True)
  File "C:\ProgramData\Anaconda3\envs\roses\lib\site-packages\pygmt\helpers\decorators.py", line 270, in new_module
    return module_func(*args, **kwargs)
  File "C:\ProgramData\Anaconda3\envs\roses\lib\site-packages\pygmt\helpers\decorators.py", line 411, in new_module
    return module_func(*args, **kwargs)
  File "C:\ProgramData\Anaconda3\envs\roses\lib\site-packages\pygmt\base_plotting.py", line 485, in grdimage
    lib.call_module("grdimage", arg_str)
  File "C:\ProgramData\Anaconda3\envs\roses\lib\site-packages\pygmt\clib\session.py", line 503, in call_module
    self.session_pointer, module.encode(), mode, args.encode()
OSError: exception: access violation reading 0x000001E880146FBC

I am using conda environment in Windows

PyGMT information:
  version: v0.2.1
System information:
  python: 3.7.8 | packaged by conda-forge | (default, Nov 17 2020, 23:02:53) [MSC v.1916 64 bit (AMD64)]
  executable: C:\ProgramData\Anaconda3\envs\roses\python.exe
  machine: Windows-10-10.0.19041-SP0
Dependency information:
  numpy: 1.19.4
  pandas: 1.1.4
  xarray: 0.16.1
  netCDF4: 1.5.4
  packaging: 20.4
  ghostscript: 9.53.3
  gmt: 6.1.1
GMT library information:
  binary dir: C:/ProgramData/Anaconda3/envs/roses
  cores: 4
  grid layout: rows
  library path: C:/ProgramData/Anaconda3/envs/roses/Library/bin/gmt.dll
  padding: 2
  plugin dir: C:/ProgramData/Anaconda3/envs/roses/Library/bin/gmt_plugins
  share dir: c:/programs/gmt5/share
  version: 6.1.1
welcome[bot] commented 3 years ago

👋 Thanks for opening your first issue here! Please make sure you filled out the template with as much detail as possible. You might also want to take a look at our contributing guidelines and code of conduct.

seisman commented 3 years ago

Yes, we notice similar crashes in our CI testings. It's still unclear to us why and where it happens, as none of us is developing PyGMT under Windows.

You have two options:

  1. Re-run the script again. Sometimes it crashes, but sometimes it works well
  2. Directly use the GMT remote file, i.e., KWARGS = dict(grid="@earth_relief_01s",region=region, projection='M4i',frame=True, E=300), instead of using the pygmt.datasets.load_earth_relief, which loads the grid into memory.
seisman commented 3 years ago

I'd like to close the issue, because:

  1. We already know that PyGMT sometimes crashes on Windows
  2. We don't have any Windows developers to track the crashes
  3. There are most likely issues of GMT, not PyGMT.