#NEWLINE# @ ValidateLarchPlugin #NEWLINE# def xrf_background( energy , counts = None , group = None , width = 4 , compress = 2 , exponent = 2 , slope = None , _larch = None ) : #NEWLINE# #INDENT# 'fit background for XRF spectra.  Arguments:\n\n    xrf_background(energy, counts=None, group=None, width=4,\n                   compress=2, exponent=2, slope=None)\n\n    Arguments\n    ---------\n    energy     array of energies OR an MCA group.  If an MCA group,\n               it will be used to give ``counts`` and ``mca`` arguments\n    counts     array of XRF counts (or MCA.counts)\n    group      group for outputs\n\n    width      full width (in keV) of the concave down polynomials\n               for when its full width is 100 counts. default = 4\n\n    compress   compression factor to apply to spectra. Default is 2.\n\n    exponent   power of polynomial used.  Default is 2, should be even.\n    slope      channel to energy conversion, from energy calibration\n               (default == None --> found from input energy array)\n\n    outputs (written to group)\n    -------\n    bgr       background array\n    bgr_info  dictionary of parameters used to calculate background\n    ' #NEWLINE# if isLarchMCAGroup ( energy ) : #NEWLINE# #INDENT# group = energy #NEWLINE# counts = group . counts #NEWLINE# energy = group . energy #NEWLINE# #UNINDENT# if ( slope is None ) : #NEWLINE# #INDENT# slope = ( ( energy [ ( - 1 ) ] - energy [ 0 ] ) / len ( energy ) ) #NEWLINE# #UNINDENT# xbgr = XRFBackground ( counts , width = width , compress = compress , exponent = exponent , slope = slope ) #NEWLINE# if ( group is not None ) : #NEWLINE# #INDENT# group . bgr = xbgr . bgr #NEWLINE# group . bgr_info = xbgr . parinfo