Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapper for pstext #122

Closed
ziyixi opened this issue Jan 17, 2018 · 3 comments · Fixed by #321
Closed

Wrapper for pstext #122

ziyixi opened this issue Jan 17, 2018 · 3 comments · Fixed by #321
Labels
feature request New feature wanted

Comments

@ziyixi
Copy link

ziyixi commented Jan 17, 2018

Hello, I have noticed there is no support for the common used command pstext. I have tried hours for supporting the command in my own machine. However, there seems to be some problems handling input like:

when I want to realize:

gmt pstext -J -R -F+f12p,1,black+jTL -D-1.5c/-0.15c -K -O >> $PS << EOF
-77.15 38.89 Washington
76.22 -69.22 Zhongshanzhan
EOF

a common choice in the python module is:

gmt.pstext(<some parameters>)

so how to input?

<< EOF
-77.15 38.89 Washington
76.22 -69.22 Zhongshanzhan
EOF

First I have tried use the virtual file you have used. However, it seems the virtual file only supports numbers but not strings like "Washington"..
Then, since we couldn't use the virtual database supported by GMT, then the only choice might be the python own virtual file, but it seems difficult to combine it with the console of libgmt....
Then we might need create a file in some place like /tmp or some place else to create a real file? or some realization similar to the GMT database..
I think this feather is really important and what's your advise?

@ziyixi
Copy link
Author

ziyixi commented Jan 17, 2018

I think supporting some feathers like:

    @fmt_docstring
    @use_alias()
    @kwargs_to_strings(R='sequence')
    def rawcommand(self, module=None, command=None):
        """
        """
        # kwargs = self._preprocess(**kwargs)
        with LibGMT() as lib:
            lib.call_module(module,command)

in the module BasePlotting may be a good choice at the moment..... :) to console a command in the form like:

fig.rawcommand(module='pstext',command='-F+f12p,1,black+jTL -D-1c/-0.15c temp/temp.txt')

Here temp.txt is the input file I created.

@leouieda
Copy link
Member

@ziyixi there were some changes made to the internal data structures of GMT lately regarding text input. I still need to do some work on the undelying virtual file machinery to make this work but that is the way forward. This will have to wait a bit but it should be ready in the next couple of months. Then it would be possible to wrap text (there is no ps anymore in GMT modern mode).

We decided not to add the raw GMT command-line option because it doesn't integrate well with Python and an be replaced by a subprocess call. We also try to avoid using temp files as much as possible and pass things in memory between GMT and Python.

Thanks for the input! We'll keep you posted when the virtual file parts are ready for pstext.

@leouieda leouieda added the feature request New feature wanted label Feb 12, 2018
@leouieda leouieda changed the title Support for pstext Wrapper for pstext Apr 24, 2018
weiji14 added a commit to weiji14/pygmt that referenced this issue Aug 20, 2019
Initial commit for wrapping the text/pstext function raised at GenericMappingTools#122, to be implemented under base_plotting.py alongside the other mapping related stuff. Original GMT `text` documentation can be found at https://gmt.soest.hawaii.edu/doc/latest/text.html. Storing sample test cases at test_text.py. Current implementation takes in either a text filename or x,y,text triples as input.
@weiji14 weiji14 mentioned this issue Aug 20, 2019
8 tasks
@weiji14
Copy link
Member

weiji14 commented Oct 31, 2019

Hi @ziyixi, text is now implemented in PyGMT, you'll need to install it from Github and should be good to go. Let us know if you need any help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants