Skip to content

Commit

Permalink
clarify boolean arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenworsley committed Oct 21, 2022
1 parent d5ecec7 commit f4dd0b9
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions esmf_regrid/schemes.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ class ESMFAreaWeighted:
:mod:`ESMF` to be able to handle grids in different coordinate systems.
"""

def __init__(self, mdtol=0, src_mask=None, tgt_mask=None):
def __init__(self, mdtol=0, src_mask=False, tgt_mask=False):
"""
Area-weighted scheme for regridding between rectilinear grids.
Expand All @@ -405,12 +405,12 @@ def __init__(self, mdtol=0, src_mask=None, tgt_mask=None):
data is tolerated while ``mdtol=1`` will mean the resulting element
will be masked if and only if all the overlapping elements of the
source grid are masked.
src_mask : :obj:`~numpy.typing.ArrayLike`, bool, optional
Array describing which elements :mod:`ESMF` will ignore on the source grid.
If True, the mask will be derived from the cube.
tgt_mask : :obj:`~numpy.typing.ArrayLike`, bool, optional
Array describing which elements :mod:`ESMF` will ignore on the target grid.
If True, the mask will be derived from the cube.
src_mask : bool, default=False
If True, derive a mask from source cube which will tell :mod:`ESMF`
which points to ignore.
tgt_mask : bool, default=False
If True, derive a mask from target cube which will tell :mod:`ESMF`
which points to ignore.
"""
if not (0 <= mdtol <= 1):
Expand Down Expand Up @@ -455,7 +455,7 @@ def regridder(self, src_grid, tgt_grid):
class ESMFAreaWeightedRegridder:
r"""Regridder class for unstructured to rectilinear :class:`~iris.cube.Cube`\\ s."""

def __init__(self, src_grid, tgt_grid, mdtol=0, src_mask=None, tgt_mask=None):
def __init__(self, src_grid, tgt_grid, mdtol=0, src_mask=False, tgt_mask=False):
"""
Create regridder for conversions between ``src_grid`` and ``tgt_grid``.
Expand All @@ -472,11 +472,11 @@ def __init__(self, src_grid, tgt_grid, mdtol=0, src_mask=None, tgt_mask=None):
``mdtol=1`` will mean the resulting element will be masked if and only
if all the contributing elements of data are masked.
src_mask : :obj:`~numpy.typing.ArrayLike`, bool, optional
Array describing which elements :mod:`ESMF` will ignore on the source grid.
If True, the mask will be derived from the cube.
Array describing which elements :mod:`ESMF` will ignore on the src_grid.
If True, the mask will be derived from src_grid.
tgt_mask : :obj:`~numpy.typing.ArrayLike`, bool, optional
Array describing which elements :mod:`ESMF` will ignore on the target grid.
If True, the mask will be derived from the cube.
Array describing which elements :mod:`ESMF` will ignore on the tgt_grid.
If True, the mask will be derived from tgt_grid.
"""
if not (0 <= mdtol <= 1):
Expand All @@ -486,8 +486,12 @@ def __init__(self, src_grid, tgt_grid, mdtol=0, src_mask=None, tgt_mask=None):

if src_mask is True:
src_mask = _get_mask(src_grid)
elif src_mask is False:
src_mask = None
if tgt_mask is True:
tgt_mask = _get_mask(tgt_grid)
elif tgt_mask is False:
tgt_mask = None

regrid_info = _regrid_rectilinear_to_rectilinear__prepare(
src_grid, tgt_grid, src_mask=src_mask, tgt_mask=tgt_mask
Expand Down

0 comments on commit f4dd0b9

Please sign in to comment.