From 7bfc18cc48f1543f130905bf1f16b91416831f01 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 16 Sep 2021 19:15:03 -0400 Subject: [PATCH 1/7] add dpi --- pygmt/src/grdproject.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pygmt/src/grdproject.py b/pygmt/src/grdproject.py index d50c654438e..53592bf1dcb 100644 --- a/pygmt/src/grdproject.py +++ b/pygmt/src/grdproject.py @@ -16,6 +16,7 @@ @fmt_docstring @use_alias( + E="dpi", G="outgrid", J="projection", I="inverse", @@ -58,6 +59,8 @@ def grdproject(grid, **kwargs): geographical [Default is False]. {J} {R} + dpi : int + Set the resolution for the new grid in dots per inch. {V} {n} {r} From 44c45212c22043497c8308a52441403531bb6271 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 16 Sep 2021 19:17:56 -0400 Subject: [PATCH 2/7] add scaling and unit --- pygmt/src/grdproject.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pygmt/src/grdproject.py b/pygmt/src/grdproject.py index 53592bf1dcb..2b0677d3ae1 100644 --- a/pygmt/src/grdproject.py +++ b/pygmt/src/grdproject.py @@ -17,9 +17,11 @@ @fmt_docstring @use_alias( E="dpi", + F="scaling", G="outgrid", J="projection", I="inverse", + M="unit", R="region", V="verbose", n="interpolation", @@ -61,6 +63,17 @@ def grdproject(grid, **kwargs): {R} dpi : int Set the resolution for the new grid in dots per inch. + scaling : str + [**c**\|\ **i**\|\ **p**\|\ **e**\|\ **f**\|\ + **k**\|\ **M**\|\ **n**\|\ **u**]. + Force 1:1 scaling, i.e., output or output data are in + actual projected meters [**e**]. To specify other units, append + **f** (foot), **k** (km), **M** (statute mile), **n** (nautical + mile), **u** (US survey foot), **i** (inch), **c** (cm), or **p** + (point). + unit : str + Append **c**, **i**, or **p** to indicate that cm, inch, or point + should be the projected measure unit. Cannot be used with `scaling`. {V} {n} {r} From 589b68aea2871f460e9659afb622936c8e8f7691 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 16 Sep 2021 19:20:18 -0400 Subject: [PATCH 3/7] add center --- pygmt/src/grdproject.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pygmt/src/grdproject.py b/pygmt/src/grdproject.py index 2b0677d3ae1..d7c6bc538e1 100644 --- a/pygmt/src/grdproject.py +++ b/pygmt/src/grdproject.py @@ -16,6 +16,7 @@ @fmt_docstring @use_alias( + C="center", E="dpi", F="scaling", G="outgrid", @@ -27,7 +28,7 @@ n="interpolation", r="registration", ) -@kwargs_to_strings(R="sequence") +@kwargs_to_strings(C="sequence", R="sequence") def grdproject(grid, **kwargs): r""" Change projection of gridded data between geographical and rectangular. @@ -61,6 +62,13 @@ def grdproject(grid, **kwargs): geographical [Default is False]. {J} {R} + center : str or list + [*dx/dy*] + Let projected coordinates be relative to projection center [Default + is relative to lower left corner]. Optionally, add offsets in the + projected units to be added (or subtracted when `inverse` is set) to + (from) the projected coordinates, such as false eastings and + northings for particular projection zones [0/0]. dpi : int Set the resolution for the new grid in dots per inch. scaling : str From 1b4d63077ea094366852d07bebe93acdf759a5d3 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 16 Sep 2021 19:24:37 -0400 Subject: [PATCH 4/7] add spacing --- pygmt/src/grdproject.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pygmt/src/grdproject.py b/pygmt/src/grdproject.py index d7c6bc538e1..be276f19f20 100644 --- a/pygmt/src/grdproject.py +++ b/pygmt/src/grdproject.py @@ -17,6 +17,7 @@ @fmt_docstring @use_alias( C="center", + D="spacing", E="dpi", F="scaling", G="outgrid", @@ -69,6 +70,29 @@ def grdproject(grid, **kwargs): projected units to be added (or subtracted when `inverse` is set) to (from) the projected coordinates, such as false eastings and northings for particular projection zones [0/0]. + spacing : str + *xinc*\ [**+e**\|\ **n**][/\ *yinc*\ [**+e**\|\ **n**]] + Set the grid spacing for the new grid. [Default is the same number of + output nodes as there are input nodes]. Optionally append a suffix + modifier. + **Geographical (degrees) coordinates**: Append + **m** to indicate arc minutes or **s** to indicate arc seconds. If one + of the units **e**, **f**, **k**, **M**, **n** or **u** is appended + instead, the increment is assumed to be given in meter, foot, km, Mile, + nautical mile or US survey foot, respectively, and will be converted to + the equivalent degrees longitude at the middle latitude of the region. + If *y_inc* is given but set to 0 it will be reset equal to *x_inc*; + otherwise it will be converted to degrees latitude. + **All coordinates**: If **+e** is appended + then the corresponding max *x* (*east*) or *y* (*north*) may be slightly + adjusted to fit exactly the given increment [by default the increment + may be adjusted slightly to fit the given domain]. Finally, instead of + giving an increment you may specify the *number of nodes* desired by + appending **+n** to the supplied integer argument; the increment is then + recalculated from the number of nodes and the domain. + **Note**: If `region` is used then the grid spacing (and registration) + have already been initialized; use `spacing` and `registration` to + override the values. dpi : int Set the resolution for the new grid in dots per inch. scaling : str From 8a74285ba1397e8c9481a0b8a0c0ae22683703ca Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 16 Sep 2021 19:38:10 -0400 Subject: [PATCH 5/7] run make format --- pygmt/src/grdproject.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/pygmt/src/grdproject.py b/pygmt/src/grdproject.py index be276f19f20..ee4a0ce018b 100644 --- a/pygmt/src/grdproject.py +++ b/pygmt/src/grdproject.py @@ -72,31 +72,32 @@ def grdproject(grid, **kwargs): northings for particular projection zones [0/0]. spacing : str *xinc*\ [**+e**\|\ **n**][/\ *yinc*\ [**+e**\|\ **n**]] - Set the grid spacing for the new grid. [Default is the same number of - output nodes as there are input nodes]. Optionally append a suffix + Set the grid spacing for the new grid. [Default is the same number of + output nodes as there are input nodes]. Optionally append a suffix modifier. **Geographical (degrees) coordinates**: Append **m** to indicate arc minutes or **s** to indicate arc seconds. If one of the units **e**, **f**, **k**, **M**, **n** or **u** is appended instead, the increment is assumed to be given in meter, foot, km, Mile, nautical mile or US survey foot, respectively, and will be converted to - the equivalent degrees longitude at the middle latitude of the region. - If *y_inc* is given but set to 0 it will be reset equal to *x_inc*; - otherwise it will be converted to degrees latitude. + the equivalent degrees longitude at the middle latitude of the region. + If *y_inc* is given but set to 0 it will be reset equal to *x_inc*; + otherwise it will be converted to degrees latitude. **All coordinates**: If **+e** is appended - then the corresponding max *x* (*east*) or *y* (*north*) may be slightly - adjusted to fit exactly the given increment [by default the increment - may be adjusted slightly to fit the given domain]. Finally, instead of - giving an increment you may specify the *number of nodes* desired by - appending **+n** to the supplied integer argument; the increment is then - recalculated from the number of nodes and the domain. - **Note**: If `region` is used then the grid spacing (and registration) - have already been initialized; use `spacing` and `registration` to + then the corresponding max *x* (*east*) or *y* (*north*) may be + slightly adjusted to fit exactly the given increment [by default the + increment may be adjusted slightly to fit the given domain]. Finally, + instead of giving an increment you may specify the *number of nodes* + desired by appending **+n** to the supplied integer argument; the + increment is then + recalculated from the number of nodes and the domain. + **Note**: If `region` is used then the grid spacing (and registration) + have already been initialized; use `spacing` and `registration` to override the values. dpi : int Set the resolution for the new grid in dots per inch. scaling : str - [**c**\|\ **i**\|\ **p**\|\ **e**\|\ **f**\|\ + [**c**\|\ **i**\|\ **p**\|\ **e**\|\ **f**\|\ **k**\|\ **M**\|\ **n**\|\ **u**]. Force 1:1 scaling, i.e., output or output data are in actual projected meters [**e**]. To specify other units, append @@ -105,7 +106,8 @@ def grdproject(grid, **kwargs): (point). unit : str Append **c**, **i**, or **p** to indicate that cm, inch, or point - should be the projected measure unit. Cannot be used with `scaling`. + should be the projected measure unit. Cannot be used with + `scaling`. {V} {n} {r} From 1f07278d58a066abf4a3d8082a6fc6bc2603b8dd Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 5 Oct 2021 19:03:52 +0100 Subject: [PATCH 6/7] Apply suggestions from code review Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- pygmt/src/grdproject.py | 41 ++++++++--------------------------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/pygmt/src/grdproject.py b/pygmt/src/grdproject.py index ee4a0ce018b..865cafd33a8 100644 --- a/pygmt/src/grdproject.py +++ b/pygmt/src/grdproject.py @@ -64,50 +64,25 @@ def grdproject(grid, **kwargs): {J} {R} center : str or list - [*dx/dy*] + [*dx/dy*]. Let projected coordinates be relative to projection center [Default is relative to lower left corner]. Optionally, add offsets in the projected units to be added (or subtracted when `inverse` is set) to (from) the projected coordinates, such as false eastings and northings for particular projection zones [0/0]. - spacing : str - *xinc*\ [**+e**\|\ **n**][/\ *yinc*\ [**+e**\|\ **n**]] - Set the grid spacing for the new grid. [Default is the same number of - output nodes as there are input nodes]. Optionally append a suffix - modifier. - **Geographical (degrees) coordinates**: Append - **m** to indicate arc minutes or **s** to indicate arc seconds. If one - of the units **e**, **f**, **k**, **M**, **n** or **u** is appended - instead, the increment is assumed to be given in meter, foot, km, Mile, - nautical mile or US survey foot, respectively, and will be converted to - the equivalent degrees longitude at the middle latitude of the region. - If *y_inc* is given but set to 0 it will be reset equal to *x_inc*; - otherwise it will be converted to degrees latitude. - **All coordinates**: If **+e** is appended - then the corresponding max *x* (*east*) or *y* (*north*) may be - slightly adjusted to fit exactly the given increment [by default the - increment may be adjusted slightly to fit the given domain]. Finally, - instead of giving an increment you may specify the *number of nodes* - desired by appending **+n** to the supplied integer argument; the - increment is then - recalculated from the number of nodes and the domain. - **Note**: If `region` is used then the grid spacing (and registration) - have already been initialized; use `spacing` and `registration` to - override the values. + {I} dpi : int Set the resolution for the new grid in dots per inch. scaling : str [**c**\|\ **i**\|\ **p**\|\ **e**\|\ **f**\|\ **k**\|\ **M**\|\ **n**\|\ **u**]. - Force 1:1 scaling, i.e., output or output data are in - actual projected meters [**e**]. To specify other units, append - **f** (foot), **k** (km), **M** (statute mile), **n** (nautical - mile), **u** (US survey foot), **i** (inch), **c** (cm), or **p** - (point). + Force 1:1 scaling, i.e., output or output data are in actual projected + meters [**e**]. To specify other units, append **f** (foot), + **k** (km), **M** (statute mile), **n** (nautical mile), **u** + (US survey foot), **i** (inch), **c** (cm), or **p** (point). unit : str - Append **c**, **i**, or **p** to indicate that cm, inch, or point - should be the projected measure unit. Cannot be used with - `scaling`. + Append **c**, **i**, or **p** to indicate that cm, inch, or point + should be the projected measure unit. Cannot be used with `scaling`. {V} {n} {r} From f08cd5c3a74f5cb1e930d1ac3650ea11db864f8b Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Wed, 6 Oct 2021 06:52:43 +0100 Subject: [PATCH 7/7] Apply suggestions from code review Co-authored-by: Dongdong Tian --- pygmt/src/grdproject.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/src/grdproject.py b/pygmt/src/grdproject.py index 865cafd33a8..b3fde8be248 100644 --- a/pygmt/src/grdproject.py +++ b/pygmt/src/grdproject.py @@ -64,10 +64,10 @@ def grdproject(grid, **kwargs): {J} {R} center : str or list - [*dx/dy*]. + [*dx*, *dy*]. Let projected coordinates be relative to projection center [Default is relative to lower left corner]. Optionally, add offsets in the - projected units to be added (or subtracted when `inverse` is set) to + projected units to be added (or subtracted when ``inverse`` is set) to (from) the projected coordinates, such as false eastings and northings for particular projection zones [0/0]. {I} @@ -82,7 +82,7 @@ def grdproject(grid, **kwargs): (US survey foot), **i** (inch), **c** (cm), or **p** (point). unit : str Append **c**, **i**, or **p** to indicate that cm, inch, or point - should be the projected measure unit. Cannot be used with `scaling`. + should be the projected measure unit. Cannot be used with ``scaling``. {V} {n} {r}