示例#1
0
def add_gaussv_noise_ic(
    ic: IonChromatogram,
    scale: int,
    cutoff: int,
    prop: float,
):
    """
	Adds noise to an ic. The noise value is drawn from a normal
	distribution, the scale of this distribution depends on the
	value of the ic at the point where the noise is being added

	:param ic: The IonChromatogram
	:param cutoff: The level below which the intensity of the ic at that point
		has no effect on the scale of the noise distribution
	:param scale: The scale of the normal distribution for ic values below the cutoff
		is modified for values above the cutoff
	:param prop: For ic values above the cutoff, the scale is multiplied by the ic
		value multiplied by ``prop``.

	:author: Sean O'Callaghan
	"""  # noqa: D400

    noise = numpy.zeros(len(ic))

    i_array = ic.intensity_array
    # time_list = ic.time_list

    for i in range(len(ic)):
        if i_array[i] < cutoff:
            noise[i] = numpy.random.normal(0.0, scale, 1)
        else:
            noise[i] = numpy.random.normal(0.0, scale * i_array[i] * prop, 1)

    i_array_with_noise = noise + i_array
    ic.intensity_array = i_array_with_noise
示例#2
0
def add_gaussc_noise_ic(ic: IonChromatogram, scale: float):
    """
	Adds noise drawn from a normal distribution with constant scale to an ion chromatogram.

	:param ic: The ion Chromatogram.
	:param scale: The scale of the normal distribution.

	:author: Sean O'Callaghan
	"""

    noise = numpy.random.normal(0.0, scale, (len(ic)))

    i_array_with_noise = ic.intensity_array + noise
    ic.intensity_array = i_array_with_noise