Example #1
0
def get_abs_corr_zeta(
        weight_percent, mass_thickness,
        take_off_angle):  # take_off_angle, temporary value for testing
    """
    Calculate absorption correction terms.

    Parameters
    ----------
    weight_percent: list of signal
        Composition in weight percent.
    mass_thickness: signal
        Density-thickness map in kg/m^2
    take_off_angle: float
        X-ray take-off angle in degrees.
    """
    from hyperspy.misc import material

    toa_rad = np.radians(take_off_angle)
    csc_toa = 1.0 / np.sin(toa_rad)
    # convert from cm^2/g to m^2/kg
    mac = stack(
        material.mass_absorption_mixture(weight_percent=weight_percent),
        show_progressbar=False) * 0.1
    acf = mac.data * mass_thickness.data * csc_toa
    acf = acf / (1.0 - np.exp(-(acf)))

    return acf
Example #2
0
def get_abs_corr_cross_section(
        composition, number_of_atoms, take_off_angle,
        probe_area):  # take_off_angle, temporary value for testing
    """
    Calculate absorption correction terms.

    Parameters
    ----------
    number_of_atoms: list of signal
        Stack of maps with number of atoms per pixel.
    take_off_angle: float
        X-ray take-off angle in degrees.
    """
    from hyperspy.misc import material

    toa_rad = np.radians(take_off_angle)
    Av = constants.Avogadro
    elements = [
        intensity.metadata.Sample.elements[0] for intensity in number_of_atoms
    ]
    atomic_weights = np.array([
        elements_db[element]['General_properties']['atomic_weight']
        for element in elements
    ])

    number_of_atoms = stack(number_of_atoms).data

    #calculate the total_mass per pixel, or mass thicknessself.
    total_mass = np.zeros_like(number_of_atoms[0], dtype='float')
    for i, (weight) in enumerate(atomic_weights):
        total_mass += (number_of_atoms[i] * weight / Av / probe_area / 1E-15)

    # determine mass absorption coefficients and convert from cm^2/g to m^2/atom.
    mac = stack(
        material.mass_absorption_mixture(
            weight_percent=material.atomic_to_weight(composition))) * 0.1

    acf = np.zeros_like(number_of_atoms)
    constant = 1 / (Av * math.sin(toa_rad) * probe_area * 1E-16)

    #determine an absorption coeficcient per element per pixel.
    for i, (weight) in enumerate(atomic_weights):
        expo = (mac.data[i] * total_mass * constant)
        acf[i] = expo / (1 - math.e**(-expo))

    return acf