Skip to content

Create LibGMT.grid_to_vfile for xarray support #159

Merged
leouieda merged 5 commits intomasterfrom
xarray-support
Apr 10, 2018
Merged

Create LibGMT.grid_to_vfile for xarray support #159
leouieda merged 5 commits intomasterfrom
xarray-support

Conversation

@leouieda
Copy link
Member

@leouieda leouieda commented Apr 9, 2018

Changes proposed in this pull request

Implements a new context manager LibGMT.grid_to_vfile that takes
an xarray.DataArray, creates a GMT_MATRIX to store the data,
passes it along to a virtual file, and yields the virtual file name.

This is the main building block for supporting the grd* commands (#124).

leouieda added 3 commits April 6, 2018 13:52
Implemented a doctest using the earth relief data. Not passing at the
moment. Failing with a Seg Fault. Might be because the direction needs
to be `GMT_IN|GMT_IS_REFERENCE`. Need support for | in the direction
argument.
Still crashing when using ranges and inc but works with dim. Might be a
bug in GMT
Need docs for dataarray_to_matrix and more tests for the code.
@leouieda
Copy link
Member Author

leouieda commented Apr 9, 2018

Still needs some work on documentation and extensive testing.

gmt/clib/core.py Outdated
direction_int = self._parse_constant(
direction, valid=['GMT_IN', 'GMT_OUT'],
valid_modifiers=['GMT_IS_REFERENCE'])
# valid_modifiers=None)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E116 unexpected indentation (comment)


"""
if len(grid.dims) != 2:
raise GMTInvalidInput(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

F821 undefined name 'GMTInvalidInput'

north_incs = north[1:] - north[0:-1]
north_inc = north_incs[0]
if not np.allclose(north_incs, north_inc):
raise GMTInvalidInput(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

F821 undefined name 'GMTInvalidInput'

@leouieda
Copy link
Member Author

leouieda commented Apr 9, 2018

Requires GMT 6.0.0a14 to work. There was a bug in the GMT grid creation when specified the grid dimensions and increments.

@leouieda leouieda merged commit f979f02 into master Apr 10, 2018
@leouieda leouieda deleted the xarray-support branch April 10, 2018 04:31
@leouieda leouieda mentioned this pull request Apr 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants