Git Product home page Git Product logo

hyperspy-demos's Introduction

Azure pipelines status Tests status Documentation status Codecov coverage pre-commit.ci status

Python Version PyPI Version Anaconda Version License: GPL v3

gitter DOI

HyperSpy is an open source Python library for the interactive analysis of multidimensional datasets that can be described as multidimensional arrays of a given signal (for example, a 2D array of spectra, also known as a spectrum image).

HyperSpy makes it straightforward to apply analytical procedures that operate on an individual signal to multidimensional arrays, as well as providing easy access to analytical tools that exploit the multidimensionality of the dataset.

Its modular structure makes it easy to add features to analyze many different types of signals. Visit the HyperSpy Website to learn more about HyperSpy and its extension packages and for instructions on how to install the package and get started in analysing your data.

HyperSpy is released under the GPL v3 license.

Since version 0.8.4, HyperSpy only supports Python 3. If you need to install HyperSpy in Python 2.7, please install version 0.8.3.

Contributing

Everyone is welcome to contribute. Please read our contributing guidelines and get started!

hyperspy-demos's People

Contributors

dnjohnstone avatar ericpre avatar francisco-dlp avatar jat255 avatar jlaehne avatar k8macarthur avatar magnunor avatar mwalls avatar pburdet avatar pietsjoh avatar thomasaarholt avatar tjof2 avatar to266 avatar vidartf avatar woozey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hyperspy-demos's Issues

possible notebook interaction problem in demo

Hi,
When I run the fitting tutorial interactively, running every executable cell (including the last two to make the data) I can only get as far as the line:
m.notebook_interaction()
at which point I generate an error (see below)
Sorry if I'm just running it wrong somehow, but I thought we'd better check before the workshop.

m.notebook_interaction()

ImportError Traceback (most recent call last)
in ()
----> 1 m.notebook_interaction()

C:\Program Files\HyperSpy WinPython Bundle v1.1\python-3.5.1.amd64\lib\site-packages\hyperspy-1.1-py3.5-win-amd64.egg\hyperspy\model.py in notebook_interaction(self)
1695 try:
1696 children = [component.notebook_interaction(False) for component in
-> 1697 self]
1698 accord = Accordion(children=children)
1699 for i, comp in enumerate(self):

C:\Program Files\HyperSpy WinPython Bundle v1.1\python-3.5.1.amd64\lib\site-packages\hyperspy-1.1-py3.5-win-amd64.egg\hyperspy\model.py in (.0)
1694
1695 try:
-> 1696 children = [component.notebook_interaction(False) for component in
1697 self]
1698 accord = Accordion(children=children)

C:\Program Files\HyperSpy WinPython Bundle v1.1\python-3.5.1.amd64\lib\site-packages\hyperspy-1.1-py3.5-win-amd64.egg\hyperspy\component.py in notebook_interaction(self, display)
1212 container = VBox([active])
1213 for parameter in self.parameters:
-> 1214 container.children += parameter.notebook_interaction(False),
1215
1216 if not display:

C:\Program Files\HyperSpy WinPython Bundle v1.1\python-3.5.1.amd64\lib\site-packages\hyperspy-1.1-py3.5-win-amd64.egg\hyperspy\component.py in notebook_interaction(self, display)
656 try:
657 if self._number_of_elements == 1:
--> 658 container = self._create_notebook_widget()
659 else:
660 children = [self._create_notebook_widget(index=i) for i in

C:\Program Files\HyperSpy WinPython Bundle v1.1\python-3.5.1.amd64\lib\site-packages\hyperspy-1.1-py3.5-win-amd64.egg\hyperspy\component.py in _create_notebook_widget(self, index)
673 def _create_notebook_widget(self, index=None):
674
--> 675 from ipywidgets import (FloatSlider, FloatText, Layout, HBox)
676
677 widget_bounds = self._interactive_slider_bounds(index=index)

ImportError: cannot import name 'Layout'

Interactive demos using binder.org

I was reading this page, which shows how to use a service called binder.org in order to run interactive notebooks in the browser. This would be great for the demo repository, since it would enable people to run demos without any sort of installation or configuration.

It's actually pretty easy to create a Binder instance, and the only changes to the repository necessary would be an environment.yml file in the root of the repository that tells the backend Docker instance what modules are needed to run the server (for example, it doesn't install hyperspy or matplotlib by default).

These demos could be linked in the main HyperSpy documentation and in the Readme. I think this would help with new user adoption.

Offset problem

Hi, I have 1D data with EELS zero loss peak situated at certain pixel. I set the scale and offset, printed the data again and checked that the zero loss peak corresponds to energy 0eV.
However when I checked the energy corresponding to Si feature (background not subtracted yet), it stayed on the same value 98eV. What is more, the last value of the data even increased. So by setting the offset, instead of shifting my spectrum to lower energies, it kind of stretched. Any ideas?

Dtype Error in Hyperspy TEM-EDS tutorial?

Hello, I am a novice programmer trying to execute the Hypespy TEMEDS tutorial so I may adapt it for my own samples. Thanks for your consideration. When attempting to follow the hyperspy TEMEDS tutorial, the following issue is triggered when trying to execute

"axes = hs.plot.plot_images((mask, pt_la * mask), axes_decor=None, colorbar=None,
label=['Mask', 'Pt Lα intensity'], cmap='viridis')"

the following error is thrown

"TypeError Traceback (most recent call last)
Cell In[39], line 1
----> 1 axes = hs.plot.plot_images((mask, pt_la * mask), axes_decor=None, colorbar=None,
2 label=['Mask', 'Pt Lα intensity'], cmap='viridis')

File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/hyperspy/drawing/utils.py:1063, in plot_images(images, cmap, no_nans, per_row, label, labelwrap, suptitle, suptitle_fontsize, colorbar, centre_colormap, scalebar, scalebar_color, axes_decor, padding, tight_layout, aspect, min_asp, namefrac_thresh, fig, vmin, vmax, overlay, colors, alphas, legend_picking, legend_loc, pixel_size_factor, **kwargs)
1061 _vmin = vmin[idx] if isinstance(vmin, (tuple, list)) else vmin
1062 _vmax = vmax[idx] if isinstance(vmax, (tuple, list)) else vmax
-> 1063 _vmin, _vmax = contrast_stretching(data, _vmin, _vmax)
1064 if centre:
1065 _vmin, _vmax = centre_colormap_values(_vmin, _vmax)

File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/hyperspy/drawing/utils.py:91, in contrast_stretching(data, vmin, vmax)
88 # If vmin, vmax are float or int, we keep the value, if not we calculate
89 # the precentile value
90 if not isinstance(vmin, (float, int)):
---> 91 vmin = np.nanpercentile(data, _parse_value(vmin, 'vmin'))
92 if not isinstance(vmax, (float, int)):
93 vmax = np.nanpercentile(data, _parse_value(vmax, 'vmax'))

File <array_function internals>:180, in nanpercentile(*args, **kwargs)

File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/numpy/lib/nanfunctions.py:1384, in nanpercentile(a, q, axis, out, overwrite_input, method, keepdims, interpolation)
1382 if not function_base._quantile_is_valid(q):
1383 raise ValueError("Percentiles must be in the range [0, 100]")
-> 1384 return _nanquantile_unchecked(
1385 a, q, axis, out, overwrite_input, method, keepdims)

File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/numpy/lib/nanfunctions.py:1559, in _nanquantile_unchecked(a, q, axis, out, overwrite_input, method, keepdims)
1557 if a.size == 0:
1558 return np.nanmean(a, axis, out=out, keepdims=keepdims)
-> 1559 r, k = function_base._ureduce(a,
1560 func=_nanquantile_ureduce_func,
1561 q=q,
1562 axis=axis,
1563 out=out,
1564 overwrite_input=overwrite_input,
1565 method=method)
1566 if keepdims and keepdims is not np._NoValue:
1567 return r.reshape(q.shape + k)

File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/numpy/lib/function_base.py:3725, in _ureduce(a, func, **kwargs)
3722 else:
3723 keepdim = (1,) * a.ndim
-> 3725 r = func(a, **kwargs)
3726 return r, keepdim

File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/numpy/lib/nanfunctions.py:1581, in _nanquantile_ureduce_func(a, q, axis, out, overwrite_input, method)
1579 if axis is None or a.ndim == 1:
1580 part = a.ravel()
-> 1581 result = _nanquantile_1d(part, q, overwrite_input, method)
1582 else:
1583 result = np.apply_along_axis(_nanquantile_1d, axis, a, q,
1584 overwrite_input, method)

File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/numpy/lib/nanfunctions.py:1607, in _nanquantile_1d(arr1d, q, overwrite_input, method)
1603 if arr1d.size == 0:
1604 # convert to scalar
1605 return np.full(q.shape, np.nan, dtype=arr1d.dtype)[()]
-> 1607 return function_base._quantile_unchecked(
1608 arr1d, q, overwrite_input=overwrite_input, method=method)

File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/numpy/lib/function_base.py:4424, in _quantile_unchecked(a, q, axis, out, overwrite_input, method, keepdims)
4416 def _quantile_unchecked(a,
4417 q,
4418 axis=None,
(...)
4421 method="linear",
4422 keepdims=False):
4423 """Assumes that q is in [0, 1], and is an ndarray"""
-> 4424 r, k = _ureduce(a,
4425 func=_quantile_ureduce_func,
4426 q=q,
4427 axis=axis,
4428 out=out,
4429 overwrite_input=overwrite_input,
4430 method=method)
4431 if keepdims:
4432 return r.reshape(q.shape + k)

File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/numpy/lib/function_base.py:3725, in _ureduce(a, func, **kwargs)
3722 else:
3723 keepdim = (1,) * a.ndim
-> 3725 r = func(a, **kwargs)
3726 return r, keepdim

File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/numpy/lib/function_base.py:4593, in _quantile_ureduce_func(a, q, axis, out, overwrite_input, method)
4591 else:
4592 arr = a.copy()
-> 4593 result = _quantile(arr,
4594 quantiles=q,
4595 axis=axis,
4596 method=method,
4597 out=out)
4598 return result

File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/numpy/lib/function_base.py:4710, in _quantile(arr, quantiles, axis, method, out)
4708 result_shape = virtual_indexes.shape + (1,) * (arr.ndim - 1)
4709 gamma = gamma.reshape(result_shape)
-> 4710 result = _lerp(previous,
4711 next,
4712 gamma,
4713 out=out)
4714 if np.any(slices_having_nans):
4715 if result.ndim == 0 and out is None:
4716 # can't write to a scalar

File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/numpy/lib/function_base.py:4527, in _lerp(a, b, t, out)
4513 def _lerp(a, b, t, out=None):
4514 """
4515 Compute the linear interpolation weighted by gamma on each point of
4516 two same shape array.
(...)
4525 Output array.
4526 """
-> 4527 diff_b_a = subtract(b, a)
4528 # asanyarray is a stop-gap until gh-13105
4529 lerp_interpolation = asanyarray(add(a, diff_b_a * t, out=out))

TypeError: numpy boolean subtract, the - operator, is not supported, use the bitwise_xor, the ^ operator, or the logical_xor function instead."


Checking the type of c and cs returns a value of false for float. How may I fix this issue? The notebook is public in my repository

Thanks again

Template for new Tutorial Notebooks

As discussed in #10 I think it would be very good if we establish a convention on structure for tutorial notebooks - this will look good and make it easier for further contributions to be made.

We should agree on this structure and make a template for it to make it easy to make new Tutorials that comply with our scheme.

eds_TEM notebook has 0% composition after doing BSS

In section 7 model fitting a quantification the composition values come out as zero when using blind source separation as the deconvolution method. For my demos I have changed this to NMF and the values come out reasonable. I can also multiply the BSS factor values by a number to making them greater than one. In the current format however the compositions come at as 0% for both elements.

BUG: Holography demo wrong phase reconstruction due to change in the code

Holography demo will deliver wrong results once 1.4 version is released. The reason is the change of reconstruction code which got an option high_cf set to True by default. It applies lowpass filter during the side band position estimation filtering out frequencies higher than half of the Nyquist. In the example I've reduced the size of the holograms from 2k to 512x512 by cropping and binning which resulted in reduced fringe sampling (~3.7 pixels per fringe which is beyond half of the Nyquist).
This is what I get with the current RNM branch state running "Holography.ipynb" notebook:

In [10]: sb_position = ref.estimate_sideband_position(sb='upper')
         sb_position.data
Out[10]: array([451,  29])

Instead of:

Out[10]: array([390,  59])

Will address this issue in PR in HS.

EDS_SEM Tutorials remove Mayavi dependence

At present the 3D FIB-SEM tutorials use Mayavi to plot some stuff. This clearly doesn't work any more because of Mayavi not becoming Py3 compatible.

I've had a look but can't find a good alternative - unless, someone can propose a viable alternative I propose simply removing these 3D visualisation parts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.