Skip to content

PyGMT load_earth_relief breaks with xarray 0.18.0 (ValueError: cannot guess the engine) #1262

@seisman

Description

@seisman

Description of the problem

xarray 0.18.0 was released on May 6, 2021, and some PyGMT tests break. I'm not sure if it's a bug or a breaking change of xarray.

Full code that generated the error

After upgrading to xarray 0.18.0, following codes no longer work:

import pygmt
pygmt.datasets.load_earth_relief("01d")

Full error message

ValueError                                Traceback (most recent call last)
<ipython-input-2-30e5a4024c6c> in <module>
----> 1 pygmt.datasets.load_earth_relief("01d")

pygmt/pygmt/helpers/decorators.py in new_module(*args, **kwargs)
    436                         kwargs[arg] = separators[fmt].join(f"{item}" for item in value)
    437             # Execute the original function and return its output
--> 438             return module_func(*args, **kwargs)
    439
    440         return new_module

pygmt/pygmt/datasets/earth_relief.py in load_earth_relief(resolution, region, registration, use_srtm)
    134             )
    135         fname = which(f"@earth_relief_{resolution}{reg}", download="a")
--> 136         with xr.open_dataarray(fname) as dataarray:
    137             grid = dataarray.load()
    138             _ = grid.gmt  # load GMTDataArray accessor information

~/.miniconda/envs/pygmt/lib/python3.9/site-packages/xarray/backends/api.py in open_dataarray(filename_or_obj, engine, chunks, cache, decode_cf, mask_and_scale, decode_times, decode_timedelta, use_cftime, concat_characters, decode_coords, drop_variables, backend_kwargs, *args, **kwargs)
    657         )
    658
--> 659     dataset = open_dataset(
    660         filename_or_obj,
    661         decode_cf=decode_cf,

~/.miniconda/envs/pygmt/lib/python3.9/site-packages/xarray/backends/api.py in open_dataset(filename_or_obj, engine, chunks, cache, decode_cf, mask_and_scale, decode_times, decode_timedelta, use_cftime, concat_characters, decode_coords, drop_variables, backend_kwargs, *args, **kwargs)
    483
    484     if engine is None:
--> 485         engine = plugins.guess_engine(filename_or_obj)
    486
    487     backend = plugins.get_backend(engine)

~/.miniconda/envs/pygmt/lib/python3.9/site-packages/xarray/backends/plugins.py in guess_engine(store_spec)
    110             warnings.warn(f"{engine!r} fails while guessing", RuntimeWarning)
    111
--> 112     raise ValueError("cannot guess the engine, try passing one explicitly")
    113
    114

ValueError: cannot guess the engine, try passing one explicitly

System information

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

PyGMT information:
  version: v0.3.2.dev82+g82ebbbc4.d20210412
System information:
  python: 3.9.2 | packaged by conda-forge | (default, Feb 21 2021, 05:02:20)  [Clang 11.0.1 ]
  executable: ~/.miniconda/envs/pygmt/bin/python
  machine: macOS-11.2.3-x86_64-i386-64bit
Dependency information:
  numpy: 1.20.1
  pandas: 1.2.3
  xarray: 0.18.0
  netCDF4: 1.5.6
  packaging: 20.9
  ghostscript: 9.53.3
  gmt: 6.1.1

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions