@_log<EOL><INDENT>def bkg_calc_weightedmean(self, analytes=None, weight_fwhm=None,<EOL>n_min=<NUM_LIT:20>, n_max=None, cstep=None,<EOL>bkg_filter=False, f_win=<NUM_LIT:7>, f_n_lim=<NUM_LIT:3>, focus_stage='<STR_LIT>'):<DEDENT>
if analytes is None:<EOL><INDENT>analytes = self.analytes<EOL>self.bkg = Bunch()<EOL><DEDENT>elif isinstance(analytes, str):<EOL><INDENT>analytes = [analytes]<EOL><DEDENT>if weight_fwhm is None:<EOL><INDENT>weight_fwhm = <NUM_LIT>  <EOL><DEDENT>self.get_background(n_min=n_min, n_max=n_max,<EOL>bkg_filter=bkg_filter,<EOL>f_win=f_win, f_n_lim=f_n_lim, focus_stage=focus_stage)<EOL>if '<STR_LIT>' not in self.bkg.keys():<EOL><INDENT>if cstep is None:<EOL><INDENT>cstep = weight_fwhm / <NUM_LIT:20><EOL><DEDENT>elif cstep > weight_fwhm:<EOL><INDENT>warnings.warn("<STR_LIT>" +<EOL>"<STR_LIT>")<EOL><DEDENT>bkg_t = np.linspace(<NUM_LIT:0>,<EOL>self.max_time,<EOL>self.max_time // cstep)<EOL>self.bkg['<STR_LIT>'] = Bunch()<EOL>self.bkg['<STR_LIT>']['<STR_LIT>'] = bkg_t<EOL><DEDENT>mean, std, stderr = gauss_weighted_stats(self.bkg['<STR_LIT>'].uTime,<EOL>self.bkg['<STR_LIT>'].loc[:, analytes].values,<EOL>self.bkg['<STR_LIT>']['<STR_LIT>'],<EOL>fwhm=weight_fwhm)<EOL>for i, a in enumerate(analytes):<EOL><INDENT>self.bkg['<STR_LIT>'][a] = {'<STR_LIT>': mean[i],<EOL>'<STR_LIT>': std[i],<EOL>'<STR_LIT>': stderr[i]}<EOL><DEDENT>
Background calculation using a gaussian weighted mean.

Parameters
----------
analytes : str or iterable
    Which analyte or analytes to calculate.
weight_fwhm : float
    The full-width-at-half-maximum of the gaussian used
    to calculate the weighted average.
n_min : int
    Background regions with fewer than n_min points
    will not be included in the fit.
cstep : float or None
    The interval between calculated background points.
filter : bool
    If true, apply a rolling filter to the isolated background regions
    to exclude regions with anomalously high values. If True, two parameters
    alter the filter's behaviour:
f_win : int
    The size of the rolling window
f_n_lim : float
    The number of standard deviations above the rolling mean
    to set the threshold.
focus_stage : str
    Which stage of analysis to apply processing to. 
    Defaults to 'despiked' if present, or 'rawdata' if not. 
    Can be one of:
    * 'rawdata': raw data, loaded from csv file.
    * 'despiked': despiked data.
    * 'signal'/'background': isolated signal and background data.
      Created by self.separate, after signal and background
      regions have been identified by self.autorange.
    * 'bkgsub': background subtracted data, created by 
      self.bkg_correct
    * 'ratios': element ratio data, created by self.ratio.
    * 'calibrated': ratio data calibrated to standards, created by self.calibrate.