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 gmt info #43

Closed
leouieda opened this issue Aug 15, 2017 · 4 comments
Closed

Wrapper for gmt info #43

leouieda opened this issue Aug 15, 2017 · 4 comments
Labels
good first issue Good for newcomers help wanted Helping hands are appreciated

Comments

@leouieda
Copy link
Member

leouieda commented Aug 15, 2017

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.

@leouieda leouieda added good first issue Good for newcomers feature labels Aug 15, 2017
@leouieda leouieda added the help wanted Helping hands are appreciated label Nov 30, 2017
@seisman
Copy link
Member

seisman commented Dec 3, 2017

I'd like to implement it. Where to put this wrapper function? base_plotting.py is not a good choice.

@leouieda
Copy link
Member Author

leouieda commented 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.py for now. If it gets too large we'll split it up.

@leouieda
Copy link
Member Author

leouieda commented Dec 3, 2017

@seisman sorry, I just realized that modules like gmt info that 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 a capture_stdout context manager on gmt/utils.py: https://stackoverflow.com/questions/24277488/in-python-how-to-capture-the-stdout-from-a-c-shared-library-to-a-variable

@leouieda
Copy link
Member Author

leouieda commented 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_NAME to a GMT module and it will write to FILE_NAME instead. Using a tempfile.NamedTemporaryFile would work great with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Helping hands are appreciated
Projects
None yet
Development

No branches or pull requests

2 participants