From f49a1a7126f78b0e4a1cc46de3dd308e3f7d58ad Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 16 Sep 2021 21:08:50 -0400 Subject: [PATCH 1/5] add single_form, duplicate, and quantity --- pygmt/src/sphdistance.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pygmt/src/sphdistance.py b/pygmt/src/sphdistance.py index 14883e57ce0..6e770932bc2 100644 --- a/pygmt/src/sphdistance.py +++ b/pygmt/src/sphdistance.py @@ -16,8 +16,14 @@ @fmt_docstring @use_alias( + C="single_form", + D="duplicate", + E="quantity", G="outgrid", I="spacing", + L="unit", + N="nodetable", + Q="voronoi", R="region", V="verbose", ) @@ -41,6 +47,23 @@ def sphdistance(table, **kwargs): {I} {R} {V} + single_form : bool + For large data sets you can save some memory (at the expense of more + processing) by only storing one form of location coordinates + (geographic or Cartesian 3-D vectors) at any given time, translating + from one form to the other when necessary [Default keeps both arrays + in memory]. Not applicable with `voronoi`. + duplicate : bool + Used to skip duplicate points since the algorithm cannot handle them. + [Default assumes there are no duplicates]. + quantity : str + Specify the quantity that should be assigned to the grid nodes. By + default we compute distances to the nearest data point [**d**]. + Use **n** to assign the ID numbers of the Voronoi polygons that each + grid node is inside, or use **z** for a natural nearest-neighbor grid + where we assign all nodes inside the polygon the z-value of the center + node. Optionally, append the resampling interval along Voronoi arcs in + spherical degrees. Returns ------- From 2a392fbaf57fa5c7413c845dee5eaac67ef179a0 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 16 Sep 2021 21:10:56 -0400 Subject: [PATCH 2/5] add unit, voronioi, and nodetable --- pygmt/src/sphdistance.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pygmt/src/sphdistance.py b/pygmt/src/sphdistance.py index 6e770932bc2..6a20a1fd02a 100644 --- a/pygmt/src/sphdistance.py +++ b/pygmt/src/sphdistance.py @@ -64,7 +64,19 @@ def sphdistance(table, **kwargs): where we assign all nodes inside the polygon the z-value of the center node. Optionally, append the resampling interval along Voronoi arcs in spherical degrees. - + unit : str + Specify the unit used for distance calculations. Choose among **d** + (spherical degree), **e** (m), **f** (feet), **k** (km), **M** + (mile), **n** (nautical mile) or **u** survey foot. + nodetable : str + Read the information pertaining to each Voronoi + polygon (the unique node lon, lat and polygon area) from a separate + file [Default acquires this information from the ASCII segment + headers of the output file]. Required if binary input via `voronoi` + is used. + voronoi : str + Append the name of a file with pre-calculated Voronoi polygons + [Default performs the Voronoi construction on input data]. Returns ------- ret: xarray.DataArray or None From 3ba48fda77b1ad22fdc484a91c9fdad1e73eeebd Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 16 Sep 2021 21:13:21 -0400 Subject: [PATCH 3/5] add units --- pygmt/src/sphdistance.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pygmt/src/sphdistance.py b/pygmt/src/sphdistance.py index 6a20a1fd02a..fecbba01aba 100644 --- a/pygmt/src/sphdistance.py +++ b/pygmt/src/sphdistance.py @@ -60,9 +60,9 @@ def sphdistance(table, **kwargs): Specify the quantity that should be assigned to the grid nodes. By default we compute distances to the nearest data point [**d**]. Use **n** to assign the ID numbers of the Voronoi polygons that each - grid node is inside, or use **z** for a natural nearest-neighbor grid - where we assign all nodes inside the polygon the z-value of the center - node. Optionally, append the resampling interval along Voronoi arcs in + grid node is inside, or use **z** for a natural nearest-neighbor grid + where we assign all nodes inside the polygon the z-value of the center + node. Optionally, append the resampling interval along Voronoi arcs in spherical degrees. unit : str Specify the unit used for distance calculations. Choose among **d** @@ -72,7 +72,7 @@ def sphdistance(table, **kwargs): Read the information pertaining to each Voronoi polygon (the unique node lon, lat and polygon area) from a separate file [Default acquires this information from the ASCII segment - headers of the output file]. Required if binary input via `voronoi` + headers of the output file]. Required if binary input via `voronoi` is used. voronoi : str Append the name of a file with pre-calculated Voronoi polygons From 17f9f53cde69ef0ce039131c8f82cdff288febed Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Fri, 15 Oct 2021 11:56:45 +0100 Subject: [PATCH 4/5] Apply suggestions from code review Co-authored-by: Meghan Jones Co-authored-by: Dongdong Tian --- pygmt/src/sphdistance.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/pygmt/src/sphdistance.py b/pygmt/src/sphdistance.py index fecbba01aba..70a340601ac 100644 --- a/pygmt/src/sphdistance.py +++ b/pygmt/src/sphdistance.py @@ -22,7 +22,7 @@ G="outgrid", I="spacing", L="unit", - N="nodetable", + N="node_table", Q="voronoi", R="region", V="verbose", @@ -52,23 +52,28 @@ def sphdistance(table, **kwargs): processing) by only storing one form of location coordinates (geographic or Cartesian 3-D vectors) at any given time, translating from one form to the other when necessary [Default keeps both arrays - in memory]. Not applicable with `voronoi`. + in memory]. Not applicable with ``voronoi``. duplicate : bool Used to skip duplicate points since the algorithm cannot handle them. [Default assumes there are no duplicates]. quantity : str - Specify the quantity that should be assigned to the grid nodes. By - default we compute distances to the nearest data point [**d**]. - Use **n** to assign the ID numbers of the Voronoi polygons that each - grid node is inside, or use **z** for a natural nearest-neighbor grid - where we assign all nodes inside the polygon the z-value of the center - node. Optionally, append the resampling interval along Voronoi arcs in + **d**\|\ **n**\|\ **z**\ [*dist*] + Specify the quantity that should be assigned to the grid nodes [Default + is **d**]: + + - **d** - compute distances to the nearest data point + - **n** - assign the ID numbers of the Voronoi polygons that each + grid node is inside + - **z** - assign all nodes inside the polygon the z-value of the center + node fot a natural nearest-neighbor grid. + + Optionally, append the resampling interval along Voronoi arcs in spherical degrees. unit : str Specify the unit used for distance calculations. Choose among **d** (spherical degree), **e** (m), **f** (feet), **k** (km), **M** (mile), **n** (nautical mile) or **u** survey foot. - nodetable : str + node_table : str Read the information pertaining to each Voronoi polygon (the unique node lon, lat and polygon area) from a separate file [Default acquires this information from the ASCII segment From e1b12c82de86d79cf948c6afdad4b4a04f23bfa2 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Mon, 25 Oct 2021 16:43:41 +0100 Subject: [PATCH 5/5] Apply suggestions from code review Co-authored-by: Dongdong Tian --- pygmt/src/sphdistance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/sphdistance.py b/pygmt/src/sphdistance.py index 8c7d4566b48..32e858db581 100644 --- a/pygmt/src/sphdistance.py +++ b/pygmt/src/sphdistance.py @@ -66,7 +66,7 @@ def sphdistance(data=None, x=None, y=None, **kwargs): Used to skip duplicate points since the algorithm cannot handle them. [Default assumes there are no duplicates]. quantity : str - **d**\|\ **n**\|\ **z**\ [*dist*] + **d**\|\ **n**\|\ **z**\ [*dist*]. Specify the quantity that should be assigned to the grid nodes [Default is **d**]: