You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The surface gridding function doesn't allow passing in a python list to region (e.g. [245, 255, 20, 30]). This is actually an oversight on my part since I wrapped the function in #245 😨.
Full code that generated the error adapted from tests_surface.py
-R<xmin>/<xmax>/<ymin>/<ymax>[/<zmin>/<zmax>]
Append r if giving lower left and upper right coordinates
-Rg or -Rd for global domain
-R<grdfile> to take the domain from a grid file
surface [ERROR]: Offending option -R245
surface [ERROR]: Option -R given more than once
surface [ERROR]: Syntax error -R option. Correct syntax:
-R<xmin>/<xmax>/<ymin>/<ymax>[/<zmin>/<zmax>]
Append r if giving lower left and upper right coordinates
-Rg or -Rd for global domain
-R<grdfile> to take the domain from a grid file
surface [ERROR]: Offending option -R255
surface [ERROR]: Option -R given more than once
surface [ERROR]: Syntax error -R option. Correct syntax:
-R<xmin>/<xmax>/<ymin>/<ymax>[/<zmin>/<zmax>]
Append r if giving lower left and upper right coordinates
-Rg or -Rd for global domain
-R<grdfile> to take the domain from a grid file
surface [ERROR]: Offending option -R20
surface [ERROR]: Option -R given more than once
surface [ERROR]: Syntax error -R option. Correct syntax:
-R<xmin>/<xmax>/<ymin>/<ymax>[/<zmin>/<zmax>]
Append r if giving lower left and upper right coordinates
-Rg or -Rd for global domain
-R<grdfile> to take the domain from a grid file
surface [ERROR]: Offending option -R30
---------------------------------------------------------------------------
GMTCLibError Traceback (most recent call last)
<ipython-input-6-918159e76c71> in <module>
----> 1 pygmt.surface(data=data, spacing="5m", region=[245, 255, 20, 30])
~/miniconda/envs/pygmt/pygmt/helpers/decorators.py in new_module(*args, **kwargs)
181 if alias in kwargs:
182 kwargs[arg] = kwargs.pop(alias)
--> 183 return module_func(*args, **kwargs)
184
185 new_module.aliases = aliases
~/miniconda/envs/pygmt/pygmt/gridding.py in surface(x, y, z, data, **kwargs)
83 outfile = kwargs["G"]
84 arg_str = " ".join([infile, build_arg_string(kwargs)])
---> 85 lib.call_module(module="surface", args=arg_str)
86
87 if outfile == tmpfile.name: # if user did not set outfile, return DataArray
~/miniconda/envs/pygmt/pygmt/clib/session.py in call_module(self, module, args)
488 raise GMTCLibError(
489 "Module '{}' failed with status code {}:\n{}".format(
--> 490 module, status, self._error_message
491 )
492 )
GMTCLibError: Module 'surface' failed with status code 71:
surface [ERROR]: Syntax error -R option. Correct syntax:
surface [ERROR]: Offending option -R245
surface [ERROR]: Option -R given more than once
surface [ERROR]: Syntax error -R option. Correct syntax:
surface [ERROR]: Offending option -R255
surface [ERROR]: Option -R given more than once
surface [ERROR]: Syntax error -R option. Correct syntax:
surface [ERROR]: Offending option -R20
surface [ERROR]: Option -R given more than once
surface [ERROR]: Syntax error -R option. Correct syntax:
surface [ERROR]: Offending option -R30
Solution
This will be a relatively straightforward fix, and I'd be happy for someone new-ish wanting to contribute to PyGMT to submit a Pull Request (and learn from it). We can guide you through the process on how to add a Python decorator to fix the issue, and update the unit tests so that the problem won't surface 😉 again in the future.
Before you start, read up on our CONTRIBUTING.md. Also, please leave a comment below if you decide to start working on this!!
Anyhow, first part is to add a python decorator @kwargs_to_strings(R="sequence") after @use_alias and before def surface here:
Make sure that you add a line to import kwargs_to_string near the top of gridding.py file, or it won't work!
What the decorator does is to convert a list like [245, 255, 20, 30] into a slash separated string like "245/255/20/30", the code for it which is found at here.
Description of the problem
The
surface
gridding function doesn't allow passing in a python list toregion
(e.g.[245, 255, 20, 30]
). This is actually an oversight on my part since I wrapped the function in #245 😨.Full code that generated the error adapted from tests_surface.py
Full error message
Solution
This will be a relatively straightforward fix, and I'd be happy for someone new-ish wanting to contribute to PyGMT to submit a Pull Request (and learn from it). We can guide you through the process on how to add a Python decorator to fix the issue, and update the unit tests so that the problem won't surface 😉 again in the future.
Before you start, read up on our CONTRIBUTING.md. Also, please leave a comment below if you decide to start working on this!!
Anyhow, first part is to add a python decorator
@kwargs_to_strings(R="sequence")
after@use_alias
and beforedef surface
here:pygmt/pygmt/gridding.py
Lines 18 to 20 in cdcdf70
Make sure that you add a line to import
kwargs_to_string
near the top ofgridding.py
file, or it won't work!What the decorator does is to convert a list like
[245, 255, 20, 30]
into a slash separated string like"245/255/20/30"
, the code for it which is found at here.Secondly, you'll need to edit the unit test file to capture this change at https://github.com/GenericMappingTools/pygmt/edit/master/pygmt/tests/test_surface.py. Change all the lines mentioning
region="245/255/20/30"
toregion=[245, 255, 20, 30]
.That should be the bulk of it! Feel free to ask for help in the comments below if you encounter any issues, and good luck!
System information
conda list
below:output of conda list
The text was updated successfully, but these errors were encountered: