pyTEMlib 0.2023.8.0__py2.py3-none-any.whl → 0.2024.2.0__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pyTEMlib might be problematic. Click here for more details.
- pyTEMlib/config_dir.py +0 -1
- pyTEMlib/crystal_tools.py +22 -26
- pyTEMlib/eds_tools.py +499 -46
- pyTEMlib/eels_dialog.py +284 -899
- pyTEMlib/eels_dialog_utilities.py +218 -341
- pyTEMlib/eels_tools.py +1526 -1583
- pyTEMlib/file_tools.py +52 -48
- pyTEMlib/graph_tools.py +3 -4
- pyTEMlib/image_tools.py +171 -41
- pyTEMlib/info_widget.py +618 -276
- pyTEMlib/kinematic_scattering.py +77 -512
- pyTEMlib/peak_dialog.py +162 -288
- pyTEMlib/version.py +2 -2
- pyTEMlib/xrpa_x_sections.py +173 -97
- {pyTEMlib-0.2023.8.0.dist-info → pyTEMlib-0.2024.2.0.dist-info}/LICENSE +1 -1
- {pyTEMlib-0.2023.8.0.dist-info → pyTEMlib-0.2024.2.0.dist-info}/METADATA +2 -2
- pyTEMlib-0.2024.2.0.dist-info/RECORD +35 -0
- {pyTEMlib-0.2023.8.0.dist-info → pyTEMlib-0.2024.2.0.dist-info}/WHEEL +1 -1
- pyTEMlib/eels_dlg.py +0 -252
- pyTEMlib/info_dialog.py +0 -665
- pyTEMlib/info_dlg.py +0 -239
- pyTEMlib/interactive_eels.py +0 -35
- pyTEMlib/viz.py +0 -481
- pyTEMlib-0.2023.8.0.dist-info/RECORD +0 -40
- {pyTEMlib-0.2023.8.0.dist-info → pyTEMlib-0.2024.2.0.dist-info}/entry_points.txt +0 -0
- {pyTEMlib-0.2023.8.0.dist-info → pyTEMlib-0.2024.2.0.dist-info}/top_level.txt +0 -0
pyTEMlib/viz.py
DELETED
|
@@ -1,481 +0,0 @@
|
|
|
1
|
-
"""plotting of sidpy Datasets with bokeh for google colab"""
|
|
2
|
-
|
|
3
|
-
import numpy as np
|
|
4
|
-
import sidpy
|
|
5
|
-
from sidpy.hdf.dtype_utils import is_complex_dtype
|
|
6
|
-
|
|
7
|
-
import plotly.graph_objects as go
|
|
8
|
-
from plotly.subplots import make_subplots
|
|
9
|
-
from ipywidgets import widgets
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import pyTEMlib.eels_tools as eels
|
|
13
|
-
import pyTEMlib.file_tools as ft
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
from bokeh.layouts import column
|
|
17
|
-
from bokeh.plotting import figure # , show, output_notebook
|
|
18
|
-
from bokeh.models import CustomJS, Slider, Span
|
|
19
|
-
from bokeh.models import LinearColorMapper, ColorBar, ColumnDataSource, BoxSelectTool
|
|
20
|
-
from bokeh.palettes import Spectral11
|
|
21
|
-
|
|
22
|
-
from pyTEMlib.sidpy_tools import *
|
|
23
|
-
import sys
|
|
24
|
-
import matplotlib.pyplot as plt
|
|
25
|
-
# from matplotlib.widgets import Slider, Button
|
|
26
|
-
import matplotlib.patches as patches
|
|
27
|
-
# import matplotlib.animation as animation
|
|
28
|
-
|
|
29
|
-
if sys.version_info.major == 3:
|
|
30
|
-
unicode = str
|
|
31
|
-
|
|
32
|
-
default_cmap = plt.cm.viridis
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def plot(dataset, palette='Viridis256'):
|
|
36
|
-
"""plot according to data_type"""
|
|
37
|
-
if dataset.data_type.name == 'IMAGE_STACK':
|
|
38
|
-
p = plot_stack(dataset, palette=palette)
|
|
39
|
-
elif dataset.data_type.name == 'IMAGE':
|
|
40
|
-
p = plot_image(dataset, palette=palette)
|
|
41
|
-
elif dataset.data_type.name == 'SPECTRUM':
|
|
42
|
-
p = plot_spectrum(dataset, palette=palette)
|
|
43
|
-
else:
|
|
44
|
-
p = None
|
|
45
|
-
return p
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
def plot_stack(dataset, palette="Viridis256"):
|
|
49
|
-
"""Plotting a stack of images
|
|
50
|
-
|
|
51
|
-
Plotting a stack of images contained in a sidpy.Dataset.
|
|
52
|
-
The images can be scrolled through with a slider widget.
|
|
53
|
-
|
|
54
|
-
Parameters
|
|
55
|
-
----------
|
|
56
|
-
dataset: sidpy.Dataset
|
|
57
|
-
sidpy dataset with data_type 'IMAGE_STACK'
|
|
58
|
-
palette: bokeh palette
|
|
59
|
-
palette is optional
|
|
60
|
-
|
|
61
|
-
Returns
|
|
62
|
-
-------
|
|
63
|
-
p: bokeh plot
|
|
64
|
-
|
|
65
|
-
Example
|
|
66
|
-
-------
|
|
67
|
-
>> import pyTEMlib
|
|
68
|
-
>> from bokeh.plotting import figure, show, output_notebook
|
|
69
|
-
>> output_notebook()
|
|
70
|
-
>> p = pyTEMlib.viz(dataset)
|
|
71
|
-
>> p.show(p)
|
|
72
|
-
"""
|
|
73
|
-
|
|
74
|
-
if not isinstance(dataset, sidpy.Dataset):
|
|
75
|
-
raise TypeError('Need a sidpy dataset for plotting')
|
|
76
|
-
if dataset.data_type.name != 'IMAGE_STACK':
|
|
77
|
-
raise TypeError('Need an IMAGE_STACK for plotting a stack')
|
|
78
|
-
|
|
79
|
-
stack = np.array(dataset-dataset.min())
|
|
80
|
-
stack = stack/stack.max()*256
|
|
81
|
-
stack = np.array(stack, dtype=int)
|
|
82
|
-
|
|
83
|
-
color_mapper = LinearColorMapper(palette=palette, low=0, high=256)
|
|
84
|
-
|
|
85
|
-
p = figure(match_aspect=True, plot_width=600, plot_height=600)
|
|
86
|
-
im_plot = p.image(image=[stack[0]], x=[0], y=[0], dw=[dataset.x[-1]], dh=[dataset.y[-1]], color_mapper=color_mapper)
|
|
87
|
-
p.x_range.range_padding = 0
|
|
88
|
-
p.y_range.range_padding = 0
|
|
89
|
-
p.xaxis.axis_label = 'distance (nm)'
|
|
90
|
-
p.yaxis.axis_label = 'distance (nm)'
|
|
91
|
-
|
|
92
|
-
slider = Slider(start=0, end=stack.shape[0]-1, value=0, step=1, title="frame")
|
|
93
|
-
|
|
94
|
-
update_curve = CustomJS(args=dict(source=im_plot, slider=slider, stack=stack),
|
|
95
|
-
code="""var f = slider.value;
|
|
96
|
-
source.data_source.data['image'] = [stack[f]];
|
|
97
|
-
// necessary because we mutated source.data in-place
|
|
98
|
-
source.data_source.change.emit(); """)
|
|
99
|
-
slider.js_on_change('value', update_curve)
|
|
100
|
-
|
|
101
|
-
return column(slider, p)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
def plot_image(dataset, palette="Viridis256"):
|
|
105
|
-
"""Plotting an image
|
|
106
|
-
|
|
107
|
-
Plotting an image contained in a sidpy.Dataset.
|
|
108
|
-
|
|
109
|
-
Parameters
|
|
110
|
-
----------
|
|
111
|
-
dataset: sidpy.Dataset
|
|
112
|
-
sidpy dataset with data_type 'IMAGE_STACK'
|
|
113
|
-
palette: bokeh palette
|
|
114
|
-
palette is optional
|
|
115
|
-
|
|
116
|
-
Returns
|
|
117
|
-
-------
|
|
118
|
-
p: bokeh plot
|
|
119
|
-
|
|
120
|
-
Example
|
|
121
|
-
-------
|
|
122
|
-
>> import pyTEMlib
|
|
123
|
-
>> from bokeh.plotting import figure, show, output_notebook
|
|
124
|
-
>> output_notebook()
|
|
125
|
-
>> p = pyTEMlib.viz(dataset)
|
|
126
|
-
>> p.show(p)
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
"""
|
|
130
|
-
if not isinstance(dataset, sidpy.Dataset):
|
|
131
|
-
raise TypeError('Need a sidpy dataset for plotting')
|
|
132
|
-
|
|
133
|
-
if dataset.data_type.name not in ['IMAGE', 'IMAGE_STACK']:
|
|
134
|
-
raise TypeError('Need an IMAGE or IMAGE_STACK for plotting an image')
|
|
135
|
-
|
|
136
|
-
if dataset.data_type.name == 'IMAGE_STACK':
|
|
137
|
-
image = dataset.sum(axis=0)
|
|
138
|
-
image = sidpy.Dataset.from_array(image)
|
|
139
|
-
image.data_type = 'image'
|
|
140
|
-
image.title = dataset.title
|
|
141
|
-
image.set_dimension(0, dataset.dim_1)
|
|
142
|
-
image.set_dimension(1, dataset.dim_2)
|
|
143
|
-
else:
|
|
144
|
-
image = dataset
|
|
145
|
-
|
|
146
|
-
p = figure(tooltips=[("x", "$x"), ("y", "$y"), ("value", "@image")], match_aspect=True,
|
|
147
|
-
plot_width=675, plot_height=600, )
|
|
148
|
-
color_mapper = LinearColorMapper(palette=palette, low=float(image.min()), high=float(image.max()))
|
|
149
|
-
|
|
150
|
-
# must give a vector of image data for image parameter
|
|
151
|
-
p.image(image=[np.array(image)], x=0, y=0, dw=image.x[-1], dh=image.y[-1], color_mapper=color_mapper,
|
|
152
|
-
level="image")
|
|
153
|
-
p.x_range.range_padding = 0
|
|
154
|
-
p.y_range.range_padding = 0
|
|
155
|
-
|
|
156
|
-
p.grid.grid_line_width = 0.
|
|
157
|
-
p.xaxis.axis_label = 'distance (nm)'
|
|
158
|
-
p.yaxis.axis_label = 'distance (nm)'
|
|
159
|
-
|
|
160
|
-
color_bar = ColorBar(color_mapper=color_mapper, major_label_text_font_size="7pt",
|
|
161
|
-
label_standoff=6, border_line_color=None, location=(0, 0))
|
|
162
|
-
p.add_layout(color_bar, 'right')
|
|
163
|
-
return p
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
def plot_spectrum(dataset, selected_range, palette=Spectral11):
|
|
167
|
-
"""Plot spectrum"""
|
|
168
|
-
if not isinstance(dataset, sidpy.Dataset):
|
|
169
|
-
raise TypeError('Need a sidpy dataset for plotting')
|
|
170
|
-
|
|
171
|
-
if dataset.data_type.name not in ['SPECTRUM']:
|
|
172
|
-
raise TypeError('Need an sidpy.Dataset of data_type SPECTRUM for plotting a spectrum ')
|
|
173
|
-
|
|
174
|
-
p = figure(x_axis_type="linear", plot_width=800, plot_height=400,
|
|
175
|
-
tooltips=[("index", "$index"), ("(x,y)", "($x, $y)")],
|
|
176
|
-
tools="pan,wheel_zoom,box_zoom,reset, hover, lasso_select")
|
|
177
|
-
p.add_tools(BoxSelectTool(dimensions="width"))
|
|
178
|
-
|
|
179
|
-
# first line is dataset
|
|
180
|
-
spectrum = ColumnDataSource(data=dict(x=dataset.dim_0, y=np.array(dataset)))
|
|
181
|
-
p.scatter('x', 'y', color='blue', size=1, alpha=0., source=spectrum,
|
|
182
|
-
selection_color="firebrick", selection_alpha=0.)
|
|
183
|
-
p.line(x='x', y='y', source=spectrum, legend_label=dataset.title, color=palette[0], line_width=2)
|
|
184
|
-
# add other lines if available
|
|
185
|
-
if 'add2plot' in dataset.metadata:
|
|
186
|
-
data = dataset.metadata['add2plot']
|
|
187
|
-
for key, line in data.items():
|
|
188
|
-
p.line(dataset.dim_0.values, line['data'], legend_label=line['legend'], color=palette[key], line_width=2)
|
|
189
|
-
p.legend.click_policy = "hide"
|
|
190
|
-
p.xaxis.axis_label = dataset.labels[0]
|
|
191
|
-
p.yaxis.axis_label = dataset.data_descriptor
|
|
192
|
-
p.title.text = dataset.title
|
|
193
|
-
|
|
194
|
-
my_span = Span(location=0, dimension='width', line_color='gray', line_width=1)
|
|
195
|
-
p.add_layout(my_span)
|
|
196
|
-
|
|
197
|
-
callback = CustomJS(args=dict(s1=spectrum), code="""
|
|
198
|
-
var inds = s1.selected.indices;
|
|
199
|
-
if (inds.length == 0)
|
|
200
|
-
return;
|
|
201
|
-
var kernel = IPython.notebook.kernel;
|
|
202
|
-
kernel.execute("selected_range = " + [inds[0], inds[inds.length-1]]);""")
|
|
203
|
-
|
|
204
|
-
spectrum.selected.js_on_change('indices', callback)
|
|
205
|
-
return p
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
class CurveVisualizer(object):
|
|
209
|
-
"""Plots a sidpy.Dataset with spectral dimension
|
|
210
|
-
|
|
211
|
-
"""
|
|
212
|
-
def __init__(self, dset, spectrum_number=None, axis=None, leg=None, **kwargs):
|
|
213
|
-
if not isinstance(dset, sidpy.Dataset):
|
|
214
|
-
raise TypeError('dset should be a sidpy.Dataset object')
|
|
215
|
-
if axis is None:
|
|
216
|
-
self.fig = plt.figure()
|
|
217
|
-
self.axis = self.fig.add_subplot(1, 1, 1)
|
|
218
|
-
else:
|
|
219
|
-
self.axis = axis
|
|
220
|
-
self.fig = axis.figure
|
|
221
|
-
|
|
222
|
-
self.dset = dset
|
|
223
|
-
self.selection = []
|
|
224
|
-
[self.spec_dim, self.energy_scale] = get_dimensions_by_type('spectral', self.dset)[0]
|
|
225
|
-
|
|
226
|
-
self.lined = dict()
|
|
227
|
-
self.plot(**kwargs)
|
|
228
|
-
|
|
229
|
-
def plot(self, **kwargs):
|
|
230
|
-
line1, = self.axis.plot(self.energy_scale.values, self.dset, label='spectrum', **kwargs)
|
|
231
|
-
lines = [line1]
|
|
232
|
-
if 'add2plot' in self.dset.metadata:
|
|
233
|
-
data = self.dset.metadata['add2plot']
|
|
234
|
-
for key, line in data.items():
|
|
235
|
-
line_add, = self.axis.plot(self.energy_scale.values, line['data'], label=line['legend'])
|
|
236
|
-
lines.append(line_add)
|
|
237
|
-
|
|
238
|
-
legend = self.axis.legend(loc='upper right', fancybox=True, shadow=True)
|
|
239
|
-
legend.get_frame().set_alpha(0.4)
|
|
240
|
-
|
|
241
|
-
for legline, origline in zip(legend.get_lines(), lines):
|
|
242
|
-
legline.set_picker(True)
|
|
243
|
-
legline.set_pickradius(5) # 5 pts tolerance
|
|
244
|
-
self.lined[legline] = origline
|
|
245
|
-
self.fig.canvas.mpl_connect('pick_event', self.onpick)
|
|
246
|
-
|
|
247
|
-
self.axis.axhline(0, color='gray', alpha=0.6)
|
|
248
|
-
self.axis.set_xlabel(self.dset.labels[0])
|
|
249
|
-
self.axis.set_ylabel(self.dset.data_descriptor)
|
|
250
|
-
self.axis.ticklabel_format(style='sci', scilimits=(-2, 3))
|
|
251
|
-
self.fig.canvas.draw_idle()
|
|
252
|
-
|
|
253
|
-
def update(self, **kwargs):
|
|
254
|
-
x_limit = self.axis.get_xlim()
|
|
255
|
-
y_limit = self.axis.get_ylim()
|
|
256
|
-
self.axis.clear()
|
|
257
|
-
self.plot(**kwargs)
|
|
258
|
-
self.axis.set_xlim(x_limit)
|
|
259
|
-
self.axis.set_ylim(y_limit)
|
|
260
|
-
|
|
261
|
-
def onpick(self, event):
|
|
262
|
-
# on the pick event, find the orig line corresponding to the
|
|
263
|
-
# legend proxy line, and toggle the visibility
|
|
264
|
-
legline = event.artist
|
|
265
|
-
origline = self.lined[legline]
|
|
266
|
-
vis = not origline.get_visible()
|
|
267
|
-
origline.set_visible(vis)
|
|
268
|
-
# Change the alpha on the line in the legend so we can see what lines
|
|
269
|
-
# have been toggled
|
|
270
|
-
if vis:
|
|
271
|
-
legline.set_alpha(1.0)
|
|
272
|
-
else:
|
|
273
|
-
legline.set_alpha(0.2)
|
|
274
|
-
self.fig.canvas.draw()
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
def verify_spectrum_dataset(datasets):
|
|
278
|
-
if isinstance(datasets, sidpy.Dataset):
|
|
279
|
-
datasets = {'Channel_000': datasets}
|
|
280
|
-
|
|
281
|
-
first_dataset = datasets[list(datasets)[0]]
|
|
282
|
-
has_complex_dataset = False
|
|
283
|
-
for dat in datasets.values():
|
|
284
|
-
if is_complex_dtype(dat.dtype):
|
|
285
|
-
has_complex_dataset = True
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
if first_dataset.data_type.name != 'SPECTRUM':
|
|
289
|
-
raise TypeError('We need a spectrum dataset here')
|
|
290
|
-
if first_dataset.ndim >1:
|
|
291
|
-
if first_dataset.shape[1] >1:
|
|
292
|
-
raise TypeError('Wrong dimensions for spectrum datasset')
|
|
293
|
-
|
|
294
|
-
energy_dim = first_dataset.get_spectrum_dims()
|
|
295
|
-
energy_dim = first_dataset.get_dimension_by_number(energy_dim[0])[0]
|
|
296
|
-
energy_dim.label = f'{energy_dim.quantity} ({energy_dim.units})'
|
|
297
|
-
|
|
298
|
-
default_plot_dictionary = {'title': '',
|
|
299
|
-
'theme': "plotly_white",
|
|
300
|
-
'y_scale': 1.0,
|
|
301
|
-
'y_axis_label': first_dataset.data_descriptor,
|
|
302
|
-
'x_axis_label': energy_dim.label,
|
|
303
|
-
'show_legend': True,
|
|
304
|
-
'height': 500,
|
|
305
|
-
'figure_size': None,
|
|
306
|
-
'scale_bar': False,
|
|
307
|
-
'colorbar': True,
|
|
308
|
-
'set_title': True,
|
|
309
|
-
'has_complex_dataset': has_complex_dataset}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
default_plot_dictionary.update(first_dataset.metadata['plot_parameter'])
|
|
313
|
-
first_dataset.metadata['plot_parameter'] = default_plot_dictionary
|
|
314
|
-
|
|
315
|
-
return datasets
|
|
316
|
-
|
|
317
|
-
def spectrum_view_plotly(datasets, figure=None, show=False):
|
|
318
|
-
|
|
319
|
-
datasets = verify_spectrum_dataset(datasets)
|
|
320
|
-
first_dataset = datasets[list(datasets)[0]]
|
|
321
|
-
plot_dic = first_dataset.metadata['plot_parameter']
|
|
322
|
-
|
|
323
|
-
if figure is None:
|
|
324
|
-
if plot_dic['has_complex_dataset']:
|
|
325
|
-
fig = make_subplots(rows=1, cols=2, subplot_titles=("Magnitude", "Phase"))
|
|
326
|
-
else:
|
|
327
|
-
fig = go.Figure()
|
|
328
|
-
|
|
329
|
-
else:
|
|
330
|
-
fig = figure
|
|
331
|
-
|
|
332
|
-
for key, dat in datasets.items():
|
|
333
|
-
if dat.data_type == first_dataset.data_type:
|
|
334
|
-
energy_dim = dat.get_spectrum_dims()
|
|
335
|
-
energy_dim = dat.get_dimension_by_number(energy_dim[0])[0]
|
|
336
|
-
if is_complex_dtype(dat.dtype):
|
|
337
|
-
fig.add_trace(go.Scatter(x=energy_dim.values, y=np.abs(dat).squeeze()*plot_dic['y_scale'], name=f'{dat.title}-Magnitude', mode="lines+markers", marker=dict(size=2)), row=1, col=1)
|
|
338
|
-
fig.add_trace(go.Scatter(x=energy_dim.values, y=np.angle(dat).squeeze()*plot_dic['y_scale'], name=f'{dat.title}-Phase', mode="lines+markers", marker=dict(size=2)), row=1, col=2)
|
|
339
|
-
else:
|
|
340
|
-
fig.add_trace(go.Scatter(x=energy_dim.values, y=np.array(dat).squeeze()*plot_dic['y_scale'], name=dat.title, mode="lines+markers", marker=dict(size=2)))
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
fig.update_layout(
|
|
344
|
-
selectdirection='h',
|
|
345
|
-
showlegend = plot_dic['show_legend'],
|
|
346
|
-
dragmode='select',
|
|
347
|
-
title_text=plot_dic['title'],
|
|
348
|
-
yaxis_title_text=plot_dic['y_axis_label'],
|
|
349
|
-
xaxis_title_text=plot_dic['x_axis_label'],
|
|
350
|
-
height=plot_dic['height'],
|
|
351
|
-
template=plot_dic['theme']
|
|
352
|
-
)
|
|
353
|
-
fig.update_layout(hovermode='x unified')
|
|
354
|
-
|
|
355
|
-
if plot_dic['has_complex_dataset']:
|
|
356
|
-
fig.update_yaxes(title_text='angle (rad)', row = 1, col = 2)
|
|
357
|
-
fig.update_xaxes(title_text=plot_dic['x_axis_label'], row = 1, col = 2)
|
|
358
|
-
|
|
359
|
-
config = {'displayModeBar': True}
|
|
360
|
-
if show:
|
|
361
|
-
fig.show(config=config)
|
|
362
|
-
return fig
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
class SpectrumView(object):
|
|
366
|
-
def __init__(self, datasets, figure=None, **kwargs):
|
|
367
|
-
first_dataset = datasets[list(datasets)[0]]
|
|
368
|
-
if first_dataset.data_type.name != 'SPECTRUM':
|
|
369
|
-
raise TypeError('We need a spectrum dataset here')
|
|
370
|
-
if first_dataset.ndim >1:
|
|
371
|
-
if first_dataset.shape[1] >1:
|
|
372
|
-
raise TypeError('Wrong dimensions for spectrum datasset')
|
|
373
|
-
|
|
374
|
-
energy_dim = first_dataset.get_spectrum_dims()
|
|
375
|
-
energy_dim = first_dataset.get_dimension_by_number(energy_dim[0])[0]
|
|
376
|
-
|
|
377
|
-
if 'plot_parameter' not in first_dataset.metadata:
|
|
378
|
-
first_dataset.metadata['plot_parameter'] = {}
|
|
379
|
-
plot_dic = first_dataset.metadata['plot_parameter']
|
|
380
|
-
energy_dim.label = f'{energy_dim.quantity} ({energy_dim.units})'
|
|
381
|
-
|
|
382
|
-
plot_dic['title'] = kwargs.pop('title', '')
|
|
383
|
-
plot_dic['theme'] = kwargs.pop('theme', "plotly_white")
|
|
384
|
-
plot_dic['y_scale'] = kwargs.pop('y_scale', 1.0)
|
|
385
|
-
plot_dic['y_axis_label'] = kwargs.pop('y_axis_label', first_dataset.data_descriptor)
|
|
386
|
-
plot_dic['x_axis_label'] = kwargs.pop('x_axis_label', energy_dim.label)
|
|
387
|
-
plot_dic['height'] = kwargs.pop('height', 500)
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
if 'incident_beam_current_counts' in first_dataset.metadata['experiment']:
|
|
391
|
-
plot_dic['y_scale'] = 1e6/first_dataset.metadata['experiment']['incident_beam_current_counts']
|
|
392
|
-
plot_dic['y_axis_label'] = ' probability (ppm)'
|
|
393
|
-
# plot_dic['y_scale'] = 1e6/first_dataset.sum()
|
|
394
|
-
|
|
395
|
-
def selection_fn(trace,points,selector):
|
|
396
|
-
self.energy_selection = [points.point_inds[0], points.point_inds[-1]]
|
|
397
|
-
|
|
398
|
-
self.fig = spectrum_view_plotly(datasets)
|
|
399
|
-
|
|
400
|
-
self.spectrum_widget = go.FigureWidget(self.fig)
|
|
401
|
-
|
|
402
|
-
self.spectrum_widget.data[0].on_selection(selection_fn)
|
|
403
|
-
self.spectrum_widget.data[0].on_click(self.identify_edges)
|
|
404
|
-
|
|
405
|
-
self.edge_annotation = 0
|
|
406
|
-
self.edge_line = 0
|
|
407
|
-
self.regions = {}
|
|
408
|
-
self.initialize_edge()
|
|
409
|
-
|
|
410
|
-
self.plot = display(self.spectrum_widget)
|
|
411
|
-
|
|
412
|
-
def initialize_edge(self):
|
|
413
|
-
""" Intitalizes edge cursor
|
|
414
|
-
Should be run first so that edge cursor is first
|
|
415
|
-
"""
|
|
416
|
-
self.edge_annotation = len(self.spectrum_widget.layout.annotations)
|
|
417
|
-
self.edge_line = len(self.spectrum_widget.layout.shapes)
|
|
418
|
-
self.spectrum_widget.add_vline(x=200, line_dash="dot", line_color='blue',
|
|
419
|
-
annotation_text= " ",
|
|
420
|
-
annotation_position="top right",
|
|
421
|
-
visible = False)
|
|
422
|
-
|
|
423
|
-
def identify_edges(self, trace, points, selector):
|
|
424
|
-
energy = points.xs[0]
|
|
425
|
-
edge_names = find_edge_names(points.xs[0])
|
|
426
|
-
self.spectrum_widget.layout['annotations'][self.edge_annotation].x=energy
|
|
427
|
-
|
|
428
|
-
self.spectrum_widget.layout['annotations'][self.edge_annotation].text = f"{edge_names}"
|
|
429
|
-
self.spectrum_widget.layout['annotations'][self.edge_annotation].visible = True
|
|
430
|
-
self.spectrum_widget.layout['shapes'][self.edge_line].x0 = energy
|
|
431
|
-
self.spectrum_widget.layout['shapes'][self.edge_line].x1 = energy
|
|
432
|
-
self.spectrum_widget.layout['shapes'][self.edge_line].visible = True
|
|
433
|
-
self.spectrum_widget.layout.update()
|
|
434
|
-
|
|
435
|
-
def add_region(self, text, start, end, color='blue'):
|
|
436
|
-
if text not in self.regions:
|
|
437
|
-
self.regions[text] = {'annotation': len(self.spectrum_widget.layout.annotations),
|
|
438
|
-
'shape': len(self.spectrum_widget.layout.shapes),
|
|
439
|
-
'start': start,
|
|
440
|
-
'end': end,
|
|
441
|
-
'color': color}
|
|
442
|
-
self.spectrum_widget.add_vrect(x0=start, x1=end,
|
|
443
|
-
annotation_text=text, annotation_position="top left",
|
|
444
|
-
fillcolor=color, opacity=0.15, line_width=0)
|
|
445
|
-
self.spectrum_widget.layout.update()
|
|
446
|
-
else:
|
|
447
|
-
self.update_region(text, start, end)
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
def update_region(self, text, start, end):
|
|
451
|
-
if text in self.regions:
|
|
452
|
-
region = self.regions[text]
|
|
453
|
-
self.spectrum_widget.layout.annotations[region['annotation']].x =start
|
|
454
|
-
self.spectrum_widget.layout['shapes'][region['shape']].x0 = start
|
|
455
|
-
self.spectrum_widget.layout['shapes'][region['shape']].x1 = end
|
|
456
|
-
self.spectrum_widget.layout.update()
|
|
457
|
-
|
|
458
|
-
def regions_visibility(self, visibility=True):
|
|
459
|
-
|
|
460
|
-
for region in self.regions.values():
|
|
461
|
-
self.spectrum_widget.layout.annotations[region['annotation']].visible = visibility
|
|
462
|
-
self.spectrum_widget.layout.shapes[region['shape']].visible = visibility
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
def find_edge_names(energy_value):
|
|
466
|
-
|
|
467
|
-
selected_edges = []
|
|
468
|
-
for shift in [1,2,5,10,20]:
|
|
469
|
-
selected_edge = ''
|
|
470
|
-
edges = eels.find_major_edges(energy_value, shift)
|
|
471
|
-
edges = edges.split('\n')
|
|
472
|
-
for edge in edges[1:]:
|
|
473
|
-
edge = edge[:-3].split(':')
|
|
474
|
-
name = edge[0].strip()
|
|
475
|
-
energy = float(edge[1].strip())
|
|
476
|
-
selected_edge = name
|
|
477
|
-
|
|
478
|
-
if selected_edge != '':
|
|
479
|
-
selected_edges.append(selected_edge)
|
|
480
|
-
if len(selected_edges)>0:
|
|
481
|
-
return selected_edges
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
pyTEMlib/__init__.py,sha256=nEN93amIEoZxO7rJgN71ABeCoXrnmaywBbE97l5lPio,178
|
|
2
|
-
pyTEMlib/animation.py,sha256=oPxbTuy8LfdH2mOOgm9Q40ArFAJmXM_58UV97ptcNAY,25187
|
|
3
|
-
pyTEMlib/atom_tools.py,sha256=ViO4ZZZoCZ_Cp2KijiqKKOiQhGOWnye45T0rsiPhf4I,7314
|
|
4
|
-
pyTEMlib/config_dir.py,sha256=NWAseETgFNfBgHfBFv7ZTl7RsFzrLdGlhTN5Bn5FrTg,2104
|
|
5
|
-
pyTEMlib/crystal_tools.py,sha256=KGW_fQqr2L8iJnGh31gi6qbJOeHt-Y7mOeIHx_Psxb8,61676
|
|
6
|
-
pyTEMlib/diffraction_plot.py,sha256=pM5d3bdBGa8LlPZ5lw8sLT94mlYTXELxPLv-jUP2FWY,27959
|
|
7
|
-
pyTEMlib/dynamic_scattering.py,sha256=O9MxnxfndWJ2VhQRjksKNQ4yY7y-gN_hitRQ4Qox4ns,9472
|
|
8
|
-
pyTEMlib/eds_tools.py,sha256=gPrKT3U8lS7V36Njk72CWI-ovsoFv-EvwB8U9zBhpGU,3546
|
|
9
|
-
pyTEMlib/eels_dialog.py,sha256=IuiekHXOz7kL36TGv3dJAunifSiMF-92U-s9PrSAqTo,61225
|
|
10
|
-
pyTEMlib/eels_dialog_utilities.py,sha256=hCNIu5UcA1WZtsFMNw3go_kzYgm2nGjvwxDKhLFZpxg,54612
|
|
11
|
-
pyTEMlib/eels_dlg.py,sha256=t3DotxKBqgmqUd_ITQGfzdDWaHANj5CYsHt4hc8chSY,9834
|
|
12
|
-
pyTEMlib/eels_tools.py,sha256=n6ke9XEqvzMXYrri0EmIE9pJ2sZZdV55Dolton9-Gvg,75435
|
|
13
|
-
pyTEMlib/file_tools.py,sha256=wL50vVk7vwPKIua4-tCzjM_dAy5uWg0jUwLMv_BoTZI,46102
|
|
14
|
-
pyTEMlib/file_tools_qt.py,sha256=tLZACS4JyGH_AOzNR_SGAhjA01y4VJB261opPhGMlm8,7223
|
|
15
|
-
pyTEMlib/graph_tools.py,sha256=lXU0ty2kHv2aqJEHiTQliqkfLHWAELzBRIqEb7Ni6Nk,44148
|
|
16
|
-
pyTEMlib/graph_viz.py,sha256=m5PwSn6l2r0bsaLWBDSHc9IGR3_PneG2BrZgnEdi07I,13644
|
|
17
|
-
pyTEMlib/image_dialog.py,sha256=F-ZgKq7UnMtPPd1b9eqb7t8MXDfWN-8hVKwB2Il0x28,6235
|
|
18
|
-
pyTEMlib/image_dlg.py,sha256=n5gradDiYOFGEQ3k_Wlk9RUYYzl4bl_hKLzNVcYteNE,5694
|
|
19
|
-
pyTEMlib/image_tools.py,sha256=AqNdbiPvr0uRy_o89NiuuHjQQcdx-rhj90Ae7_aQGQs,37278
|
|
20
|
-
pyTEMlib/info_dialog.py,sha256=E7kumPEzyEYumTcvV0sdYPjHM7MO2SAwcl9oT_nK_AA,32694
|
|
21
|
-
pyTEMlib/info_dlg.py,sha256=A72cifLU12ucijP_Nxf2hsA8IUhIs5cKJ0yIbKRPjXk,9894
|
|
22
|
-
pyTEMlib/info_widget.py,sha256=PcHQGx-Ndzdemt7XZ1nlb2aSGQYiC0ZZHx88B-nQkeI,32003
|
|
23
|
-
pyTEMlib/interactive_eels.py,sha256=lzK6sgMTjoRyaUc48BgOgrG_xhuBqjXdp-kIeaTBVD0,912
|
|
24
|
-
pyTEMlib/interactive_image.py,sha256=5PwypcA1OjLAD-fi8bmWWFHuOjdIPVY9Dh59V24WuDA,34
|
|
25
|
-
pyTEMlib/kinematic_scattering.py,sha256=wuH0YvPz4PL3DksPNsRvkl6zsJP-Uy-QXGvLlwHxR6c,61071
|
|
26
|
-
pyTEMlib/microscope.py,sha256=iigUF1UImHEfmL2wqEBBj3aNRgEYouDbIln8VCo4_KM,1545
|
|
27
|
-
pyTEMlib/peak_dialog.py,sha256=dBJshnBcmtn8L2BJpTclshTukJYXYbd0dFJEJmbyCjU,56368
|
|
28
|
-
pyTEMlib/peak_dlg.py,sha256=qcjcnhwpGa4jBCeXzwQz9sCyX-tHsLLQ67ToqfKOiQY,11550
|
|
29
|
-
pyTEMlib/probe_tools.py,sha256=8tPQuANClLsGAKnZo6Vo4gNIGKfyDR6WUMO3dXcm_4k,27177
|
|
30
|
-
pyTEMlib/sidpy_tools.py,sha256=0oIx-qMtEmcZmLazQKW19dd-KoxyY3B15aIeMcyHA8E,4878
|
|
31
|
-
pyTEMlib/simulation_tools.py,sha256=RmegD5TpQMU68uASvzZWVplAqs7bM5KkF6bWDWLjyc0,2799
|
|
32
|
-
pyTEMlib/version.py,sha256=L6feq1ILXLEf4Sl5r76W5rml6QzybDbUuBsZS947eYE,93
|
|
33
|
-
pyTEMlib/viz.py,sha256=Z36r4OptraJVIQlZx57_1wwwrwnxWVZyNoCOjeNj_ac,18439
|
|
34
|
-
pyTEMlib/xrpa_x_sections.py,sha256=WeR7dc6SjYukk1S_8kR6IQFDqPagETTMJkFmbP78OPU,1805870
|
|
35
|
-
pyTEMlib-0.2023.8.0.dist-info/LICENSE,sha256=ASQTnQgYv39esmSFeb-IDhPwOMZSqGJ4s19vy4YtIaA,1069
|
|
36
|
-
pyTEMlib-0.2023.8.0.dist-info/METADATA,sha256=6fqx1QSoxo3E-0CvA6NB70ukueyAefT0Z1YVnGpz2u8,3280
|
|
37
|
-
pyTEMlib-0.2023.8.0.dist-info/WHEEL,sha256=m9WAupmBd2JGDsXWQGJgMGXIWbQY3F5c2xBJbBhq0nY,110
|
|
38
|
-
pyTEMlib-0.2023.8.0.dist-info/entry_points.txt,sha256=qiIFPP3ffSz-gxj-TowzbA0Setq5Lo0RJTVtSrqD1IY,44
|
|
39
|
-
pyTEMlib-0.2023.8.0.dist-info/top_level.txt,sha256=rPLVH0UJxrPSPgSoKScTjL1K_X69JFzsYYnDnYTYIlU,9
|
|
40
|
-
pyTEMlib-0.2023.8.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|