hyperspy.api.data#

The hyperspy.api.data module includes synthetic data signal.

hyperspy.api.data.atomic_resolution_image()#

Get an artificial atomic resolution image.

Returns:
Signal2D

Examples

>>> s = hs.data.atomic_resolution_image()
>>> s.plot()
hyperspy.api.data.luminescence_signal(navigation_dimension=0, uniform=False, add_baseline=False, add_noise=True, random_state=None)#

Get an artificial luminescence signal in wavelength scale (nm, uniform) or energy scale (eV, non-uniform), simulating luminescence data recorded with a diffracting spectrometer. Some random noise is also added to the spectrum, to simulate experimental noise.

Parameters:
navigation_dimensionint

The navigation dimension(s) of the signal. 0 = single spectrum, 1 = linescan, 2 = spectral map etc…

uniformbool

return uniform (wavelength) or non-uniform (energy) spectrum

add_baselinebool

If true, adds a constant baseline to the spectrum. Conversion to energy representation will turn the constant baseline into inverse powerlaw.

add_noisebool

If True, add noise to the signal. See note to seed the noise to generate reproducible noise.

random_stateNone, int or numpy.random.Generator, default None

Random seed used to generate the data.

Returns:
Signal1D

Examples

>>> import hyperspy.api as hs
>>> s = hs.data.luminescence_signal()
>>> s.plot()

With constant baseline

>>> s = hs.data.luminescence_signal(uniform=True, add_baseline=True)
>>> s.plot()

To make the noise the same for multiple spectra, which can be useful for testing fitting routines

>>> s1 = hs.data.luminescence_signal(random_state=10)
>>> s2 = hs.data.luminescence_signal(random_state=10)
>>> print((s1.data == s2.data).all())
True

2D map

>>> s = hs.data.luminescence_signal(navigation_dimension=2)
>>> s.plot()
hyperspy.api.data.two_gaussians(add_noise=True, return_model=False)#

Create synthetic data consisting of two Gaussian functions with random centers and area

Parameters:
add_noisebool

If True, add noise to the signal.

return_modelbool

If True, returns the model in addition to the signal.

Returns:
BaseSignal or tuple

Returns tuple when return_model=True.

hyperspy.api.data.wave_image(angle=45, wavelength=10, shape=(256, 256), add_noise=True, random_state=None)#

Returns a wave image generated using the sinus function.

Parameters:
anglefloat, optional

The angle in degree.

wavelengthfloat, optional

The wavelength the wave in pixel. The default is 10

shapetuple of float, optional

The shape of the data. The default is (256, 256).

add_noisebool

If True, add noise to the signal. See note to seed the noise to generate reproducible noise.

random_stateNone, int or numpy.random.Generator, default None

Random seed used to generate the data.

Returns:
Signal2D