Skip to content

Commit

Permalink
a/e and energy cal stuff (#585)
Browse files Browse the repository at this point in the history
* add check on fwhm plot nan lims

* fix error prop and mean plot
  • Loading branch information
ggmarshall authored May 31, 2024
1 parent 63dd3dc commit ddd4414
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/pygama/pargen/AoE_cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,10 +718,9 @@ def get_survival_fraction(
surv_err = surv_errs["n_sig"]

pc_n = ct_n + surv_n
pc_err = np.sqrt(surv_err**2 + ct_err**2)

sf = (surv_n / pc_n) * 100
err = sf * np.sqrt((pc_err / pc_n) ** 2 + (surv_err / surv_n) ** 2)
err = sf * np.sqrt((ct_err / pc_n**2) ** 2 + (surv_err / pc_n**2) ** 2)
return sf, err, cut_pars, surv_pars


Expand Down Expand Up @@ -835,10 +834,9 @@ def compton_sf(cut_param, low_cut_val, high_cut_val=None, mode="greater", dt_mas
surv_err = np.sqrt(len(cut_param[mask]))

pc_n = ct_n + surv_n
pc_err = np.sqrt(surv_err**2 + ct_err**2)

sf = (surv_n / pc_n) * 100
err = sf * np.sqrt((pc_err / pc_n) ** 2 + (surv_err / surv_n) ** 2)
err = sf * np.sqrt((ct_err / pc_n**2) ** 2 + (surv_err / pc_n**2) ** 2)

return {
"low_cut": low_cut_val,
Expand Down Expand Up @@ -1954,8 +1952,8 @@ def plot_aoe_mean_time(
datetime.strptime(tstamp, "%Y%m%dT%H%M%SZ")
for tstamp in aoe_class.cal_dicts
],
y1=np.array(grouped_means) - 0.2 * np.array(aoe_class.timecorr_df["res"]),
y2=np.array(grouped_means) + 0.2 * np.array(aoe_class.timecorr_df["res"]),
y1=np.array(grouped_means) - 0.2 * np.array(aoe_class.timecorr_df["sigma"]),
y2=np.array(grouped_means) + 0.2 * np.array(aoe_class.timecorr_df["sigma"]),
color="green",
alpha=0.2,
)
Expand All @@ -1964,8 +1962,8 @@ def plot_aoe_mean_time(
datetime.strptime(tstamp, "%Y%m%dT%H%M%SZ")
for tstamp in aoe_class.cal_dicts
],
y1=np.array(grouped_means) - 0.4 * np.array(aoe_class.timecorr_df["res"]),
y2=np.array(grouped_means) + 0.4 * np.array(aoe_class.timecorr_df["res"]),
y1=np.array(grouped_means) - 0.4 * np.array(aoe_class.timecorr_df["sigma"]),
y2=np.array(grouped_means) + 0.4 * np.array(aoe_class.timecorr_df["sigma"]),
color="yellow",
alpha=0.2,
)
Expand Down
2 changes: 2 additions & 0 deletions src/pygama/pargen/energy_cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1719,6 +1719,8 @@ def plot_eres_fit(self, data, erange=(200, 2700), figsize=(12, 8), fontsize=12):
ax1.plot(qbb_line_vx, qbb_line_vy, lw=1, c="r", ls="--")

ax1.set_xlim(erange)
if np.isnan(low_lim):
low_lim = 0
ax1.set_ylim([low_lim, None])
ax1.set_ylabel("FWHM energy resolution (keV)")
for _, fwhm_dict in fwhm_dicts.items():
Expand Down

0 comments on commit ddd4414

Please sign in to comment.