def get_counts(self, data, net=False):
        bgr_width = int(self.bgr_width)
        ilmin = max((self.left - bgr_width), 0)
        irmax = min((self.right + bgr_width), len(data)-1) + 1
        bgr_counts = np.concatenate((data[ilmin:self.left],
                                     data[self.right+1:irmax])).mean()

        #total and net cts
        self.total  = data[self.left:self.right+1].sum()
        self.net    = self.total - bgr_counts*(self.right-self.left)
        out = self.total
        if net:
            out = self.net
        return out
calculate total and net counts for a spectra
dataset/ETHPy150Open xraypy/xraylarch/plugins/xrf/roi.py/ROI.get_counts