Skip to content

Wrap GMT_Inquire_VirtualFile to get the family of virtualfiles - #3152

Merged
seisman merged 5 commits into
mainfrom
inquire_virtualfiles
Apr 7, 2024
Merged

Wrap GMT_Inquire_VirtualFile to get the family of virtualfiles#3152
seisman merged 5 commits into
mainfrom
inquire_virtualfiles

Conversation

@seisman

@seismanseisman commented Apr 1, 2024

Copy link
Copy Markdown
Member

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()

@seismanseisman added enhancement Improving an existing feature needs review This PR has higher priority and needs review. labels Apr 1, 2024
@seismanseisman added this to the 0.12.0 milestone Apr 1, 2024
Comment threadpygmt/tests/test_clib_virtualfiles.py Outdated
Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com>
Comment threadpygmt/clib/session.py Outdated
@seismanseisman 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 teamApril 6, 2024 14:10
@seisman
seisman merged commit a32049d into mainApr 7, 2024
@seisman
seisman deleted the inquire_virtualfiles branch April 7, 2024 11:59
@seismanseisman removed the final review call This PR requires final review and approval from a second reviewer label Apr 8, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancementImproving an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@seisman@yvonnefroehlich