Skip to content

Commit

Permalink
refactor: use new accessors and attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
kmnhan committed Apr 1, 2024
1 parent cb9aa01 commit 8e1dee2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/erlab/analysis/fit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ def guess(self, data, x, **kwargs):
temp = 30
if isinstance(data, xr.DataArray):
try:
temp = data.S.temp
except AttributeError:
temp = data.attrs["temp_sample"]
except KeyError:
pass

pars[f"{self.prefix}center"].set(value=efermi, min=x.min(), max=x.max())
Expand Down Expand Up @@ -338,7 +338,7 @@ def guess(self, data, eV, alpha, negative=False, **kwargs):
)
pars[f"{self.prefix}const_bkg"].set(value=dos0)
pars[f"{self.prefix}lin_bkg"].set(value=dos1)
pars[f"{self.prefix}temp"].set(value=data.S.temp)
pars[f"{self.prefix}temp"].set(value=data.attrs["temp_sample"])

return lmfit.models.update_param_vals(pars, self.prefix, **kwargs)

Expand Down
12 changes: 6 additions & 6 deletions src/erlab/analysis/gold.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def edge(
model_cls = StepEdgeModel
else:
if temp is None:
temp = gold.S.temp
temp = gold.attrs["temp_sample"]
params = {
"temp": dict(value=temp, vary=vary_temp),
}
Expand Down Expand Up @@ -183,7 +183,7 @@ def _plot_gold_fit(fig, gold, angle_range, eV_range, center_arr, center_stderr,
plt.tick_params("x", labelbottom=False)
ax2 = fig.add_subplot(gs[1, 1], sharex=ax1)

gold.S.plot(ax=ax0, cmap="copper", gamma=0.5)
gold.qplot(ax=ax0, cmap="copper", gamma=0.5)
rect = mpatches.Rectangle(
(angle_range[0], eV_range[0]),
np.diff(angle_range)[0],
Expand Down Expand Up @@ -392,7 +392,7 @@ def resolution(
edc_avg = gold_roi.mean("alpha").sel(eV=slice(*eV_range_fit))

params = dict(
temp=dict(value=gold.S.temp, vary=False),
temp=dict(value=gold.attrs["temp_sample"], vary=False),
resolution=dict(value=0.1, vary=True, min=0),
)
fit = ExtendedAffineBroadenedFD().guess_fit(
Expand All @@ -401,7 +401,7 @@ def resolution(
if plot:
plt.show()
ax = plt.gca()
gold_corr.S.plot(ax=ax, cmap="copper", gamma=0.5)
gold_corr.qplot(ax=ax, cmap="copper", gamma=0.5)
rect = mpatches.Rectangle(
(angle_range[0], eV_range_fit[0]),
np.diff(angle_range)[0],
Expand Down Expand Up @@ -438,7 +438,7 @@ def resolution_roi(
edc_avg = gold_roi.mean("alpha").sel(eV=slice(*eV_range))

params = dict(
temp=dict(value=gold_roi.S.temp, vary=not fix_temperature),
temp=dict(value=gold_roi.attrs["temp_sample"], vary=not fix_temperature),
resolution=dict(value=0.1, vary=True, min=0),
)
fit = ExtendedAffineBroadenedFD().guess_fit(
Expand All @@ -449,7 +449,7 @@ def resolution_roi(
)
if plot:
ax = plt.gca()
gold_roi.S.plot(ax=ax, cmap="copper", gamma=0.5)
gold_roi.qplot(ax=ax, cmap="copper", gamma=0.5)
ax.fill_between(
gold_roi.alpha,
eV_range[0],
Expand Down

0 comments on commit 8e1dee2

Please sign in to comment.