GenericMappingTools / pygmt

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

Problems running examples from the user guide #1534

Closed labrosse closed 3 years ago

labrosse commented 3 years ago

Description of the problem

I am having troubles running examples from the user guide that are using pygmt.datasets.load_earth_relief. I get two types of errors:

I don't know if the problem comes from my install.

Full code that generated the error

import pygmt

subset_region = [-14, 30, 35, 60]
grid_subset = pygmt.datasets.load_earth_relief(resolution="01m", region=subset_region)

fig = pygmt.Figure()

pygmt.makecpt(cmap="globe", series=[-6000, 3000])
fig.grdimage(grid=grid_subset, projection="M?", region=subset_region, frame=True)
fig.colorbar(frame=["a2000f1000", "x+lElevation", "y+lm"])

fig.savefig('map.pdf')

Full error message resolution="10m"

Traceback (most recent call last):
  File "topo_hawaii.py", line 4, in <module>
    grid_subset = pygmt.datasets.load_earth_relief(resolution="10m", region=subset_region)
  File "/Users/stephane/opt/anaconda3/envs/pygmt/lib/python3.8/site-packages/pygmt/helpers/decorators.py", line 411, in new_module
    return module_func(*args, **kwargs)
  File "/Users/stephane/opt/anaconda3/envs/pygmt/lib/python3.8/site-packages/pygmt/datasets/earth_relief.py", line 89, in load_earth_relief
    raise NotImplementedError(
NotImplementedError: 'region' is not supported for Earth relief resolution '10m'

With resolution="01m"

grdblend [NOTICE]: Remote data courtesy of GMT data server OCEANIA [https://oceania.generic-mapping-tools.org]
grdblend [NOTICE]: Earth Relief at 1x1 arc minutes from Gaussian Cartesian filtering (1.9 km fullwidth) of SRTM15+V2.1 [Tozer et al., 2019].
grdblend [NOTICE]:   -> Download 30x30 degree grid tile (earth_relief_01m_p): N30W030
[Session pygmt-session (1)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)
[Session pygmt-session (1)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)
[Session pygmt-session (1)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)
[Session pygmt-session (1)]: Error returned from GMT API: GMT_FILE_NOT_FOUND (16)
[Session pygmt-session (1)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)
[Session pygmt-session (1)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)
Traceback (most recent call last):
  File "topo_hawaii.py", line 4, in <module>
    grid_subset = pygmt.datasets.load_earth_relief(resolution="01m", region=subset_region)
  File "/Users/stephane/opt/anaconda3/envs/pygmt/lib/python3.8/site-packages/pygmt/helpers/decorators.py", line 411, in new_module
    return module_func(*args, **kwargs)
  File "/Users/stephane/opt/anaconda3/envs/pygmt/lib/python3.8/site-packages/pygmt/datasets/earth_relief.py", line 103, in load_earth_relief
    grid = grdcut(f"@earth_relief_{resolution}{reg}", region=region)
  File "/Users/stephane/opt/anaconda3/envs/pygmt/lib/python3.8/site-packages/pygmt/helpers/decorators.py", line 270, in new_module
    return module_func(*args, **kwargs)
  File "/Users/stephane/opt/anaconda3/envs/pygmt/lib/python3.8/site-packages/pygmt/helpers/decorators.py", line 411, in new_module
    return module_func(*args, **kwargs)
  File "/Users/stephane/opt/anaconda3/envs/pygmt/lib/python3.8/site-packages/pygmt/gridops.py", line 112, in grdcut
    with xr.open_dataarray(outgrid) as dataarray:
  File "/Users/stephane/opt/anaconda3/envs/pygmt/lib/python3.8/site-packages/xarray/backends/api.py", line 654, in open_dataarray
    dataset = open_dataset(
  File "/Users/stephane/opt/anaconda3/envs/pygmt/lib/python3.8/site-packages/xarray/backends/api.py", line 481, in open_dataset
    engine = plugins.guess_engine(filename_or_obj)
  File "/Users/stephane/opt/anaconda3/envs/pygmt/lib/python3.8/site-packages/xarray/backends/plugins.py", line 148, in guess_engine
    raise ValueError(error_msg)
ValueError: did not find a match in any of xarray's currently installed IO backends ['netcdf4', 'scipy']. Consider explicitly selecting one of the installed engines via the ``engine`` parameter, or installing additional IO dependencies, see:
http://xarray.pydata.org/en/stable/getting-started-guide/installing.html
http://xarray.pydata.org/en/stable/user-guide/io.html

System information

Please paste the output of python -c "import pygmt; pygmt.show_versions()":

PyGMT information:
  version: v0.2.1
System information:
  python: 3.8.6 | packaged by conda-forge | (default, Nov 27 2020, 19:17:44)  [Clang 11.0.0 ]
  executable: /Users/stephane/opt/anaconda3/envs/pygmt/bin/python
  machine: macOS-10.16-x86_64-i386-64bit
Dependency information:
  numpy: 1.19.4
  pandas: 1.1.5
  xarray: 0.19.0
  netCDF4: 1.5.5
  packaging: 20.7
  ghostscript: 9.54.0
  gmt: 6.1.1
GMT library information:
  binary dir: /Users/stephane/opt/anaconda3/envs/pygmt/bin
  cores: 16
  grid layout: rows
  library path: /Users/stephane/opt/anaconda3/envs/pygmt/lib/libgmt.dylib
  padding: 2
  plugin dir: /Users/stephane/opt/anaconda3/envs/pygmt/lib/gmt/plugins
  share dir: /Users/stephane/opt/anaconda3/envs/pygmt/share/gmt
  version: 6.1.1
seisman commented 3 years ago

@labrosse Your PyGMT version is too old. v0.2.1 was released on Nov. 14, 2020, and there are a lot of new features, enhancements, and fixes since that release (see https://www.pygmt.org/dev/changes.html for all changes for each release).

The latest stable release is v0.4.1 on Aug. 7, 2021. I recommend you upgrade your PyGMT to the latest to access new features.

labrosse commented 3 years ago

Thanks a lot, it works. Oddly enough, when I tried conda update pygmt, it said it was satisfied with what was installed. I had to do a fresh install of conda to get the proper version. I guess my previous install was not quite correct. Everything works fine now!

maxrjones commented 3 years ago

Thanks a lot, it works. Oddly enough, when I tried conda update pygmt, it said it was satisfied with what was installed. I had to do a fresh install of conda to get the proper version. I guess my previous install was not quite correct. Everything works fine now!

Good to hear everything's working now!