-
Notifications
You must be signed in to change notification settings - Fork 233
Description
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:
- Some future proofing necessary. The code will be eventually be shared with other grid functions like
nearneighbor,sphinterpolate, etc. - Agree on some aliases first with Easier to read aliases in docstrings #79 (Easier to read aliases in docstrings) (see also List of GMT aliases #48). Minimum required argument for
surfaceis-Goutput file name,-lgrid spacing and-Rregion of interest. - Add a sample dataset,
@tut_ship.xyzused in the 'Gridding of arbitrarily spaced data' tutorial.
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 outputfileI'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!