GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||
GeezerVison is showing github.com — Wrap makecpt by weiji14 · Pull Request #329 · GenericMappingTools/pygmt Conversation
|
|
Hi @weiji14, it would be nice if we had more coordination with the Julia wrapper. Specially in what regards the keyword names. For example, looking at your example I believe you named the option -T |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Funny you said that, I did think of using ‘range’ at one point (might have looked at your Julia implementation actually) but unfortunately that’s a reserved function in Python so had to come up with another name. Other than that though, I do agree that we should keep things consistent across implementations. Might be good to track this upstream, perhaps at GenericMappingTools/gmt#230? That way we don’t keep reinventing the wheel/aliases each time. As a side note, if you need help with documentation, there’s this hacktoberfest thing coming up that would be terrific for encouraging more contributions. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ah, yes The long-format GMT issue is the right place but when we go ahead of it we must baptize the keywords anyway. Thanks for the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Allow makecpt to save the generated color palette table to a file via the output (H) argument. The 'H' setting in GMT upstream (see https://docs.generic-mapping-tools.org/latest/makecpt.html#h) is actually a flag to force the creation of an output (to stdout) in modern mode. Here we use it to set the filename too. See also GenericMappingTools/gmt#827 and GenericMappingTools/gmt#823
With rainbow cmap checks to test various zlow/zhigh combinations.
Used 'earth' cmap to test various reversed colormap examples.
There was an error while loading. Please reload this page.
|
I think this is ready for review. The Happy to consider any other suggestions too 😄 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me.
Can you also implement the -Z option? I believe it's also commonly used.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| outfile = kwargs.pop("H") | ||
| if not outfile or not isinstance(outfile, str): | ||
| raise GMTInvalidInput("'output' should be a proper file name.") | ||
| arg_str = " ".join([build_arg_string(kwargs), f"-H > {outfile}"]) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Other functions in PyGMT which output to a file use -> instead of >. I don't know why but maybe you can try if -> also works.
| arg_str = " ".join([build_arg_string(kwargs), f"-H > {outfile}"]) | |
| arg_str = " ".join([build_arg_string(kwargs), f"-H -> {outfile}"]) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure it'll work, and I did notice it in other parts of the code but never quite understood why -> is used. Is it meant to be a cross-platform thing?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ok, I was wrong, -> doesn't work. The test_makecpt_output_to_cpt_file function fails with this error message:
def test_makecpt_output_to_cpt_file(): """ Save the generated static color palette table to a .cpt file """ with GMTTempFile(suffix=".cpt") as cptfile: > makecpt(output=cptfile.name) ../pygmt/tests/test_makecpt.py:82: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../pygmt/helpers/decorators.py:187: in new_module return module_func(*args, **kwargs) ../pygmt/helpers/decorators.py:282: in new_module return module_func(*args, **kwargs) ../pygmt/mathops.py:65: in makecpt lib.call_module(module="makecpt", args=arg_str) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pygmt.clib.session.Session object at 0x7fe9ae6ad470>, module = 'makecpt', args = ' -H -> /tmp/pygmt-dz2kwkqs.cpt' def call_module(self, module, args): """ Call a GMT module with the given arguments. Makes a call to ``GMT_Call_Module`` from the C API using mode ``GMT_MODULE_CMD`` (arguments passed as a single string). Most interactions with the C API are done through this function. Parameters ---------- module : str Module name (``'pscoast'``, ``'psbasemap'``, etc). args : str String with the command line arguments that will be passed to the module (for example, ``'-R0/5/0/10 -JM'``). Raises ------ GMTCLibError If the returned status code of the function is non-zero. """ c_call_module = self.get_libgmt_func( "GMT_Call_Module", argtypes=[ctp.c_void_p, ctp.c_char_p, ctp.c_int, ctp.c_void_p], restype=ctp.c_int, ) mode = self["GMT_MODULE_CMD"] status = c_call_module( self.session_pointer, module.encode(), mode, args.encode() ) if status != 0: raise GMTCLibError( "Module '{}' failed with status code {}:\n{}".format( > module, status, self._error_message ) ) E pygmt.exceptions.GMTCLibError: Module 'makecpt' failed with status code 71: E makecpt [ERROR]: Syntax error: No input files expected unless -E or -S are used ../pygmt/clib/session.py:490: GMTCLibError --------------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------------- makecpt [ERROR]: Syntax error: No input files expected unless -E or -S are used
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Included one test to create a continuous cpt from blue to white. Also updated link to the full list of GMT's color palette tables due to documentation reorganization during GenericMappingTools/gmt#1594.
Includes GenericMappingTools/pygmt#343 that will hopefully address https://github.com/dependabot/feedback/issues/482. There's also the new `makecpt` wrapper added in GenericMappingTools/pygmt#329. Need to temporarily pin dask at 0.12.3 because of some multiprocessing error. - [GMT](https://github.com/GenericMappingTools/gmt) from 6.0.0rc3 to 6.0.0rc5 - [Release notes](https://github.com/GenericMappingTools/gmt/releases/tag/6.0.0rc5) - [Commits](GenericMappingTools/gmt@6.0.0rc3...6.0.0rc5) - [PyGMT](https://github.com/GenericMappingTools/pygmt) from 0.0.1a0-43-g421e10d to 0.0.1a0-57-g7590d4a. - [Commits](weiji14/pygmt@0.0.1a0-43-g421e10d...0.0.1a0-57-g7590d4a)
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Wrapper for makecpt
There was an error while loading. Please reload this page.