Example #1
0
def fit_spectrum(epos, pk_data, peak_height_fraction, bg_rois):
    import initElements_P3
    import peak_param_determination as ppd

    # Define peaks to range
    ed = initElements_P3.initElements()

    # Define which peaks to use for CSR calcs
    Ga1p_m2qs = [ed['Ga'].isotopes[69][0], ed['Ga'].isotopes[71][0]]
    Ga2p_m2qs = [ed['Ga'].isotopes[69][0] / 2, ed['Ga'].isotopes[71][0] / 2]

    Ga1p_idxs = [np.argmin(np.abs(m2q - pk_data['m2q'])) for m2q in Ga1p_m2qs]
    Ga2p_idxs = [np.argmin(np.abs(m2q - pk_data['m2q'])) for m2q in Ga2p_m2qs]

    # Determine the global background
    glob_bg_param = ppd.get_glob_bg(epos['m2q'], rois=bg_rois)

    # Range the peaks
    pk_params = ppd.get_peak_ranges(epos,
                                    pk_data['m2q'],
                                    peak_height_fraction=peak_height_fraction,
                                    glob_bg_param=0)

    return (pk_params, glob_bg_param, Ga1p_idxs, Ga2p_idxs)
Example #2
0
#                            (3,     1,      0,  (ed['Ga'].isotopes[71][0]+3*ed['N'].isotopes[14][0])/2),
#                            (0,     1,      0,  ed['Ga'].isotopes[69][0]),
#                            (0,     1,      0,  ed['Ga'].isotopes[71][0]),
#                            (0,     1,      0,  ed['Ga'].isotopes[71][0]+ed['H'].isotopes[1][0])
#                            ],
#                            dtype=[('N','i4'),('Ga','i4'),('Al','i4'),('m2q','f4')] )

# Define which peaks to use for CSR calcs
Ga1p_m2qs = [ed['Ga'].isotopes[69][0], ed['Ga'].isotopes[71][0]]
Ga2p_m2qs = [ed['Ga'].isotopes[69][0] / 2, ed['Ga'].isotopes[71][0] / 2]

Ga1p_idxs = [np.argmin(np.abs(m2q - pk_data['m2q'])) for m2q in Ga1p_m2qs]
Ga2p_idxs = [np.argmin(np.abs(m2q - pk_data['m2q'])) for m2q in Ga2p_m2qs]

# Range the peaks
pk_params = ppd.get_peak_ranges(epos, pk_data['m2q'], peak_height_fraction=0.1)

# Determine the global background
glob_bg_param = ppd.get_glob_bg(epos['m2q'])

# Count the peaks, local bg, and global bg
cts = ppd.do_counting(epos, pk_params, glob_bg_param)

# Test for peak S/N and throw out craptastic peaks
B = np.max(np.c_[cts['local_bg'][:, None], cts['global_bg'][:, None]], 1)[:,
                                                                          None]
T = cts['total'][:, None]
S = T - B
std_S = np.sqrt(T + B)
# Make up a threshold for peak detection... for the most part this won't matter
# since weak peaks don't contribute to stoichiometry much... except for Mg!