Skip to content

Commit

Permalink
Use "is np.ma.masked" when interpreting fwhm column
Browse files Browse the repository at this point in the history
  • Loading branch information
drvdputt committed Jul 9, 2024
1 parent da9ed24 commit 4e16008
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pahfit/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def amp_guess(row, fwhm):
if calc_line_fwhm:
for row_index in np.where(self.features["kind"] == "line")[0]:
row = self.features[row_index]
if np.ma.is_masked(row["fwhm"]):
if row["fwhm"] is np.ma.masked:
self.features[row_index]["fwhm"] = (
line_fwhm_guess(row),
np.nan,
Expand Down Expand Up @@ -902,8 +902,7 @@ def cleaned(features_tuple3):

elif kind == "line":
# be careful with lines that have masked FWHM values here
fwhm_masked = row['fwhm'].ndim == 0
if use_instrument_fwhm or fwhm_masked:
if use_instrument_fwhm or row['fwhm'] is np.ma.masked:
# One caveat here: redshift. We do the necessary
# adjustment as follows : 1. shift to observed wav;
# 2. evaluate fwhm at oberved wav; 3. shift back to
Expand All @@ -922,9 +921,14 @@ def cleaned(features_tuple3):
# decide if scalar (fixed) or tuple (fitted fwhm
# between upper and lower fwhm limits, happens in
# case of overlapping instruments)
if np.ma.is_masked(fwhm):
fwhm = fwhm[0]
if calculated_fwhm[1] is np.ma.masked:
fwhm = calculated_fwhm[0]
else:
fwhm = calculated_fwhm

else:
# if instrument model is not to be used, just take
# the value as is specified in the Features table
fwhm = cleaned(row["fwhm"])

self.fitter.add_feature_line(
Expand Down

0 comments on commit 4e16008

Please sign in to comment.