hyperspy.utils package

Submodules

hyperspy.utils.eds module

hyperspy.utils.markers module

Markers that can be added to Signal plots.

Example

>>> import scipy.misc
>>> im = hs.signals.Signal2D(scipy.misc.ascent())
>>> m = hs.plot.markers.rectangle(x1=150, y1=100, x2=400, y2=400, color='red')
>>> im.add_marker(m)

hyperspy.utils.material module

hyperspy.utils.model module

Model functions.

The model module contains the following submodules:

components1D
1D components for HyperSpy model.
components2D
2D components for HyperSpy model.

hyperspy.utils.model_selection module

hyperspy.utils.model_selection.AIC(model)

Calculates the Akaike information criterion

AIC = 2 k - 2 ln(L)

where L is the maximum likelihood function value, k is the number of free parameters.

hyperspy.utils.model_selection.AICc(model)
hyperspy.utils.model_selection.BIC(model)

Calculates the Bayesian information criterion

BIC = -2 * ln(L) + k * ln(n)

where L is the maximum likelihood function, k is the number of free parameters, and n is the number of data points (observations) / sample size.

hyperspy.utils.parallel_pool module

class hyperspy.utils.parallel_pool.ParallelPool(num_workers=None, ipython_kwargs=None, ipyparallel=None)

Bases: object

Creates a ParallelPool by either looking for a ipyparallel client and then creating a load_balanced_view, or by creating a multiprocessing pool

setup()

sets up the requested pool

sleep()

sleeps for the requested (or timeout) time

has_pool

Bool – Boolean if the pool is available and active.

pool

{ipyparallel.load_balanced_view, multiprocessing.Pool} – The pool object.

ipython_kwargs

dict – The dictionary with Ipyparallel connection arguments.

timeout

float – Timeout for either pool when waiting for results.

num_workers

int – The number of workers actually created (may be less than requested, but can’t be more).

timestep

float – Can be used as “ticks” to adjust CPU load when building upon this class.

is_ipyparallel

bool – If the pool is ipyparallel-based

is_multiprocessing

bool – If the pool is multiprocessing-based

has_pool

Returns bool if the pool is ready and set-up

is_ipyparallel

Returns bool if the pool is ipyparallel-based

is_multiprocessing

Returns bool if the pool is multiprocessing-based

setup(ipyparallel=None)

Sets up the pool.

Parameters:ipyparallel ({None, bool}) – if True, only tries to set up the ipyparallel pool. If False - only the multiprocessing. If None, first tries ipyparallel, and it does not succeed, then multiprocessing.
sleep(howlong=None)

Sleeps for the required number of seconds.

Parameters:howlong ({None, float}) – How long the pool should sleep for in seconds. If None (default), sleeps for “timestep”
timestep

hyperspy.utils.plot module

Plotting funtions.

Functions:

plot_spectra, plot_images
Plot multiple spectra/images in the same figure.
plot_signals
Plot multiple signals at the same time.
plot_histograms
Compute and plot the histograms of multiple signals in the same figure.

The plot module contains the following submodules:

markers
Markers that can be added to Signal plots.

hyperspy.utils.roi module

Region of interests (ROIs).

ROIs operate on BaseSignal instances and include widgets for interactive operation.

The following 1D ROIs are available:

Point1DROI
Single element ROI of a 1D signal.
SpanROI
Interval ROI of a 1D signal.

The following 2D ROIs are available:

Point2DROI
Single element ROI of a 2D signal.
RectangularROI
Rectagular ROI of a 2D signal.
CircleROI
(Hollow) circular ROI of a 2D signal
Line2DROI
Line profile of a 2D signal with customisable width.

hyperspy.utils.samfire module

SAMFire modules

The samfire module contains the following submodules:

fit_tests
Tests to check fit convergence when running SAMFire
global_strategies
Available global strategies to use in SAMFire
local_strategies
Available global strategies to use in SAMFire
SamfirePool
The parallel pool, customized to run SAMFire.

Module contents

Functions that operate of Signal instances and other goodies.

stack
Stack Signal instances.

Subpackages:

material
Tools related to the material under study.
plot
Tools for plotting.
eds
Tools for energy-dispersive X-ray data analysis.
example_signals
A few example of signal