Skip to content

Commit

Permalink
Update __init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
yukaribbba committed Apr 22, 2024
1 parent 294c3d7 commit 28c5099
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions satpy/composites/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1033,8 +1033,10 @@ def __call__(self, projectables, *args, **kwargs):
class CloudCompositor(GenericCompositor):
"""Detect clouds based on thresholding and use it as a mask for compositing."""

_supported_modes = ["LA", "RGBA"]

def __init__(self, name, transition_min=258.15, transition_max=298.15, # noqa: D417
transition_gamma=3.0, invert_alpha=False, **kwargs):
transition_gamma=3.0, invert_alpha=False, mode="LA", **kwargs):
"""Collect custom configuration values.
Args:
Expand All @@ -1045,12 +1047,17 @@ def __init__(self, name, transition_min=258.15, transition_max=298.15, # noqa:
transition_gamma (float): Gamma correction to apply at the end
invert_alpha (bool): Invert the alpha channel to make low data values transparent
and high data values opaque.
mode (str, optional): Image mode to return.
This shall be "LA" (default) or "RGBA".
"""
self.transition_min = transition_min
self.transition_max = transition_max
self.transition_gamma = transition_gamma
self.invert_alpha = invert_alpha
if mode not in self._supported_modes:
raise ValueError(f"Invalid mode {mode!s}. Supported modes: " + ", ".join(self._supported_modes))

Check warning on line 1059 in satpy/composites/__init__.py

View check run for this annotation

Codecov / codecov/patch

satpy/composites/__init__.py#L1059

Added line #L1059 was not covered by tests
self.mode = mode

Check notice on line 1060 in satpy/composites/__init__.py

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Excess Number of Function Arguments

CloudCompositor.__init__ increases from 6 to 7 arguments, threshold = 4. This function has too many arguments, indicating a lack of encapsulation. Avoid adding more arguments.
super(CloudCompositor, self).__init__(name, **kwargs)

def __call__(self, projectables, **kwargs):
Expand All @@ -1077,7 +1084,10 @@ def __call__(self, projectables, **kwargs):

# gamma adjustment
alpha **= gamma
res = super(CloudCompositor, self).__call__((data, alpha), **kwargs)
if self.mode == "LA":
res = super(CloudCompositor, self).__call__((data, alpha), **kwargs)
else:
res = super(CloudCompositor, self).__call__((data, data,data, alpha), **kwargs)

Check warning on line 1090 in satpy/composites/__init__.py

View check run for this annotation

Codecov / codecov/patch

satpy/composites/__init__.py#L1090

Added line #L1090 was not covered by tests
return res


Expand Down

0 comments on commit 28c5099

Please sign in to comment.