Skip to content

Commit

Permalink
Update bkg_coef array when degree changes
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Avery <[email protected]>
  • Loading branch information
psavery committed Sep 18, 2023
1 parent 555f3c1 commit 25814d3
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions hexrd/wppf/WPPF.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,23 @@ def initialize_bkg(self):
)
self._background.append(Spectrum(x=self._tth_list[i], y=yy))

@property
def bkgmethod(self):
return self._bkgmethod

@bkgmethod.setter
def bkgmethod(self, v):
self._bkgmethod = v
if "chebyshev" in v and hasattr(self, 'bkg_coef'):
degree = v["chebyshev"]
# In case the degree has changed, slice off any extra at the end,
# and in case it is less, pad with zeros.
if len(self.bkg_coef) > degree + 1:
self.bkg_coef = self.bkg_coef[:degree + 1]
elif len(self.bkg_coef) < degree + 1:
pad_width = (0, degree + 1 - len(self.bkg_coef))
self.bkg_coef = np.pad(self.bkg_coef, pad_width)

def chebyshevfit(self):
"""
03/08/2021 SS spectrum_expt is a list now. accounting
Expand Down Expand Up @@ -1763,6 +1780,23 @@ def initialize_bkg(self):
)
self._background.append(Spectrum(x=self._tth_list[i], y=yy))

@property
def bkgmethod(self):
return self._bkgmethod

@bkgmethod.setter
def bkgmethod(self, v):
self._bkgmethod = v
if "chebyshev" in v and hasattr(self, 'bkg_coef'):
degree = v["chebyshev"]
# In case the degree has changed, slice off any extra at the end,
# and in case it is less, pad with zeros.
if len(self.bkg_coef) > degree + 1:
self.bkg_coef = self.bkg_coef[:degree + 1]
elif len(self.bkg_coef) < degree + 1:
pad_width = (0, degree + 1 - len(self.bkg_coef))
self.bkg_coef = np.pad(self.bkg_coef, pad_width)

def chebyshevfit(self):
"""
03/08/2021 SS spectrum_expt is a list now. accounting
Expand Down

0 comments on commit 25814d3

Please sign in to comment.