Skip to content

Wrapper for gmt info #43

Closed
Closed

Description

@leouieda

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.

Activity

  1. added
    help wanted
    on Nov 30, 2017
  2. seisman commented on Dec 3, 2017

    @seisman
    Member

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

  3. leouieda commented on Dec 3, 2017

    @leouieda
    MemberAuthor

    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.

  4. leouieda commented on Dec 3, 2017

    @leouieda
    MemberAuthor

    @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

  5. leouieda commented on Dec 3, 2017

    @leouieda
    MemberAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issuehelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions