

@ValidateLarchPlugin
def f1f2(z, energies, width=None, edge=None, _larch=None):
    "Return anomalous scattering factors f1, f2 from Cromer-Liberman\n\n    Look-up and return f1, f2 for an element and array of energies\n    from Cromer-Liberman (Cowan-Brennan implementation)\n\n    Parameters\n    ----------\n    z:         atomic number of element\n    energies:  array of x-ray energies (in eV)\n    width:     width used to convolve values with lorentzian profile\n    edge:      x-ray edge ('K', 'L3', etc) used to lookup energy\n               width for convolution.\n\n    Returns:\n    ---------\n    f1, f2:    anomalous scattering factors\n\n    "
    global CLLIB
    if (CLLIB is None):
        CLLIB = get_dll('cldata')
    en = as_ndarray(energies)
    if (not isinstance(z, int)):
        z = atomic_number(z, _larch=_larch)
        if (z is None):
            return None
    if (z > 92):
        print('Cromer-Liberman data not available for Z>92')
        return
    if ((edge is not None) or ((width is not None) and (_larch is not None))):
        natwid = core_width(element=z, edge=edge, _larch=_larch)
        if ((width is None) and (z not in (None, []))):
            width = natwid
    if (width is not None):
        e_extra = int((width * 80.0))
        estep = (en[1:] - en[:(- 1)]).min()
        emin = (min(en) - e_extra)
        emax = (max(en) + e_extra)
        npts = (1 + (abs(((emax - emin) + (estep * 0.02))) / abs(estep)))
        en = np.linspace(emin, emax, npts)
        nk = int((e_extra / estep))
        sig = (width / 2.0)
        lor = ((1.0 / (1 + (((np.arange(((2 * nk) + 1)) - (nk * 1.0)) / sig) ** 2))) / (np.pi * sig))
        scale = lor.sum()
    npts = len(en)
    p_z = ctypes.pointer(ctypes.c_int(int(z)))
    p_npts = ctypes.pointer(ctypes.c_int(npts))
    p_en = (npts * ctypes.c_double)()
    p_f1 = (npts * ctypes.c_double)()
    p_f2 = (npts * ctypes.c_double)()
    for i in range(npts):
        p_en[i] = en[i]
    nout = CLLIB.f1f2(p_z, p_npts, p_en, p_f1, p_f2)
    f1 = np.array([i for i in p_f1[:]])
    f2 = np.array([i for i in p_f2[:]])
    if (width is not None):
        f1 = (np.interp(energies, en, convolve(f1, lor)[nk:(- nk)]) / scale)
        f2 = (np.interp(energies, en, convolve(f2, lor)[nk:(- nk)]) / scale)
    return (f1, f2)

dataset/ETHPy150Open xraypy/xraylarch/plugins/xray/cromer_liberman.py f1f2/VarMisuse@165/443 `natwid`->`z`