Skip to content

Commit

Permalink
Update radial.py to include "none" as an option for rhef (#266)
Browse files Browse the repository at this point in the history
Co-authored-by: Nabil Freij <[email protected]>
  • Loading branch information
GillySpace27 and nabobalis authored Feb 20, 2025
1 parent 4be11b2 commit b083afa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog/266.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Changed the default rank method for `sunkit_image.radial.rhef` from 'numpy' to 'scipy'.
1 change: 1 addition & 0 deletions changelog/266.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added a method called "none" to `sunkit_image.radial.rhef` to allow for the bypassing of the radial filter.
11 changes: 8 additions & 3 deletions sunkit_image/radial.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,20 @@ def _percentile_ranks_numpy_inplace(arr):
arr[sorted_indices] = np.arange(1, len(arr) + 1)
return arr / float(len(arr))

# Select the sort method
def _pass_without_filtering(arr):
return arr

method = method.lower()
if method == "inplace":
ranking_func = _percentile_ranks_numpy_inplace
elif method == "numpy":
ranking_func = _percentile_ranks_numpy
elif method == "scipy":
ranking_func = _percentile_ranks_scipy
elif method == "none":
ranking_func = _pass_without_filtering
else:
msg = f"{method} is invalid. Allowed values are 'inplace', 'numpy', 'scipy'"
msg = f"{method} is invalid. Allowed values are 'inplace', 'numpy', 'scipy', or 'none'"
raise NotImplementedError(msg)
return ranking_func

Expand Down Expand Up @@ -651,7 +656,7 @@ def rhef(
radial_bin_edges=None,
application_radius=0 * u.R_sun,
upsilon=0.35,
method="numpy",
method="scipy",
vignette=None,
progress=False,
fill=np.nan,
Expand Down

0 comments on commit b083afa

Please sign in to comment.