Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Wrap grdmath #1527

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add basic example for using GrdMathCalc and run docformatter
  • Loading branch information
weiji14 committed Sep 19, 2021
commit 40115aad82ef6c96fb4e1a443060d8cb575459d7
19 changes: 16 additions & 3 deletions pygmt/src/grdmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
class GrdMathCalc:
"""
Raster calculator for grids (element by element).

Examples
--------
>>> grdcalc = GrdMathCalc()

>>> # Basic square root operation
>>> grid0 = grdcalc.sqrt(
... ingrid="@earth_relief_01d", outgrid=True, region=[0, 3, 6, 9]
... )
"""

def __init__(self, arg_str=None):
Expand Down Expand Up @@ -111,19 +120,23 @@ def grdmath(cls, operator, ingrid=None, outgrid=None, old_arg_str=None, **kwargs

def sqrt(self, ingrid, outgrid=None, **kwargs):
"""
sqrt (A). 1 input, 1 output.
sqrt (A).

1 input, 1 output.
"""
return self.grdmath(operator="SQRT", ingrid=ingrid, outgrid=outgrid, **kwargs)

def std(self, ingrid, outgrid=None, **kwargs):
"""
Standard deviation of A. 1 input, 1 output.
Standard deviation of A.

1 input, 1 output.
"""
return self.grdmath(operator="STD", ingrid=ingrid, outgrid=outgrid, **kwargs)

def multiply(self, ingrid, outgrid=None, **kwargs):
"""
A * B. 2 inputs, 1 output
A * B. 2 inputs, 1 output.
"""
return self.grdmath(
operator="MUL",
Expand Down