Skip to content

Commit

Permalink
Add basic example for using GrdMathCalc and run docformatter
Browse files Browse the repository at this point in the history
  • Loading branch information
weiji14 committed Sep 19, 2021
1 parent 2279eb5 commit 40115aa
Showing 1 changed file with 16 additions and 3 deletions.
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

0 comments on commit 40115aa

Please sign in to comment.