hyperspy.api.data#

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

hyperspy.api.data.atomic_resolution_image(size=512, spacing=0.2, column_radius=0.05, rotation_angle=0, pixel_size=0.015, add_noise=False, random_state=None)#

Make an artificial atomic resolution image. The atomic columns are modelled with Gaussian functions.

Parameters:
sizeint or tuple of int, default=512

The number of pixels of the image in horizontal and vertical directions. If int, the size is the same in both directions.

spacingfloat or tuple of float, default=14

The spacing between the atomic columns in horizontal and vertical directions in nanometer.

column_radiusfloat, default=0.05

The radius of the atomic column, i. e. the width of the Gaussian in nanometer.

rotation_angleint or float, default=0

The rotation of the lattice in degree.

pixel_sizefloat, default=0.015

The pixel size in nanometer.

add_noisebool

If True, add noise to the signal. Use random_state 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

Examples

>>> import hyperspy.api as hs
>>> 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. Use random_state 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. Use random_state 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