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

Simplify decomposition logic #220

Merged
merged 4 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 8 additions & 7 deletions src/sleplet/meshes/_mesh_slepian_decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,16 @@ def _harmonic_sum(self, rank: int) -> float:

def _detect_method(self) -> None:
"""Detects what method is used to perform the decomposition."""
if isinstance(self.u_i, np.ndarray):
if self.u_i is not None:
_logger.info("harmonic sum method selected")
self.method = "harmonic_sum"
elif isinstance(self.u, np.ndarray) and not self.mask:
_logger.info("integrating the whole mesh method selected")
self.method = "integrate_mesh"
elif isinstance(self.u, np.ndarray):
_logger.info("integrating a region on the mesh method selected")
self.method = "integrate_region"
elif self.u is not None:
if self.mask:
_logger.info("integrating a region on the mesh method selected")
self.method = "integrate_region"
else:
_logger.info("integrating the whole mesh method selected")
self.method = "integrate_mesh"
else:
raise RuntimeError(
"need to pass one off harmonic coefficients, real pixels "
Expand Down
15 changes: 8 additions & 7 deletions src/sleplet/slepian/_slepian_decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,16 @@ def _harmonic_sum(self, rank: int) -> complex:

def _detect_method(self) -> None:
"""Detects what method is used to perform the decomposition."""
if isinstance(self.flm, np.ndarray):
if self.flm is not None:
_logger.info("harmonic sum method selected")
self.method = "harmonic_sum"
elif isinstance(self.f, np.ndarray) and not isinstance(self.mask, np.ndarray):
_logger.info("integrating the whole sphere method selected")
self.method = "integrate_sphere"
elif isinstance(self.f, np.ndarray):
_logger.info("integrating a region on the sphere method selected")
self.method = "integrate_region"
elif self.f is not None:
if self.mask is None:
_logger.info("integrating the whole sphere method selected")
self.method = "integrate_sphere"
else:
_logger.info("integrating a region on the sphere method selected")
self.method = "integrate_region"
else:
raise RuntimeError(
"need to pass one off harmonic coefficients, real pixels "
Expand Down