Skip to content

Commit

Permalink
default to nan outside of bounds, or allow user to select value
Browse files Browse the repository at this point in the history
  • Loading branch information
GillySpace27 authored and nabobalis committed Oct 29, 2024
1 parent f4a8983 commit 9dd000d
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions sunkit_image/radial.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ def nrgf(
width_function_kwargs=None,
application_radius=1 * u.R_sun,
progress=True,
fill=np.nan,
):
"""
Implementation of the normalizing radial gradient filter (NRGF).
Expand Down Expand Up @@ -270,6 +271,9 @@ def nrgf(
Defaults to 1 solar radii.
progress : ``bool``, optional
Show a progressbar while computing
fill : ``any``, optional
The value to be placed outside of the bounds of the algorithm
Defaults to NAN.
Returns
-------
Expand Down Expand Up @@ -310,7 +314,7 @@ def nrgf(
)

# Storage for the filtered data
data = np.zeros_like(smap.data)
data = np.ones_like(smap.data) * fill

# Calculate the filter value for each radial bin.
for i in tqdm(range(radial_bin_edges.shape[1]), desc="NRGF: ", disable=not progress):
Expand Down Expand Up @@ -399,6 +403,7 @@ def fnrgf(
application_radius=1 * u.R_sun,
number_angular_segments=130,
progress=True,
fill=np.nan,
):
"""
Implementation of the fourier normalizing radial gradient filter (FNRGF).
Expand Down Expand Up @@ -448,6 +453,9 @@ def fnrgf(
Defaults to 130.
progress : ``bool``, optional
Show a progressbar while computing
fill : ``any``, optional
The value to be placed outside of the bounds of the algorithm
Defaults to NAN.
Returns
-------
Expand Down Expand Up @@ -486,7 +494,7 @@ def fnrgf(
nbins = radial_bin_edges.shape[1]

# Storage for the filtered data
data = np.zeros_like(smap.data)
data = np.ones_like(smap.data) * fill

# Iterate over each circular ring
for i in tqdm(range(nbins), desc="FNRGF: ", disable=not progress):
Expand Down Expand Up @@ -648,6 +656,7 @@ def rhef(
method="numpy",
vignette=None,
progress=True,
fill=np.nan,
):
"""
Implementation of the Radial Histogram Equalizing Filter (RHEF).
Expand Down Expand Up @@ -680,7 +689,9 @@ def rhef(
Radius beyond which pixels will be set to NAN. Defaults to None, must be in units that are compatible with "R_sun" as the value will be transformed.
progress : bool, optional
If True, display a progress bar during the filtering process. Defaults to True.
fill : ``any``, optional
The value to be placed outside of the bounds of the algorithm
Defaults to NAN.
Returns
-------
`sunpy.map.Map`
Expand All @@ -697,7 +708,7 @@ def rhef(

radial_bin_edges, map_r = find_radial_bin_edges(smap, radial_bin_edges)

data = np.zeros_like(smap.data)
data = np.ones_like(smap.data) * fill

# Select the ranking method
ranking_func = _select_rank_method(method)
Expand Down

0 comments on commit 9dd000d

Please sign in to comment.