trident.spectrum_generator.SpectrumGenerator.add_noise_vector

SpectrumGenerator.add_noise_vector(noise)[source]

Add an array of noise to the spectrum.

Parameters

Noise:

array of floats

The array of noise values to be added to the spectrum. This array must be of the same size as the flux array.

Example

>>> import numpy as np
>>> import trident
>>> ray = trident.make_onezone_ray(column_densities={'H_p0_number_density':1e21})
>>> sg = trident.SpectrumGenerator(lambda_min=1200, lambda_max=1300, dlambda=0.1)
>>> sg.make_spectrum(ray, lines=['Ly a'])
>>> my_noise = np.random.normal(loc=0.0, scale=0.1, size=sg.flux_field.size)
>>> sg.add_noise_vector(my_noise)
>>> sg.plot_spectrum('spec_noise.png')