From 8897946afa3afdbe620fe73225cb350208894b0d Mon Sep 17 00:00:00 2001 From: Daniel-Eduardo-Rojas-Ariza Date: Thu, 19 Aug 2021 16:43:57 -0500 Subject: [PATCH 1/6] Expand table-like input options for pygmt.surface --- pygmt/src/surface.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pygmt/src/surface.py b/pygmt/src/surface.py index 1d24a438595..a05910a2bd9 100644 --- a/pygmt/src/surface.py +++ b/pygmt/src/surface.py @@ -84,14 +84,10 @@ def surface(x=None, y=None, z=None, data=None, **kwargs): with GMTTempFile(suffix=".nc") as tmpfile: with Session() as lib: - if kind == "file": - file_context = dummy_context(data) - elif kind == "matrix": - file_context = lib.virtualfile_from_matrix(data) - elif kind == "vectors": - file_context = lib.virtualfile_from_vectors(x, y, z) - else: - raise GMTInvalidInput("Unrecognized data type: {}".format(type(data))) + # Choose how data will be passed into the module + file_context = lib.virtualfile_from_data( + kind = "vector", data=data, x=x, y=y, z=z + ) with file_context as infile: if "G" not in kwargs.keys(): # if outfile is unset, output to tmpfile kwargs.update({"G": tmpfile.name}) From c8cfb287f72781d61617a06b4f9506e5af098ca8 Mon Sep 17 00:00:00 2001 From: daroari <60489499+daroari@users.noreply.github.com> Date: Thu, 19 Aug 2021 18:08:24 -0500 Subject: [PATCH 2/6] Update pygmt/src/surface.py Co-authored-by: Meghan Jones --- pygmt/src/surface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/surface.py b/pygmt/src/surface.py index a05910a2bd9..e445eada987 100644 --- a/pygmt/src/surface.py +++ b/pygmt/src/surface.py @@ -86,7 +86,7 @@ def surface(x=None, y=None, z=None, data=None, **kwargs): with Session() as lib: # Choose how data will be passed into the module file_context = lib.virtualfile_from_data( - kind = "vector", data=data, x=x, y=y, z=z + check_kind="vector", data=data, x=x, y=y, z=z ) with file_context as infile: if "G" not in kwargs.keys(): # if outfile is unset, output to tmpfile From 6f05cc8b3399e0c48a7922b569c4642539e3f60d Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Thu, 19 Aug 2021 23:18:35 +0000 Subject: [PATCH 3/6] [format-command] fixes --- pygmt/src/surface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/surface.py b/pygmt/src/surface.py index e445eada987..e0a27eafb08 100644 --- a/pygmt/src/surface.py +++ b/pygmt/src/surface.py @@ -86,7 +86,7 @@ def surface(x=None, y=None, z=None, data=None, **kwargs): with Session() as lib: # Choose how data will be passed into the module file_context = lib.virtualfile_from_data( - check_kind="vector", data=data, x=x, y=y, z=z + check_kind="vector", data=data, x=x, y=y, z=z ) with file_context as infile: if "G" not in kwargs.keys(): # if outfile is unset, output to tmpfile From 3c74ccb8f2a371e8109ecffb56707e4d1cf4ebfe Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 21 Sep 2021 15:38:34 +0800 Subject: [PATCH 4/6] Remove unused imports and variables --- pygmt/src/surface.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/pygmt/src/surface.py b/pygmt/src/surface.py index 1492637b2f4..30558be0270 100644 --- a/pygmt/src/surface.py +++ b/pygmt/src/surface.py @@ -9,7 +9,6 @@ build_arg_string, data_kind, deprecate_parameter, - dummy_context, fmt_docstring, kwargs_to_strings, use_alias, @@ -92,8 +91,6 @@ def surface(x=None, y=None, z=None, data=None, **kwargs): - None if ``outgrid`` is set (grid output will be stored in file set by ``outgrid``) """ - kind = data_kind(data, x, y, z, required_z=True) - with GMTTempFile(suffix=".nc") as tmpfile: with Session() as lib: # Choose how data will be passed into the module From f3510fff2698b4f8e9e97c965eeb556d17061584 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 21 Sep 2021 15:41:15 +0800 Subject: [PATCH 5/6] Update docstring for data --- pygmt/src/surface.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pygmt/src/surface.py b/pygmt/src/surface.py index 30558be0270..0bd6b1a7fb0 100644 --- a/pygmt/src/surface.py +++ b/pygmt/src/surface.py @@ -58,14 +58,14 @@ def surface(x=None, y=None, z=None, data=None, **kwargs): ---------- x/y/z : 1d arrays Arrays of x and y coordinates and values z of the data points. - data : str or 2d array - Either a data file name or a 2d numpy array with the tabular data. + data : str or {table-like} + Pass in (x, y, z) or (longitude, latitude, elevation) values by + providing a file name to an ASCII data table, a 2D + {table-classes}. {I} - region : str or list - *xmin/xmax/ymin/ymax*\[**+r**][**+u**\ *unit*]. - Specify the region of interest. + {R} outgrid : str Optional. The file name for the output netcdf file with extension .nc From b4077213cf61f19f1cf8b99b30d7f9c8c9f6f1a5 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 21 Sep 2021 15:48:24 +0800 Subject: [PATCH 6/6] Remove unused imports --- pygmt/src/surface.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pygmt/src/surface.py b/pygmt/src/surface.py index 0bd6b1a7fb0..1e028b4ecc8 100644 --- a/pygmt/src/surface.py +++ b/pygmt/src/surface.py @@ -3,11 +3,9 @@ splines. """ from pygmt.clib import Session -from pygmt.exceptions import GMTInvalidInput from pygmt.helpers import ( GMTTempFile, build_arg_string, - data_kind, deprecate_parameter, fmt_docstring, kwargs_to_strings,