This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See below for use | |
def get_individual_model_components(m): | |
""" | |
Exports the signals from the individual components present in the model | |
Returns a list of signals, from the current position in the model. | |
""" | |
def get_A(component): | |
return component.A.value | |
def set_A(component, value): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rotate90(sample): | |
from ase.build import rotate as rot | |
a1 = (1,0,0) | |
a2 = (0,0,1) | |
b1 = (0,0,1) | |
b2 = (1,0,0) | |
rot(sample, a1, a2, b1, b2, rotate_cell=False) | |
sample.cell[0,0], sample.cell[2,2] = sample.cell[2,2], sample.cell[0,0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prism(file, path=None, focus=0, FP=20, alpha=20.0e-3): | |
import gc | |
gc.collect() | |
import os | |
import pyprismatic as pr | |
file = os.path.abspath(file) | |
save_path = path | |
path, filename = os.path.split(file) | |
name, _ = os.path.splitext(filename) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mylist = [20, 30, 1, 3, 50] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--------------------------------------------------------------------------- | |
KeyError Traceback (most recent call last) | |
<ipython-input-1-bcff7cee2750> in <module>() | |
1 get_ipython().run_line_magic('matplotlib', 'notebook') | |
2 import hyperspy.api as hs | |
----> 3 hs.preferences.gui() | |
c:\users\me\documents\github\hyperspy\hyperspy\ui_registry.py in pg(self, display, toolkit, **kwargs) | |
172 def pg(self, display=True, toolkit=None, **kwargs): | |
173 return get_gui(self, toolkey=toolkey, display=display, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ipywidgets as widgets | |
import os | |
from pathlib import Path | |
cwd = Path(os.getcwd()) | |
FOLDERLABEL = '-------FOLDERS-------' | |
FILESLABEL = '-------FILES-------' | |
def get_folder_contents(folder): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File "D:\Anaconda\envs\py36\lib\runpy.py", line 193, in _run_module_as_main | |
"__main__", mod_spec) | |
File "D:\Anaconda\envs\py36\lib\runpy.py", line 85, in _run_code | |
exec(code, run_globals) | |
File "D:\Anaconda\envs\py36\lib\site-packages\ipykernel_launcher.py", line 16, in <module> | |
app.launch_new_instance() | |
File "D:\Anaconda\envs\py36\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance | |
app.start() | |
File "D:\Anaconda\envs\py36\lib\site-packages\ipykernel\kernelapp.py", line 486, in start | |
self.io_loop.start() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string = 'a*x**r+b*x+c' | |
expression = sympy.sympify(string) | |
expr = hs.model.components1D.Expression(string, 'test') | |
data = np.random.random((5,300)) | |
s = hs.signals.Signal1D(data) | |
m = s.create_model() | |
m.append(expr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plot_im(s, ax=None, scalebar=True, label=True, clim=None, cmap=None, cbar=True, loc=4, axislabel=False, colorbar_format="scientific", colorbar_decimals=1, dont_show=False, **kwargs): | |
""" | |
Plots the HS image nicely with a scalebar. Label can be modified or turned off. | |
Use dont_show=True to not show a plot, but still return it. | |
Returns: | |
fig - the figure | |
ax - the axes | |
im - the image data | |
""" | |
import matplotlib.pyplot as plt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def linear_regression(y, comp_data): | |
''' | |
Performs linear regression on single pixels as well | |
as multidimensional arrays | |
Parameters | |
---------- | |
y : array_like, shape: (signal_axis) or (nav_shape, signal_axis) | |
The data to be fit to | |
comp_data : array_like, shape: (number_of_comp, signal_axis) |