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

pygmt.datasets.load_earth_relief region keyword #656

Closed uliw closed 3 years ago

uliw commented 3 years ago

Description of the problem

Line 1 in the example below will work, line 2 will not. I also tried to include R or -R. What is the correct way of specifying the region?

Full code that generated the error

grid = gmt.datasets.load_earth_relief(resolution="05m",region="g")
grid = gmt.datasets.load_earth_relief(resolution="05m",region="-180/180/90/-90")

Full error message

GMTCLibErrorTraceback (most recent call last)
<ipython-input-2-c3f4b1e9fae7> in <module>
     14 
     15 #grid = gmt.datasets.load_earth_relief(resolution="05m",region="g")
---> 16 grid = gmt.datasets.load_earth_relief(resolution=r,region="-180/180/90/-90")
     17 # grid = gmt.datasets.load_earth_relief(resolution="01d")
     18 

~/anaconda3/envs/mygmt/lib/python3.8/site-packages/pygmt/helpers/decorators.py in new_module(*args, **kwargs)
    372                         kwargs[arg] = separators[fmt].join(f"{item}" for item in value)
    373             # Execute the original function and return its output
--> 374             return module_func(*args, **kwargs)
    375 
    376         return new_module

~/anaconda3/envs/mygmt/lib/python3.8/site-packages/pygmt/datasets/earth_relief.py in load_earth_relief(resolution, region, registration)
    101                 f"'region' is required for Earth relief resolution '{resolution}'"
    102             )
--> 103         grid = grdcut(f"@earth_relief_{resolution}{reg}", region=region)
    104     else:
    105         raise GMTInvalidInput(f'Invalid Earth relief resolution "{resolution}"')

~/anaconda3/envs/mygmt/lib/python3.8/site-packages/pygmt/helpers/decorators.py in new_module(*args, **kwargs)
    235                 if alias in kwargs:
    236                     kwargs[arg] = kwargs.pop(alias)
--> 237             return module_func(*args, **kwargs)
    238 
    239         new_module.aliases = aliases

~/anaconda3/envs/mygmt/lib/python3.8/site-packages/pygmt/helpers/decorators.py in new_module(*args, **kwargs)
    372                         kwargs[arg] = separators[fmt].join(f"{item}" for item in value)
    373             # Execute the original function and return its output
--> 374             return module_func(*args, **kwargs)
    375 
    376         return new_module

~/anaconda3/envs/mygmt/lib/python3.8/site-packages/pygmt/gridops.py in grdcut(grid, **kwargs)
    104                 outgrid = kwargs["G"]
    105                 arg_str = " ".join([infile, build_arg_string(kwargs)])
--> 106                 lib.call_module("grdcut", arg_str)
    107 
    108         if outgrid == tmpfile.name:  # if user did not set outgrid, return DataArray

~/anaconda3/envs/mygmt/lib/python3.8/site-packages/pygmt/clib/session.py in call_module(self, module, args)
    500         )
    501         if status != 0:
--> 502             raise GMTCLibError(
    503                 "Module '{}' failed with status code {}:\n{}".format(
    504                     module, status, self._error_message

GMTCLibError: Module 'grdcut' failed with status code 71:
grdcut [ERROR]: Option -R parsing failure. Correct syntax:
grdcut [ERROR]: Offending option -R-180/180/90/-90

System information

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

PyGMT information:
  version: v0.2.0
System information:
  python: 3.8.6 | packaged by conda-forge | (default, Oct  7 2020, 19:08:05)  [GCC 7.5.0]
  executable: /home/uliw/anaconda3/envs/mygmt/bin/python
  machine: Linux-5.6.14-1-default-x86_64-with-glibc2.10
Dependency information:
  numpy: 1.18.5
  pandas: 1.0.5
  xarray: 0.15.1
  netCDF4: 1.5.3
  packaging: 20.4
  ghostscript: 9.53.3
  gmt: 6.1.1
GMT library information:
  binary dir: /home/uliw/anaconda3/envs/mygmt/bin
  cores: 8
  grid layout: rows
  library path: /home/uliw/anaconda3/envs/mygmt/lib/libgmt.so
  padding: 2
  plugin dir: /home/uliw/anaconda3/envs/mygmt/lib/gmt/plugins
  share dir: /home/uliw/anaconda3/envs/mygmt/share/gmt
  version: 6.1.1
seisman commented 3 years ago

It should be -R-180/180/-90/90, not -R-180/180/90/-90.

region should be given by xmin/xmax/ymin/ymax.

uliw commented 3 years ago

argh! The following works as expected

grid =
gmt.datasets.load_earth_relief(resolution="05m",region="-180/180/-90/90")

Thanks again

On Mon, Oct 19, 2020 at 11:44 AM Dongdong Tian notifications@github.com wrote:

It should be -R-180/180/-90/90, not -R-180/180/90/-90.

region should be given by xmin/xmax/ymin/ymax.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/GenericMappingTools/pygmt/issues/656#issuecomment-712255594, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWSVATEBR7BO5DUXS2IPSDSLRNF7ANCNFSM4SWJUM6Q .

-- Ulrich G. Wortmann https://www.es.utoronto.ca/people/faculty/wortmann-ulrich/ Dept. of Earth Sciences Fax : 416 978 3938 University of Toronto Phone: 416 978 7084 22 Ursula Franklin Street, Toronto, ON, Canada M5S 3B1