Skip to content

Commit

Permalink
unfolder and fg method use remove negatives only, no fill
Browse files Browse the repository at this point in the history
This gave better results, see discussions in the PRs #110 and #113
  • Loading branch information
fzeiser authored and fzeiser committed Mar 19, 2020
1 parent 4461f06 commit 9edb485
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
10 changes: 4 additions & 6 deletions ompy/firstgeneration.py
Expand Up @@ -56,8 +56,6 @@ class FirstGeneration:
multiplicity_estimation (str): Selects which method should be used
for the multiplicity estimation. Can be either "statistical",
or "total". Default is "statistical".
window_size (int or np.ndarray): window_size for (fill and) remove
negatives on output. Defaults to 20.
statistical_upper (float): Threshold for upper limit in
`statistical` multiplicity estimation. Defaults to 430 keV.
statistical_lower (float): Threshold for lower limit in
Expand Down Expand Up @@ -87,7 +85,6 @@ class FirstGeneration:
def __init__(self):
self.num_iterations: int = 10
self.multiplicity_estimation: str = 'statistical'
self.window_size = 20

self.statistical_upper: float = 430.0 # MAMA ThresSta
self.statistical_lower: float = 200.0 # MAMA ThresTot
Expand Down Expand Up @@ -401,14 +398,15 @@ def allgen_from_primary(fg: Matrix,
return ag

def remove_negative(self, matrix: Matrix):
""" (Fill and) remove negative counts
""" Wrapper for Matrix.remove_negative()
Wrapper for Matrix.fill_and_remove_negative()
Put in as an extra method to facilitate replacing this by eg.
`fill_and_remove_negatve`
Args:
matrix: Input matrix
"""
matrix.fill_and_remove_negative(window_size=self.window_size)
matrix.remove_negative()


def normalize_rows(array: np.ndarray) -> np.ndarray:
Expand Down
10 changes: 4 additions & 6 deletions ompy/unfolder.py
Expand Up @@ -78,8 +78,6 @@ class Unfolder:
fluctuations. Defaults to 0.2
minimum_iterations (int, optional): Minimum number of iterations.
Defaults to 3.
window_size (int or np.ndarray): window_size for (fill and) remove
negatives on output. Defaults to 20.
use_compton_subtraction (bool, optional): Set usage of Compton
subtraction method. Defaults to `True`.
response_tab (DataFrame, optional): If `use_compton_subtraction=True`
Expand All @@ -105,7 +103,6 @@ def __init__(self, num_iter: int = 33, response: Optional[Matrix] = None):
self.num_iter = num_iter
self.weight_fluctuation: float = 0.2
self.minimum_iterations: int = 3
self.window_size = 20

self._R: Optional[Matrix] = response
self.raw: Optional[Matrix] = None
Expand Down Expand Up @@ -431,14 +428,15 @@ def compton_subtraction(self, unfolded: np.ndarray) -> np.ndarray:
return unfolded

def remove_negative(self, matrix: Matrix):
""" (Fill and) remove negative counts
""" Wrapper for Matrix.remove_negative()
Wrapper for Matrix.fill_and_remove_negative()
Put in as an extra method to facilitate replacing this by eg.
`fill_and_remove_negatve`
Args:
matrix: Input matrix
"""
matrix.fill_and_remove_negative(window_size=self.window_size)
matrix.remove_negative()


def shift(counts_in, E_array_in, energy_shift):
Expand Down

0 comments on commit 9edb485

Please sign in to comment.