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
Create a wrapper function for gmt info. Data input should be a file name data='some_file.txt'. Doesn't really make much sense to read in numpy arrays for this because most of it can be done using numpy functions.
See how other modules are wrapped, for example in gmt/base_plotting.py.
Yeah, I've been trying to come up with a good module structure for these. I think we can keep them in a gmt/modules.py for now. If it gets too large we'll split it up.
A much simpler alternative would be to tell GMT to send the output to a temporary file which we read in later. This might be the better option actually. You can pass an argument ->FILE_NAME to a GMT module and it will write to FILE_NAME instead. Using a tempfile.NamedTemporaryFile would work great with this.
Activity
seisman commentedon Dec 3, 2017
I'd like to implement it. Where to put this wrapper function?
base_plotting.pyis not a good choice.leouieda commentedon Dec 3, 2017
Yeah, I've been trying to come up with a good module structure for these. I think we can keep them in a
gmt/modules.pyfor now. If it gets too large we'll split it up.leouieda commentedon Dec 3, 2017
@seisman sorry, I just realized that modules like
gmt infothat print things to stdout aren't very useful to us. We would need to capture the stdout output to a Python string so that we can return that to the user instead. I found this on stackoverflow that would work great implemented as acapture_stdoutcontext manager ongmt/utils.py: https://stackoverflow.com/questions/24277488/in-python-how-to-capture-the-stdout-from-a-c-shared-library-to-a-variableleouieda commentedon Dec 3, 2017
A much simpler alternative would be to tell GMT to send the output to a temporary file which we read in later. This might be the better option actually. You can pass an argument
->FILE_NAMEto a GMT module and it will write toFILE_NAMEinstead. Using atempfile.NamedTemporaryFilewould work great with this.