Commit 75a4b336 authored by Viktor Reshniak's avatar Viktor Reshniak
Browse files

change mask rebinning in `def fit`

parent 869ac61f
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -1802,12 +1802,14 @@ class PeakHistogram(object):
		fit_points = fit_points.reshape((-1,self.ndims))

		# self.detector_mask = None
		# if self.detector_mask is None:
		# 	detector_mask = fit_data==fit_data
		if self.detector_mask is not None:
			detector_mask = rebin_histogram(self.detector_mask.astype(int), bins)>0
			fit_data   = fit_data[detector_mask.ravel()]
			fit_points = fit_points[detector_mask.ravel(),:]
			if np.any(np.array([len(b) for b in bins])!=self.shape):
				# all subbins must be in detector mask, 0.99 to account for numerical error
				mask = rebin_histogram(self.detector_mask.astype(float), bins, mode='density') > 0.99
			else:
				mask = self.detector_mask
			fit_data   = fit_data[mask.ravel()]
			fit_points = fit_points[mask.ravel(),:]

		###########################################################################
		# initialization and bounds on parameters