hyperspy | Multidimensional data analysis | Data Visualization library
kandi X-RAY | hyperspy Summary
kandi X-RAY | hyperspy Summary
Multidimensional data analysis
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Plot images .
- Return a list of the supported SPC data types .
- Perform blind source separation .
- Read frames from file .
- Reconstruct the phase of the signal .
- Compute a quantification of intensities .
- Creates an eelDB dataset .
- Perform kramersk - kronigers kramers - correlation .
- Read a file .
- Read EDF file
hyperspy Key Features
hyperspy Examples and Code Snippets
Community Discussions
Trending Discussions on hyperspy
QUESTION
this is the first time i ask a question in here, so i hope i can ask it correctly any feedback on clarity is also appriciated.
I am forced to use matplotlib's plot function in the code i am currently writing, due to the datastructure i am working with. But it does not do well with plotting in loops. What i aim to do, with my plot, is to be able to modify a background window determined by the user, and either accept or reject the output. But as i understand there is some conflict between matplotlibs interactive function and the use of a loop. I am relativly new to python, so the code might not be the prittiest, but useually i gets the job done. I am however at a complete loss for the particular problem. I have seen similair problems on the internet, which have been solved with plt.pause('timeinterval') but this is not an option in my case. or atleast i cannot see how i can use it, since i want to wait for user input. I have also tried plt.waitforbuttonpress() but this is not very intuetive, i cannot choose which button it should wait for.
I guess a third option is to extract the data from the format hyperspy uses and then make a canvas of my own, which forfills my needs, but this is very tidious for me, due to my lack of experience.
Do anyone have any alternative ways of producing a plot, preferably with matplotlib such that i can achive what i am trying?
By the way, i have also tried turning off interactive mode, and this does not do the trick unfurtunatly.
Some information about the specs: This is running on a windows pc, using jupyterlab and python 3.10
I hope my dilemma is clear.
...ANSWER
Answered 2021-Oct-11 at 13:10import pandas as pd
import numpy as np
import ipywidgets as wg
from ipywidgets import HBox, VBox
import matplotlib.pyplot as plt
from IPython.display import display
%matplotlib widget
a = np.arange(50)
b = np.random.rand(50) + a
c = np.sin(a)
d = np.cos(b)
df = pd.DataFrame({'a': a,
'b': b,
'c': c,
'd': d})
userinput1 = wg.Text(value="", placeholder='Type something', description='x axis')
userinput2 = wg.Text(value="", placeholder='Type something', description='y axis')
buttonplot = wg.Button(description='Plot', disabled=False, button_style='', tooltip='Click me',icon='check')
buttonout = wg.Output()
display(HBox((userinput1, userinput2, buttonplot)))
display(buttonout)
plt.close()
fig, ax = plt.subplots()
def on_click_event(change):
with buttonout:
x = (userinput1.value)
y = (userinput2.value)
ax.plot(df[x], df[y], label=f'{y}')
ax.legend()
buttonplot.on_click(on_click_event)
QUESTION
[Edit: apparently this file looks similar to h5 format] I am trying to extract metadata from a file with extension of (.dm3) using hyperspy in Python, I am able to get all the data but it's getting saved in a treeview, but I need the data in Json I tried to make my own parser to convert it which worked for most cases but then failed:
Is there a library or package I can use to convert the treeview to JSON in pyhton?
My parser:
...ANSWER
Answered 2021-Jun-15 at 20:08I wrote a parser for the tree-view format:
QUESTION
I have a bunch of cryo and liquid cell dm4 images that are 32bit float, but the precision and the large values of 32bit are completely unnecessary, so we've decided to convert them to 16bit signed int.
I need to preserve the metadata structure that dm4 images have because the images still need to be openable in digital micrograph. So using hyperspy or ncempy is not an option since they can't write dm4 files.
I currently have a script to do this in dm-script, but it only takes in one directory at a time and doesn't know how to handle liquid cell data. And I am not good enough to do that.
I was wondering if I could do the same thing in the python interface in DM? Since I can manipulate the file structure and traverse the directories with easily with python.
The dm script I'm referring to is the on FELMI ZFE DigitalMicrograph Script Database slightly adjusted to allow for signed integers and not creating tiffs since they are not useful for us currently.
Edit: the dm-script works nicely for now, i am curious if there is a way to pass the source and output directory to my dm-script from the python script. That way i can do all the directory handling in python, and just call the dm-script one folder at a time.
...ANSWER
Answered 2020-Aug-27 at 19:46Not sure if this is what you're after, but the script below shows how one recursively builds a file-list from all subfolders, filters it by extension, and then act on each of them.
The current script will open all .dm4 files of a given folder and its subfolders, convert the image into sint16 and resave it with a prefixed name.
However, you can very easily adjust the script by modifying the method ActOnFile
.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install hyperspy
You can use hyperspy like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page