-
Notifications
You must be signed in to change notification settings - Fork 16
Use cases code & pseudocode
Brian Plimley edited this page Mar 27, 2017
·
9 revisions
What does energy calibration look like?
import becquerel as bq
cs_spec = bq.Spectrum.from_file("Cs137.spe")
am_spec = bq.Spectrum.from_file("Am241.spe")
k_spec = bq.Spectrum.from_file("K40.spe")
cs_ROI = [1800, 1816]
am_ROI = [158, 170]
k_ROI = [3981, 3999]
cs_kev = 661.66
am_kev = 59.541
k_kev = 1460.83
cs_peak = bq.peaks.PeakFeature(cs_spec, cs_ROI, cal_energy_kev=cs_kev)
am_peak = bq.peaks.PeakFeature(am_spec, am_ROI, cal_energy_kev=am_kev)
# Generate fit calibration
cal = bq.energycal.FitPolyCal(peaks_list=[cs_peak, am_peak], order=1)
# apply to spectra
cs_spec.calibrate(cal)
am_spec.calibrate(cal)
# add a calibration point
k_peak = bq.peaks.PeakFeature(k_spec, k_ROI, cal_energy_kev=k_kev)
cal.add_peak(k_peak) # refit=True by default
# use it directly
cal.ch2kev(2345)
# 858.76
- Multiple inheritance is complicated
- Does every peak need to have a reference of the entire spectrum it came from? Can it be more self-contained?
cs_peak = bq.peaks.Fitter.get_feature(
cs_spec, cs_ROI, 'gauss+linear', cal_energy=cs_kev)
am_peak = bq.peaks.Fitter.get_feature(
am_spec, am_ROI, 'gauss+linear', cal_energy=am_kev)
cal = bq.energycal.EnergyCal.from_features([cs_peak, am_peak], order=1)
...