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

Wrap GMT_Inquire_VirtualFile to get the family of virtualfiles #3152

Merged
merged 5 commits into from
Apr 7, 2024

Conversation

seisman
Copy link
Member

@seisman seisman commented Apr 1, 2024

Description of proposed changes

Upstream documentation: http://docs.generic-mapping-tools.org/dev/devdocs/api.html#gmt-inquire-virtualfile

The GMT_Inquire_VirtualFile API function takes the name of a virtual file as input, and returns the integer of the family.

This PR wraps up the API function. Tests are also added.

Address the request in #3115 (comment).

After this PR is merged, we will refactor

def virtualfile_to_grid(self, vfname, outgrid):
    if outgrid is not None:
        return None
    return self.read_virtualfile(vfname, kind="grid").contents.to_dataarray()

to something like

def virtualfile_to_raster(self, vfname, outgrid, kind="grid"):
    if outgrid is not None:
        return None
    if kind is None: 
        family = self.inquire_virtualfile(vfname)
        kind = {
            self["GMT_IS_GRID"]: "grid",
            self["GMT_IS_IMAGE"]: "image",
            self["GMT_IS_CUBE"]: "cube",
       }[family]
    return self.read_virtualfile(vfname, kind=kind).contents.to_dataarray()

@seisman seisman added enhancement Improving an existing feature needs review This PR has higher priority and needs review. labels Apr 1, 2024
@seisman seisman added this to the 0.12.0 milestone Apr 1, 2024
Co-authored-by: Yvonne Fröhlich <[email protected]>
pygmt/clib/session.py Outdated Show resolved Hide resolved
@seisman seisman added final review call This PR requires final review and approval from a second reviewer and removed needs review This PR has higher priority and needs review. labels Apr 6, 2024
@seisman seisman requested a review from a team April 6, 2024 14:10
@seisman seisman merged commit a32049d into main Apr 7, 2024
21 checks passed
@seisman seisman deleted the inquire_virtualfiles branch April 7, 2024 11:59
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improving an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants