hyperspy 2.0rc0__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.
Files changed (331) hide show
  1. hyperspy/Release.py +89 -0
  2. hyperspy/__init__.py +69 -0
  3. hyperspy/_components/__init__.py +0 -0
  4. hyperspy/_components/arctan.py +68 -0
  5. hyperspy/_components/bleasdale.py +101 -0
  6. hyperspy/_components/doniach.py +170 -0
  7. hyperspy/_components/error_function.py +70 -0
  8. hyperspy/_components/exponential.py +170 -0
  9. hyperspy/_components/expression.py +473 -0
  10. hyperspy/_components/gaussian.py +209 -0
  11. hyperspy/_components/gaussian2d.py +166 -0
  12. hyperspy/_components/gaussianhf.py +194 -0
  13. hyperspy/_components/heaviside.py +74 -0
  14. hyperspy/_components/logistic.py +74 -0
  15. hyperspy/_components/lorentzian.py +205 -0
  16. hyperspy/_components/offset.py +137 -0
  17. hyperspy/_components/polynomial.py +157 -0
  18. hyperspy/_components/power_law.py +188 -0
  19. hyperspy/_components/rc.py +69 -0
  20. hyperspy/_components/scalable_fixed_pattern.py +152 -0
  21. hyperspy/_components/skew_normal.py +269 -0
  22. hyperspy/_components/split_voigt.py +233 -0
  23. hyperspy/_components/voigt.py +210 -0
  24. hyperspy/_lazy_signals.py +38 -0
  25. hyperspy/_signals/__init__.py +0 -0
  26. hyperspy/_signals/common_signal1d.py +55 -0
  27. hyperspy/_signals/common_signal2d.py +42 -0
  28. hyperspy/_signals/complex_signal.py +376 -0
  29. hyperspy/_signals/complex_signal1d.py +38 -0
  30. hyperspy/_signals/complex_signal2d.py +125 -0
  31. hyperspy/_signals/lazy.py +1308 -0
  32. hyperspy/_signals/signal1d.py +1574 -0
  33. hyperspy/_signals/signal2d.py +1059 -0
  34. hyperspy/api.py +48 -0
  35. hyperspy/api_nogui.py +159 -0
  36. hyperspy/axes.py +2465 -0
  37. hyperspy/component.py +1323 -0
  38. hyperspy/components1d.py +71 -0
  39. hyperspy/components2d.py +72 -0
  40. hyperspy/conftest.py +88 -0
  41. hyperspy/data/__init__.py +40 -0
  42. hyperspy/data/artificial_data.py +233 -0
  43. hyperspy/data/two_gaussians.py +94 -0
  44. hyperspy/decorators.py +263 -0
  45. hyperspy/defaults_parser.py +241 -0
  46. hyperspy/docstrings/__init__.py +19 -0
  47. hyperspy/docstrings/markers.py +33 -0
  48. hyperspy/docstrings/model.py +103 -0
  49. hyperspy/docstrings/parameters.py +27 -0
  50. hyperspy/docstrings/plot.py +195 -0
  51. hyperspy/docstrings/signal.py +175 -0
  52. hyperspy/docstrings/signal1d.py +89 -0
  53. hyperspy/docstrings/utils.py +62 -0
  54. hyperspy/drawing/__init__.py +17 -0
  55. hyperspy/drawing/_markers/__init__.py +17 -0
  56. hyperspy/drawing/_markers/arrows.py +88 -0
  57. hyperspy/drawing/_markers/circles.py +74 -0
  58. hyperspy/drawing/_markers/ellipses.py +79 -0
  59. hyperspy/drawing/_markers/horizontal_lines.py +88 -0
  60. hyperspy/drawing/_markers/lines.py +58 -0
  61. hyperspy/drawing/_markers/points.py +65 -0
  62. hyperspy/drawing/_markers/polygons.py +82 -0
  63. hyperspy/drawing/_markers/rectangles.py +80 -0
  64. hyperspy/drawing/_markers/squares.py +79 -0
  65. hyperspy/drawing/_markers/texts.py +58 -0
  66. hyperspy/drawing/_markers/vertical_lines.py +85 -0
  67. hyperspy/drawing/_widgets/__init__.py +17 -0
  68. hyperspy/drawing/_widgets/circle.py +211 -0
  69. hyperspy/drawing/_widgets/horizontal_line.py +55 -0
  70. hyperspy/drawing/_widgets/label.py +110 -0
  71. hyperspy/drawing/_widgets/line2d.py +478 -0
  72. hyperspy/drawing/_widgets/range.py +226 -0
  73. hyperspy/drawing/_widgets/rectangles.py +494 -0
  74. hyperspy/drawing/_widgets/scalebar.py +147 -0
  75. hyperspy/drawing/_widgets/vertical_line.py +55 -0
  76. hyperspy/drawing/figure.py +141 -0
  77. hyperspy/drawing/image.py +694 -0
  78. hyperspy/drawing/markers.py +1056 -0
  79. hyperspy/drawing/mpl_he.py +261 -0
  80. hyperspy/drawing/mpl_hie.py +63 -0
  81. hyperspy/drawing/mpl_hse.py +180 -0
  82. hyperspy/drawing/signal.py +134 -0
  83. hyperspy/drawing/signal1d.py +598 -0
  84. hyperspy/drawing/tiles.py +90 -0
  85. hyperspy/drawing/utils.py +1700 -0
  86. hyperspy/drawing/widget.py +1018 -0
  87. hyperspy/drawing/widgets.py +37 -0
  88. hyperspy/events.py +560 -0
  89. hyperspy/exceptions.py +163 -0
  90. hyperspy/extensions.py +88 -0
  91. hyperspy/external/__init__.py +0 -0
  92. hyperspy/external/astropy/__init__.py +0 -0
  93. hyperspy/external/astropy/bayesian_blocks.py +516 -0
  94. hyperspy/external/astropy/histogram.py +171 -0
  95. hyperspy/external/matplotlib/_api.py +61 -0
  96. hyperspy/external/matplotlib/collections.py +481 -0
  97. hyperspy/external/matplotlib/path.py +13 -0
  98. hyperspy/external/matplotlib/quiver.py +383 -0
  99. hyperspy/external/matplotlib/widgets.py +795 -0
  100. hyperspy/external/mpfit/__init__.py +0 -0
  101. hyperspy/external/mpfit/mpfit.py +2037 -0
  102. hyperspy/external/progressbar.py +46 -0
  103. hyperspy/hyperspy_extension.yaml +171 -0
  104. hyperspy/interactive.py +144 -0
  105. hyperspy/io.py +952 -0
  106. hyperspy/learn/__init__.py +17 -0
  107. hyperspy/learn/mlpca.py +155 -0
  108. hyperspy/learn/mva.py +2801 -0
  109. hyperspy/learn/ornmf.py +442 -0
  110. hyperspy/learn/orthomax.py +121 -0
  111. hyperspy/learn/rpca.py +585 -0
  112. hyperspy/learn/svd_pca.py +278 -0
  113. hyperspy/learn/whitening.py +90 -0
  114. hyperspy/logger.py +120 -0
  115. hyperspy/misc/__init__.py +17 -0
  116. hyperspy/misc/array_tools.py +645 -0
  117. hyperspy/misc/axis_tools.py +56 -0
  118. hyperspy/misc/dask_widgets/lazy_signal.html.j2 +65 -0
  119. hyperspy/misc/export_dictionary.py +209 -0
  120. hyperspy/misc/hist_tools.py +291 -0
  121. hyperspy/misc/ipython_tools.py +100 -0
  122. hyperspy/misc/lowess_smooth.py +88 -0
  123. hyperspy/misc/machine_learning/__init__.py +0 -0
  124. hyperspy/misc/machine_learning/import_sklearn.py +40 -0
  125. hyperspy/misc/machine_learning/tools.py +61 -0
  126. hyperspy/misc/math_tools.py +249 -0
  127. hyperspy/misc/model_tools.py +218 -0
  128. hyperspy/misc/signal_tools.py +198 -0
  129. hyperspy/misc/slicing.py +338 -0
  130. hyperspy/misc/test_utils.py +140 -0
  131. hyperspy/misc/tv_denoise.py +377 -0
  132. hyperspy/misc/utils.py +1641 -0
  133. hyperspy/model.py +2553 -0
  134. hyperspy/models/__init__.py +17 -0
  135. hyperspy/models/model1d.py +957 -0
  136. hyperspy/models/model2d.py +418 -0
  137. hyperspy/roi.py +1474 -0
  138. hyperspy/samfire.py +615 -0
  139. hyperspy/samfire_utils/__init__.py +0 -0
  140. hyperspy/samfire_utils/fit_tests.py +38 -0
  141. hyperspy/samfire_utils/global_strategies.py +36 -0
  142. hyperspy/samfire_utils/goodness_of_fit_tests/__init__.py +0 -0
  143. hyperspy/samfire_utils/goodness_of_fit_tests/information_theory.py +102 -0
  144. hyperspy/samfire_utils/goodness_of_fit_tests/red_chisq.py +38 -0
  145. hyperspy/samfire_utils/goodness_of_fit_tests/test_general.py +33 -0
  146. hyperspy/samfire_utils/local_strategies.py +49 -0
  147. hyperspy/samfire_utils/samfire_kernel.py +242 -0
  148. hyperspy/samfire_utils/samfire_pool.py +392 -0
  149. hyperspy/samfire_utils/samfire_worker.py +304 -0
  150. hyperspy/samfire_utils/segmenters/__init__.py +1 -0
  151. hyperspy/samfire_utils/segmenters/histogram.py +82 -0
  152. hyperspy/samfire_utils/strategy.py +546 -0
  153. hyperspy/samfire_utils/weights/__init__.py +0 -0
  154. hyperspy/samfire_utils/weights/red_chisq.py +35 -0
  155. hyperspy/signal.py +6703 -0
  156. hyperspy/signal_tools.py +2077 -0
  157. hyperspy/signals.py +60 -0
  158. hyperspy/tests/__init__.py +50 -0
  159. hyperspy/tests/axes/__init__.py +0 -0
  160. hyperspy/tests/axes/test_axes_manager.py +586 -0
  161. hyperspy/tests/axes/test_conversion_units.py +470 -0
  162. hyperspy/tests/axes/test_data_axis.py +771 -0
  163. hyperspy/tests/component/__init__.py +0 -0
  164. hyperspy/tests/component/data/hs14_model.hspy +0 -0
  165. hyperspy/tests/component/data/hs15_model.hspy +0 -0
  166. hyperspy/tests/component/data/hs16_model.hspy +0 -0
  167. hyperspy/tests/component/data/hs2.0_custom_component.hspy +0 -0
  168. hyperspy/tests/component/test_arctan.py +34 -0
  169. hyperspy/tests/component/test_backcompatibility.py +133 -0
  170. hyperspy/tests/component/test_bleasdale.py +47 -0
  171. hyperspy/tests/component/test_component.py +367 -0
  172. hyperspy/tests/component/test_component_active_array.py +64 -0
  173. hyperspy/tests/component/test_component_print_current.py +131 -0
  174. hyperspy/tests/component/test_component_set_parameters.py +80 -0
  175. hyperspy/tests/component/test_components.py +458 -0
  176. hyperspy/tests/component/test_components2D.py +233 -0
  177. hyperspy/tests/component/test_doniach.py +67 -0
  178. hyperspy/tests/component/test_erf.py +31 -0
  179. hyperspy/tests/component/test_exponential.py +100 -0
  180. hyperspy/tests/component/test_expression.py +148 -0
  181. hyperspy/tests/component/test_gaussian.py +142 -0
  182. hyperspy/tests/component/test_gaussian2d.py +132 -0
  183. hyperspy/tests/component/test_gaussianhf.py +138 -0
  184. hyperspy/tests/component/test_heaviside.py +29 -0
  185. hyperspy/tests/component/test_logistic.py +32 -0
  186. hyperspy/tests/component/test_lorentzian.py +131 -0
  187. hyperspy/tests/component/test_powerlaw.py +88 -0
  188. hyperspy/tests/component/test_rc.py +32 -0
  189. hyperspy/tests/component/test_skewnormal.py +127 -0
  190. hyperspy/tests/component/test_splitvoigt.py +112 -0
  191. hyperspy/tests/component/test_voigt.py +138 -0
  192. hyperspy/tests/drawing/__init__.py +0 -0
  193. hyperspy/tests/drawing/data/Cr_L_cl.hspy +0 -0
  194. hyperspy/tests/drawing/data/signal_markers_hs1_7_5.hspy +0 -0
  195. hyperspy/tests/drawing/test_figure.py +110 -0
  196. hyperspy/tests/drawing/test_horizontal_plotting.py +58 -0
  197. hyperspy/tests/drawing/test_markers.py +1192 -0
  198. hyperspy/tests/drawing/test_mpl_testing_setup.py +56 -0
  199. hyperspy/tests/drawing/test_plot_histograms.py +28 -0
  200. hyperspy/tests/drawing/test_plot_lazy.py +136 -0
  201. hyperspy/tests/drawing/test_plot_model.py +138 -0
  202. hyperspy/tests/drawing/test_plot_model1d.py +69 -0
  203. hyperspy/tests/drawing/test_plot_mva.py +228 -0
  204. hyperspy/tests/drawing/test_plot_roi_widgets.py +246 -0
  205. hyperspy/tests/drawing/test_plot_signal.py +348 -0
  206. hyperspy/tests/drawing/test_plot_signal1d.py +460 -0
  207. hyperspy/tests/drawing/test_plot_signal2d.py +761 -0
  208. hyperspy/tests/drawing/test_plot_signal_tools.py +306 -0
  209. hyperspy/tests/drawing/test_plot_widgets.py +519 -0
  210. hyperspy/tests/drawing/test_texts.py +110 -0
  211. hyperspy/tests/drawing/test_utils.py +47 -0
  212. hyperspy/tests/drawing/test_widget.py +152 -0
  213. hyperspy/tests/learn/__init__.py +0 -0
  214. hyperspy/tests/learn/test_bss.py +512 -0
  215. hyperspy/tests/learn/test_cluster.py +456 -0
  216. hyperspy/tests/learn/test_decomposition.py +684 -0
  217. hyperspy/tests/learn/test_export.py +51 -0
  218. hyperspy/tests/learn/test_lazy_decomposition.py +246 -0
  219. hyperspy/tests/learn/test_learning_results.py +52 -0
  220. hyperspy/tests/learn/test_mlpca.py +82 -0
  221. hyperspy/tests/learn/test_ornmf.py +127 -0
  222. hyperspy/tests/learn/test_rpca.py +233 -0
  223. hyperspy/tests/learn/test_svd_pca.py +163 -0
  224. hyperspy/tests/learn/test_whitening.py +48 -0
  225. hyperspy/tests/misc/__init__.py +0 -0
  226. hyperspy/tests/misc/test_array_tools.py +178 -0
  227. hyperspy/tests/misc/test_axis_tools.py +46 -0
  228. hyperspy/tests/misc/test_dictionary_tree_browser.py +561 -0
  229. hyperspy/tests/misc/test_hist_tools.py +97 -0
  230. hyperspy/tests/misc/test_image_tools.py +50 -0
  231. hyperspy/tests/misc/test_math_tools.py +82 -0
  232. hyperspy/tests/misc/test_signal_tools.py +29 -0
  233. hyperspy/tests/misc/test_test_utils.py +102 -0
  234. hyperspy/tests/misc/test_tv_denoise.py +57 -0
  235. hyperspy/tests/misc/test_utils.py +178 -0
  236. hyperspy/tests/model/__init__.py +0 -0
  237. hyperspy/tests/model/test_chi_squared.py +118 -0
  238. hyperspy/tests/model/test_constant.py +67 -0
  239. hyperspy/tests/model/test_fancy_indexing.py +116 -0
  240. hyperspy/tests/model/test_fit_component.py +242 -0
  241. hyperspy/tests/model/test_fitting.py +656 -0
  242. hyperspy/tests/model/test_linear_model.py +827 -0
  243. hyperspy/tests/model/test_linearity.py +115 -0
  244. hyperspy/tests/model/test_model.py +788 -0
  245. hyperspy/tests/model/test_model2d.py +294 -0
  246. hyperspy/tests/model/test_model_as_dictionary.py +249 -0
  247. hyperspy/tests/model/test_model_selection_criteria.py +54 -0
  248. hyperspy/tests/model/test_model_storing.py +200 -0
  249. hyperspy/tests/model/test_parameter.py +398 -0
  250. hyperspy/tests/model/test_set_parameter_state.py +178 -0
  251. hyperspy/tests/model/test_set_parameter_value.py +113 -0
  252. hyperspy/tests/samfire/__init__.py +0 -0
  253. hyperspy/tests/samfire/test_goodness_of_fit_tests.py +118 -0
  254. hyperspy/tests/samfire/test_histogram_segmenter.py +86 -0
  255. hyperspy/tests/samfire/test_red_chisq_weight.py +44 -0
  256. hyperspy/tests/samfire/test_samfire.py +549 -0
  257. hyperspy/tests/samfire/test_strategy.py +525 -0
  258. hyperspy/tests/samfire/test_strategy_list.py +58 -0
  259. hyperspy/tests/samfire/test_utils.py +72 -0
  260. hyperspy/tests/signals/__init__.py +0 -0
  261. hyperspy/tests/signals/data/test_find_peaks1D_ohaver.hdf5 +0 -0
  262. hyperspy/tests/signals/test_1D.py +52 -0
  263. hyperspy/tests/signals/test_1D_tools.py +420 -0
  264. hyperspy/tests/signals/test_2D.py +471 -0
  265. hyperspy/tests/signals/test_2D_tools.py +391 -0
  266. hyperspy/tests/signals/test_3D.py +353 -0
  267. hyperspy/tests/signals/test_4D.py +91 -0
  268. hyperspy/tests/signals/test_apodization.py +132 -0
  269. hyperspy/tests/signals/test_assign_subclass.py +185 -0
  270. hyperspy/tests/signals/test_binned.py +55 -0
  271. hyperspy/tests/signals/test_check_mask.py +81 -0
  272. hyperspy/tests/signals/test_complex_signal.py +217 -0
  273. hyperspy/tests/signals/test_complex_signal2d.py +37 -0
  274. hyperspy/tests/signals/test_copy.py +33 -0
  275. hyperspy/tests/signals/test_cuda.py +180 -0
  276. hyperspy/tests/signals/test_fancy_indexing.py +407 -0
  277. hyperspy/tests/signals/test_find_peaks1D_ohaver.py +44 -0
  278. hyperspy/tests/signals/test_find_peaks2D.py +246 -0
  279. hyperspy/tests/signals/test_folding.py +151 -0
  280. hyperspy/tests/signals/test_fourier_transform.py +174 -0
  281. hyperspy/tests/signals/test_image.py +65 -0
  282. hyperspy/tests/signals/test_image_contrast_editor_tool.py +111 -0
  283. hyperspy/tests/signals/test_inheritance.py +33 -0
  284. hyperspy/tests/signals/test_interpolate_on_axis.py +257 -0
  285. hyperspy/tests/signals/test_lazy.py +429 -0
  286. hyperspy/tests/signals/test_lazy_tools.py +135 -0
  287. hyperspy/tests/signals/test_linear_rebin.py +93 -0
  288. hyperspy/tests/signals/test_map_method.py +1173 -0
  289. hyperspy/tests/signals/test_mask.py +37 -0
  290. hyperspy/tests/signals/test_obj_in_dict2hspy.py +70 -0
  291. hyperspy/tests/signals/test_ragged_signal.py +129 -0
  292. hyperspy/tests/signals/test_remove_background.py +298 -0
  293. hyperspy/tests/signals/test_rgb.py +87 -0
  294. hyperspy/tests/signals/test_signal_operators.py +157 -0
  295. hyperspy/tests/signals/test_signal_subclass_conversion.py +109 -0
  296. hyperspy/tests/signals/test_spectrum.py +65 -0
  297. hyperspy/tests/signals/test_spike_removal_tool.py +112 -0
  298. hyperspy/tests/signals/test_tools.py +360 -0
  299. hyperspy/tests/signals/test_transpose.py +151 -0
  300. hyperspy/tests/test_data.py +54 -0
  301. hyperspy/tests/test_decorators.py +134 -0
  302. hyperspy/tests/test_events.py +454 -0
  303. hyperspy/tests/test_extension_registry.py +67 -0
  304. hyperspy/tests/test_import.py +253 -0
  305. hyperspy/tests/test_interactive.py +160 -0
  306. hyperspy/tests/test_io.py +342 -0
  307. hyperspy/tests/test_non-uniform_not-implemented.py +71 -0
  308. hyperspy/tests/utils/__init__.py +0 -0
  309. hyperspy/tests/utils/test_attrsetter.py +68 -0
  310. hyperspy/tests/utils/test_parallel_pool.py +40 -0
  311. hyperspy/tests/utils/test_print_known_signal_types.py +9 -0
  312. hyperspy/tests/utils/test_roi.py +768 -0
  313. hyperspy/tests/utils/test_slugify.py +23 -0
  314. hyperspy/tests/utils/test_stack.py +219 -0
  315. hyperspy/tests/utils/test_stack_calibration.py +82 -0
  316. hyperspy/ui_registry.py +197 -0
  317. hyperspy/utils/__init__.py +115 -0
  318. hyperspy/utils/markers.py +66 -0
  319. hyperspy/utils/model.py +43 -0
  320. hyperspy/utils/model_selection.py +77 -0
  321. hyperspy/utils/parallel_pool.py +182 -0
  322. hyperspy/utils/peakfinders2D.py +591 -0
  323. hyperspy/utils/plot.py +58 -0
  324. hyperspy/utils/roi.py +44 -0
  325. hyperspy/utils/samfire.py +55 -0
  326. hyperspy-2.0rc0.dist-info/AUTHORS.txt +3 -0
  327. hyperspy-2.0rc0.dist-info/COPYING.txt +674 -0
  328. hyperspy-2.0rc0.dist-info/METADATA +170 -0
  329. hyperspy-2.0rc0.dist-info/RECORD +331 -0
  330. hyperspy-2.0rc0.dist-info/WHEEL +5 -0
  331. hyperspy-2.0rc0.dist-info/top_level.txt +1 -0
hyperspy/Release.py ADDED
@@ -0,0 +1,89 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2007-2023 The HyperSpy developers
3
+ #
4
+ # This file is part of HyperSpy.
5
+ #
6
+ # HyperSpy is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # HyperSpy is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with HyperSpy. If not, see <https://www.gnu.org/licenses/#GPL>.
18
+
19
+ name = 'hyperspy'
20
+
21
+ # The commit following to a release must update the version number
22
+ # to the version number of the release followed by ".dev", e.g.
23
+ # if the version of the last release is 0.4.1 the version of the
24
+ # next development version afterwards must be 0.4.1.dev.
25
+ # When running setup.py the ".dev" string will be replaced (if possible)
26
+ # by the output of "git describe" if git is available or the git
27
+ # hash if .git is present.
28
+ version = "2.0rc0"
29
+ __version__ = version
30
+ description = "Multidimensional data analysis toolbox"
31
+ license = 'GPL v3'
32
+
33
+ authors = {
34
+ 'all': ('The HyperSpy developers',), }
35
+
36
+ url = 'https://hyperspy.org'
37
+
38
+ download_url = 'https://www.hyperspy.org'
39
+ documentation_url = 'https://hyperspy.org/hyperspy-doc/current/index.html'
40
+
41
+ PROJECT_URLS = {
42
+ 'Bug Tracker': 'https://github.com/hyperspy/hyperspy/issues',
43
+ 'Documentation': 'https://hyperspy.org/hyperspy-doc/current/index.html',
44
+ 'Source Code': 'https://github.com/hyperspy/hyperspy',
45
+ 'Support' : 'https://gitter.im/hyperspy/hyperspy'
46
+ }
47
+
48
+ platforms = ['Linux', 'Mac OSX', 'Windows XP/2000/NT', 'Windows 95/98/ME']
49
+
50
+ keywords = ['EDX',
51
+ 'EELS',
52
+ 'EFTEM',
53
+ 'EMSA',
54
+ 'FEI',
55
+ 'ICA',
56
+ 'PCA',
57
+ 'PES',
58
+ 'STEM',
59
+ 'TEM',
60
+ 'curve fitting',
61
+ 'data analysis',
62
+ 'dm3',
63
+ 'electron energy loss spectroscopy',
64
+ 'electron microscopy',
65
+ 'emi',
66
+ 'energy dispersive x-rays',
67
+ 'hyperspectral',
68
+ 'hyperspectrum',
69
+ 'multidimensional',
70
+ 'hyperspy',
71
+ 'machine learning',
72
+ 'microscopy',
73
+ 'model',
74
+ 'msa',
75
+ 'numpy',
76
+ 'python',
77
+ 'quantification',
78
+ 'scipy',
79
+ 'ser',
80
+ 'spectroscopy',
81
+ 'spectrum image']
82
+
83
+ info = """
84
+ H y p e r S p y
85
+ Version %s
86
+
87
+ https://www.hyperspy.org
88
+
89
+ """ % version.replace('_', ' ')
hyperspy/__init__.py ADDED
@@ -0,0 +1,69 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2007-2023 The HyperSpy developers
3
+ #
4
+ # This file is part of HyperSpy.
5
+ #
6
+ # HyperSpy is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # HyperSpy is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with HyperSpy. If not, see <https://www.gnu.org/licenses/#GPL>.
18
+
19
+ import importlib
20
+ import logging
21
+ from hyperspy import docstrings
22
+
23
+ _logger = logging.getLogger(__name__)
24
+
25
+
26
+ __doc__ = """
27
+ HyperSpy: a multi-dimensional data analysis package for Python
28
+ ==============================================================
29
+
30
+ Documentation is available in the docstrings and online at
31
+ https://hyperspy.org/hyperspy-doc/current/index.html.
32
+
33
+ All public packages, functions and classes are in :mod:`~hyperspy.api`. All
34
+ other packages and modules are for internal consumption and should not be
35
+ needed for data analysis.
36
+
37
+ %s
38
+
39
+ More details in the :mod:`~hyperspy.api` docstring.
40
+
41
+ """ % docstrings.START_HSPY
42
+
43
+
44
+ __all__ = [
45
+ "api",
46
+ "__version__"
47
+ ]
48
+
49
+
50
+ def __dir__():
51
+ return sorted(__all__)
52
+
53
+
54
+ _import_mapping = {
55
+ '__version__':'.Release',
56
+ }
57
+
58
+
59
+ def __getattr__(name):
60
+ if name in __all__:
61
+ if name in _import_mapping.keys():
62
+ import_path = 'hyperspy' + _import_mapping.get(name)
63
+ return getattr(importlib.import_module(import_path), name)
64
+ else: # pragma: no cover
65
+ # We can't get this block covered in the test suite because it is
66
+ # already imported, when running the test suite.
67
+ # If this is broken, a lot of things will be broken!
68
+ return importlib.import_module("." + name, 'hyperspy')
69
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
File without changes
@@ -0,0 +1,68 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2007-2023 The HyperSpy developers
3
+ #
4
+ # This file is part of HyperSpy.
5
+ #
6
+ # HyperSpy is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # HyperSpy is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with HyperSpy. If not, see <https://www.gnu.org/licenses/#GPL>.
18
+
19
+
20
+ from hyperspy._components.expression import Expression
21
+
22
+
23
+ class Arctan(Expression):
24
+
25
+ r"""Arctan function component.
26
+
27
+ .. math::
28
+
29
+ f(x) = A \cdot \arctan \left[ k \left( x-x_0 \right) \right]
30
+
31
+
32
+ ============ =============
33
+ Variable Parameter
34
+ ============ =============
35
+ :math:`A` A
36
+ :math:`k` k
37
+ :math:`x_0` x0
38
+ ============ =============
39
+
40
+
41
+ Parameters
42
+ -----------
43
+ A : float
44
+ Amplitude parameter. :math:`\lim_{x\to -\infty}f(x)=-A` and
45
+ :math:`\lim_{x\to\infty}f(x)=A`
46
+ k : float
47
+ Slope (steepness of the step). The larger :math:`k`, the sharper the
48
+ step.
49
+ x0 : float
50
+ Center parameter (position of zero crossing :math:`f(x_0)=0`).
51
+
52
+ """
53
+
54
+ def __init__(self, A=1., k=1., x0=1., module=["numpy", "scipy"], **kwargs):
55
+ # To be able to still read old file versions that contain this argument
56
+ if "minimum_at_zero" in kwargs:
57
+ del kwargs["minimum_at_zero"]
58
+ super().__init__(
59
+ expression="A * arctan(k * (x - x0))",
60
+ name="Arctan",
61
+ A=A,
62
+ k=k,
63
+ x0=x0,
64
+ position="x0",
65
+ module=module,
66
+ autodoc=False,
67
+ **kwargs,
68
+ )
@@ -0,0 +1,101 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2007-2023 The HyperSpy developers
3
+ #
4
+ # This file is part of HyperSpy.
5
+ #
6
+ # HyperSpy is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # HyperSpy is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with HyperSpy. If not, see <https://www.gnu.org/licenses/#GPL>.
18
+
19
+ import numpy as np
20
+
21
+ from hyperspy._components.expression import Expression
22
+
23
+ class Bleasdale(Expression):
24
+
25
+ r"""Bleasdale function component.
26
+
27
+ Also called the Bleasdale-Nelder function. Originates from
28
+ the description of the yield-density relationship in crop growth.
29
+
30
+ .. math::
31
+
32
+ f(x) = \left(a+b\cdot x\right)^{-1/c}
33
+
34
+ Parameters
35
+ ----------
36
+ a : float, default=1.0
37
+ The value of Parameter a.
38
+ b : float, default=1.0
39
+ The value of Parameter b.
40
+ c : float, default=1.0
41
+ The value of Parameter c.
42
+ **kwargs
43
+ Extra keyword arguments are passed to
44
+ :py:class:`~.api.model.components1D.Expression`.
45
+
46
+ Note
47
+ ----
48
+ For :math:`(a+b\cdot x)\leq0`, the component will be set to 0.
49
+
50
+ """
51
+
52
+ def __init__(self, a=1., b=1., c=1., module=None, **kwargs):
53
+ super().__init__(
54
+ expression="where((a + b * x) > 0, pow(a + b * x, -1 / c), 0)",
55
+ name="Bleasdale",
56
+ a=a,
57
+ b=b,
58
+ c=c,
59
+ module=module,
60
+ autodoc=False,
61
+ compute_gradients=False,
62
+ linear_parameter_list=['b'],
63
+ check_parameter_linearity=False,
64
+ **kwargs)
65
+ module = self._whitelist['module'][1]
66
+ if module in ("numpy", "scipy"):
67
+ # Issue with calculating component at 0...
68
+ raise ValueError(
69
+ f"{module} is not supported for this component, use numexpr instead."
70
+ )
71
+
72
+ def grad_a(self, x):
73
+ """
74
+ Returns d(function)/d(parameter_1)
75
+ """
76
+ a = self.a.value
77
+ b = self.b.value
78
+ c = self.c.value
79
+
80
+ return np.where((a + b * x) > 0, -(a + b * x) ** (-1 / c - 1) / c, 0)
81
+
82
+ def grad_b(self, x):
83
+ """
84
+ Returns d(function)/d(parameter_1)
85
+ """
86
+ a = self.a.value
87
+ b = self.b.value
88
+ c = self.c.value
89
+
90
+ return np.where((a + b * x) > 0, -x * (a + b * x) ** (-1 / c - 1) / c
91
+ , 0)
92
+
93
+ def grad_c(self, x):
94
+ """
95
+ Returns d(function)/d(parameter_1)
96
+ """
97
+ a = self.a.value
98
+ b = self.b.value
99
+ c = self.c.value
100
+ return np.where((a + b * x) > 0, np.log(a + b * x) / (c ** 2. *
101
+ (b * x + a) ** (1. / c)), 0)
@@ -0,0 +1,170 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2007-2023 The HyperSpy developers
3
+ #
4
+ # This file is part of HyperSpy.
5
+ #
6
+ # HyperSpy is free software: you can redistribute it and/or modify
7
+ # it under the terms of GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # HyperSpy is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with HyperSpy. If not, see <https://www.gnu.org/licenses/#GPL>.
18
+
19
+ import math
20
+ import numpy as np
21
+
22
+ from hyperspy.component import _get_scaling_factor
23
+ from hyperspy._components.expression import Expression
24
+ from hyperspy._components.gaussian import _estimate_gaussian_parameters
25
+
26
+ sqrt2pi = math.sqrt(2 * math.pi)
27
+
28
+
29
+ tiny = np.finfo(float).eps
30
+
31
+
32
+ class Doniach(Expression):
33
+
34
+ r""" Doniach Sunjic lineshape component.
35
+
36
+ .. math::
37
+ :nowrap:
38
+
39
+ \[
40
+ f(x) = \frac{A \cos[ \frac{{\pi\alpha}}{2}+
41
+ (1-\alpha)\tan^{-1}(\frac{x-centre+dx}{\sigma})]}
42
+ {(\sigma^2 + (x-centre+dx)^2)^{\frac{(1-\alpha)}{2}}}
43
+ \]
44
+
45
+
46
+ \[
47
+ dx = \frac{2.354820\sigma}{2 tan[\frac{\pi}{2-\alpha}]}
48
+ \]
49
+
50
+
51
+ =============== ===========
52
+ Variable Parameter
53
+ =============== ===========
54
+ :math:`A` A
55
+ :math:`\sigma` sigma
56
+ :math:`\alpha` alpha
57
+ :math:`centre` centre
58
+ =============== ===========
59
+
60
+ Parameters
61
+ -----------
62
+ A : float
63
+ Height
64
+ sigma : float
65
+ Variance parameter of the distribution
66
+ alpha : float
67
+ Tail or asymmetry parameter
68
+ centre : float
69
+ Location of the maximum (peak position).
70
+ **kwargs
71
+ Extra keyword arguments are passed to the
72
+ :py:class:`~._components.expression.Expression` component.
73
+
74
+ Note
75
+ -----
76
+ This is an asymmetric lineshape, originially design for xps but generally
77
+ useful for fitting peaks with low side tails
78
+ See Doniach S. and Sunjic M., J. Phys. 4C31, 285 (1970)
79
+ or http://www.casaxps.com/help_manual/line_shapes.htm for a more detailed
80
+ description
81
+
82
+ """
83
+
84
+ def __init__(self, centre=0., A=1., sigma=1., alpha=0.5,
85
+ module=["numpy", "scipy"], **kwargs):
86
+ super().__init__(
87
+ expression="A*cos(0.5*pi*alpha+\
88
+ ((1.0 - alpha) * arctan( (x-centre+offset)/sigma) ) )\
89
+ /(sigma**2 + (x-centre+offset)**2)**(0.5 * (1.0 - alpha));\
90
+ offset = 2.354820*sigma / (2 * tan(pi / (2 - alpha)))",
91
+ name="Doniach",
92
+ centre=centre,
93
+ A=A,
94
+ sigma=sigma,
95
+ alpha=alpha,
96
+ module=module,
97
+ autodoc=False,
98
+ **kwargs,
99
+ )
100
+ #
101
+ self.sigma.bmin = 1.0e-8
102
+ self.alpha.bmin = 1.0e-8
103
+ self.isbackground = False
104
+ self.convolved = True
105
+
106
+ def estimate_parameters(self, signal, x1, x2, only_current=False):
107
+ """Estimate the Donach by calculating the median (centre) and the
108
+ variance parameter (sigma).
109
+
110
+ Note that an insufficient range will affect the accuracy of this
111
+ method and that this method doesn't estimate the asymmetry parameter
112
+ (alpha).
113
+
114
+ Parameters
115
+ ----------
116
+ signal : Signal1D instance
117
+ x1 : float
118
+ Defines the left limit of the spectral range to use for the
119
+ estimation.
120
+ x2 : float
121
+ Defines the right limit of the spectral range to use for the
122
+ estimation.
123
+
124
+ only_current : bool
125
+ If False estimates the parameters for the full dataset.
126
+
127
+ Returns
128
+ -------
129
+ bool
130
+ Returns True when the parameters estimation is successful
131
+
132
+ Examples
133
+ --------
134
+
135
+ >>> g = hs.model.components1D.Lorentzian()
136
+ >>> x = np.arange(-10, 10, 0.01)
137
+ >>> data = np.zeros((32, 32, 2000))
138
+ >>> data[:] = g.function(x).reshape((1, 1, 2000))
139
+ >>> s = hs.signals.Signal1D(data)
140
+ >>> s.axes_manager[-1].offset = -10
141
+ >>> s.axes_manager[-1].scale = 0.01
142
+ >>> g.estimate_parameters(s, -10, 10, False)
143
+ """
144
+
145
+ super()._estimate_parameters(signal)
146
+ axis = signal.axes_manager.signal_axes[0]
147
+ centre, height, sigma = _estimate_gaussian_parameters(signal, x1, x2,
148
+ only_current)
149
+ scaling_factor = _get_scaling_factor(signal, axis, centre)
150
+
151
+ if only_current is True:
152
+ self.centre.value = centre
153
+ self.sigma.value = sigma
154
+ self.A.value = height * 1.3
155
+ if axis.is_binned:
156
+ self.A.value /= scaling_factor
157
+ return True
158
+ else:
159
+ if self.A.map is None:
160
+ self._create_arrays()
161
+ self.A.map['values'][:] = height * 1.3
162
+ if axis.is_binned:
163
+ self.A.map['values'][:] /= scaling_factor
164
+ self.A.map['is_set'][:] = True
165
+ self.sigma.map['values'][:] = sigma
166
+ self.sigma.map['is_set'][:] = True
167
+ self.centre.map['values'][:] = centre
168
+ self.centre.map['is_set'][:] = True
169
+ self.fetch_stored_values()
170
+ return True
@@ -0,0 +1,70 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2007-2023 The HyperSpy developers
3
+ #
4
+ # This file is part of HyperSpy.
5
+ #
6
+ # HyperSpy is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # HyperSpy is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with HyperSpy. If not, see <https://www.gnu.org/licenses/#GPL>.
18
+
19
+ from hyperspy._components.expression import Expression
20
+
21
+
22
+ class Erf(Expression):
23
+
24
+ r"""Error function component.
25
+
26
+ .. math::
27
+
28
+ f(x) = \frac{A}{2}~\mathrm{erf}\left[\frac{(x - x_0)}{\sqrt{2}
29
+ \sigma}\right]
30
+
31
+
32
+ ============== =============
33
+ Variable Parameter
34
+ ============== =============
35
+ :math:`A` A
36
+ :math:`\sigma` sigma
37
+ :math:`x_0` origin
38
+ ============== =============
39
+
40
+ Parameters
41
+ ----------
42
+ A : float
43
+ The min/max values of the distribution are -A/2 and A/2.
44
+ sigma : float
45
+ Width of the distribution.
46
+ origin : float
47
+ Position of the zero crossing.
48
+ **kwargs
49
+ Extra keyword arguments are passed to the
50
+ :py:class:`~._components.expression.Expression` component.
51
+ """
52
+
53
+ def __init__(self, A=1., sigma=1., origin=0., module=["numpy", "scipy"],
54
+ **kwargs):
55
+ super().__init__(
56
+ expression="A * erf((x - origin) / sqrt(2) / sigma) / 2",
57
+ name="Erf",
58
+ A=A,
59
+ sigma=sigma,
60
+ origin=origin,
61
+ module=module,
62
+ autodoc=False,
63
+ **kwargs,
64
+ )
65
+
66
+ # Boundaries
67
+ self.A.bmin = 0.
68
+
69
+ self.isbackground = False
70
+ self.convolved = True