Skip to content

Wrapper for surface #243

Closed
Closed
@weiji14

Description

@weiji14

Description of the desired feature

Hi there, I'd like to help implement the surface function which "Grids table data using adjustable tension continuous curvature splines". There's a lot of plotting related functionality in gmt-python now, but there's more to GMT than that! Basically, this feature request aims to bring some data processing functionality into gmt-python.

The surface function is actually just one small part of the 'Gridding of Data Tables' family of functions in GMT (see module quickref), but I'd like to start with surface because 1) It appears to be a common gridding function (there's a tutorial for it) and 2) I'm using it.

Things to keep in mind:

Idea for structure:

Store the surface function in a Gridding class under gridding.py. Similar to how e.g. psconvert is in the Figure class under figure.py. This means we can store future gridding functions like nearneighbor in the same place.

# File at gmt/gridding.py
"""
Define the Gridding class that handles all gridding.
"""

class Gridding:
    def surface(x=None, y=None, z=None, data=None, **kwargs):
        raise NotImplementedError("GMT gridding surface")

This is my initial stab at a test case file. Loosely based on the following bash code used in the tutorial.

    gmt blockmedian -R245/255/20/30 -I5m -V @tut_ship.xyz > ship_5m.xyz
    gmt surface ship_5m.xyz -R245/255/20/30 -I5m -Gship.nc -V
# File at gmt/tests/test_surface.py
"""
Test Gridding.surface
"""

from .. import Gridding
from ..datasets import load_tut_ship

def test_surface():
    ship_data = load_tut_ship()
    outputfile = Gridding.surface(
        x=ship_data.x,
        y=ship_data.y,
        z=ship_data.z,
        G="ship.nc",
        I="5m",
        R="245/255/20/30",
    )
    return outputfile

I've actually got some boilerplate code ready on my fork. Just wanting to get the green light and check if I've missed out on any important details.

Are you willing to help implement and maintain this feature? Yes!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions