Skip to content
Merged
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
18 changes: 9 additions & 9 deletions hexrdgui/calibration/polarview.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

from hexrd.rotations import mapAngle
from hexrd.utils.decorators import memoize
from hexrd.utils.warnings import ignore_warnings

from hexrd import constants as ct
from hexrd.xrdutil import _project_on_detector_plane, _project_on_detector_cylinder
from hexrd import instrument
Expand Down Expand Up @@ -519,13 +517,15 @@ def apply_intensity_corrections(self, img: np.ndarray) -> np.ndarray:

stacked = np.ma.stack(output.values()).filled(np.nan)

# It's okay to have all nan-slices here, but it produces a warning.
# Just ignore the warning.
with ignore_warnings(RuntimeWarning):
# In case there are overlapping detectors, we do nanmean for
# the intensities instead of nansum. This would produce a
# somewhat more reasonable intensity.
correction_field = np.nanmean(stacked, axis=0)
# In case there are overlapping detectors, we do nanmean for
# the intensities instead of nansum. All-NaN slices are expected
# (detector gaps) and should produce NaN in the correction field.
# We compute the mean manually instead of calling np.nanmean()
# because the "Mean of empty slice" RuntimeWarning it emits could
# not be reliably suppressed on all platforms (see PR #1941).
valid_count = np.sum(~np.isnan(stacked), axis=0)
with np.errstate(invalid='ignore', divide='ignore'):
correction_field = np.nansum(stacked, axis=0) / valid_count

img *= correction_field

Expand Down
Loading