diff --git a/bin/evaluate.py b/bin/evaluate.py index f5fc10a..a8a919e 100755 --- a/bin/evaluate.py +++ b/bin/evaluate.py @@ -2,7 +2,7 @@ import sys import pathlib -sys.path.append(str(pathlib.Path().cwd().parent)) +sys.path.append(str(pathlib.Path(__file__).parent.parent / 'src')) from nmreval.configs import check_for_config @@ -15,8 +15,8 @@ check_for_config() from nmreval.lib.logger import handle_exception sys.excepthook = handle_exception -from nmreval.gui_qt import App -from nmreval.gui_qt.main.mainwindow import NMRMainWindow +from gui_qt import App +from gui_qt.main.mainwindow import NMRMainWindow app = App([]) diff --git a/doc/Makefile b/doc/Makefile index 407565f..d471d93 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -4,7 +4,7 @@ # You can set these variables from the command line, and also # from the environment for the first two. SPHINXOPTS ?= -SPHINXBUILD ?= /autohome/dominik/miniconda3/bin/sphinx-build +SPHINXBUILD ?= # /autohome/dominik/miniconda3/bin/sphinx-build SOURCEDIR = /autohome/dominik/nmreval/doc/source BUILDDIR = /autohome/dominik/nmreval/doc/_build diff --git a/doc/examples/nmr/plot_RelaxationEvaluation.py b/doc/examples/nmr/plot_RelaxationEvaluation.py index d9252d8..2a182f9 100644 --- a/doc/examples/nmr/plot_RelaxationEvaluation.py +++ b/doc/examples/nmr/plot_RelaxationEvaluation.py @@ -1,16 +1,9 @@ """ -========== -T1 minimum -========== +================================ +Example of apodization functions +================================ -``RelaxationEvaluation`` is used to get width parameter from a T1 minimum. -As a subclass of ``Relaxation`` it can also be used to calculate Relaxation times. -The basic steps are: - -* Determine a T1 minimum with `nmreval.nmr.RelaxationEvaluation.calculate_t1_min` -* Calculate width parameter of a spectral density/coupling constants/... with - ``RelaxationEvaluation.get_increase`` -* Calculate correlation times from these values with ``RelaxationEvaluation.correlation_from_t1`` +This file """ import numpy as np import matplotlib.pyplot as plt diff --git a/doc/source/_static/fit_dialog.png b/doc/source/_static/fit_dialog.png deleted file mode 100644 index 559aa14..0000000 Binary files a/doc/source/_static/fit_dialog.png and /dev/null differ diff --git a/doc/source/_templates/autosummary/class.rst b/doc/source/_templates/autosummary/class.rst index 4eca388..3584823 100644 --- a/doc/source/_templates/autosummary/class.rst +++ b/doc/source/_templates/autosummary/class.rst @@ -3,25 +3,36 @@ .. currentmodule:: {{ module }} .. autoclass:: {{ objname }} + :exclude-members: {% for item in methods %}{%- if not item.startswith('_') or item in ['__call__'] %}{{ item }}, {% endif %}{%- endfor %} - {% block methods %} - + {%- block methods %} {% if methods %} - .. rubric:: {{ _('Methods') }} - - {% for item in methods %} - .. automethod:: {{ item }} - {%- endfor %} - {% endif %} - {% endblock %} - - {% block attributes %} - {% if attributes %} - .. rubric:: {{ _('Attributes') }} + .. rubric:: Methods .. autosummary:: - {% for item in attributes %} - ~{{ name }}.{{ item }} - {%- endfor %} + :toctree: + + {% for item in methods %} + {%- if not item.startswith('_') or item in ['__call__'] %} ~{{ name }}.{{ item }} {% endif %} - {% endblock %} + {%- endfor %} + {%- endif %} + {%- endblock %} + + {%- block attributes %} + {%- if attributes %} + .. rubric:: Properties + + .. autosummary:: + :toctree: + + {% for item in attributes %} + {%- if not item.startswith('_') or item in ['__call__'] %} ~{{ name }}.{{ item }} + {% endif %} + {%- endfor %} + {%- endif %} + {%- endblock %} + +.. _sphx_glr_backref_{{ fullname }}: +.. minigallery:: {{ objname }} + :add-heading: diff --git a/doc/source/api/distributions.rst b/doc/source/api/distributions.rst index c1489a3..85d4355 100644 --- a/doc/source/api/distributions.rst +++ b/doc/source/api/distributions.rst @@ -1,5 +1,2 @@ .. automodule:: nmreval.distributions :members: - :inherited-members: - :undoc-members: - diff --git a/doc/source/api/index.rst b/doc/source/api/index.rst index 10f0748..000f622 100644 --- a/doc/source/api/index.rst +++ b/doc/source/api/index.rst @@ -11,3 +11,4 @@ Reference models distributions nmr + math diff --git a/doc/source/conf.py b/doc/source/conf.py index 4f0356f..b7a6daa 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -12,7 +12,7 @@ # import os import sys -sys.path.append('/autohome/dominik/nmreval') +sys.path.append(os.path.abspath('../../src')) import nmreval @@ -43,6 +43,9 @@ extensions = [ 'sphinx.ext.viewcode', 'sphinx.ext.intersphinx', 'sphinx_gallery.gen_gallery', + 'sphinx.ext.todo', + 'sphinx.ext.autosectionlabel', + 'sphinx.ext.mathjax', ] # configuration for intersphinx @@ -56,7 +59,7 @@ intersphinx_mapping = { # # autodoc options autodoc_typehints = 'none' -autodoc_class_signature = 'separated' +# autodoc_class_signature = 'separated' autoclass_content = 'class' autodoc_member_order = 'groupwise' # @@ -79,6 +82,7 @@ sphinx_gallery_conf = { 'min_reported_time': 10000000000, 'show_memory': False, 'show_signature': False, + 'line_numbers': True, } # The suffix(es) of source filenames. @@ -151,15 +155,23 @@ todo_include_todos = False # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'pydata_sphinx_theme' +html_theme = 'sphinx_material' # 'sphinx_rtd_theme' # 'pydata_sphinx_theme' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. html_theme_options = { - 'collapse_navigation': False, - 'show_prev_next': False, - 'navbar_end': ['navbar-icon-links.html', 'search-field.html'], + 'nav_title': 'nmreval', + # 'base_url': 'https://chaos3.fkp.physik.tu-darmstadt.de/source/nmreval', + 'repo_url': 'https://chaos3.fkp.physik.tu-darmstadt.de/source/nmreval', + 'repo_name': 'Repo', + 'html_minify': True, + 'css_minify': True, + 'master_doc': False, + 'globaltoc_depth': 3, + 'globaltoc_collapse': True, + 'globaltoc_includehidden': True, + 'heroes': {'index': 'Fun for the whole family!!!!'} } # Add any paths that contain custom themes here, relative to this directory. @@ -183,10 +195,10 @@ html_static_path = ['_static'] html_logo = '_static/logo.png' # Custom sidebar templates, maps document names to template names. -html_sidebars = {'**': ['sidebar-nav-bs.html']} -# html_sidebars = { -# '**': ['localtoc.html', 'relations.html', 'sourcelink.html', 'searchbox.html'], -# } +html_sidebars = { + "**": ["logo-text.html", "globaltoc.html", "localtoc.html", "searchbox.html"] +} + # If true, links to the reST sources are added to the pages. html_show_sourcelink = False @@ -205,7 +217,7 @@ html_last_updated_fmt = '' html_additional_pages = {} # If false, no module index is generated. -html_domain_indices = False +html_domain_indices = True # If false, no index is generated. html_use_index = True @@ -214,10 +226,10 @@ html_use_index = True html_split_index = False # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -# html_show_sphinx = True +html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -# html_show_copyright = True +html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the diff --git a/doc/source/index.rst b/doc/source/index.rst index 6b3d246..8160915 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -10,15 +10,15 @@ NMREval documentation .. toctree:: :maxdepth: 1 + install.rst user_guide/index gallery/index api/index -Indices and tables -================== +Indices +======= -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` +| :ref:`genindex` +| :ref:`modindex` diff --git a/doc/source/nmr/pake.rst b/doc/source/nmr/pake.rst index 1e66f6d..c5ef757 100644 --- a/doc/source/nmr/pake.rst +++ b/doc/source/nmr/pake.rst @@ -11,7 +11,8 @@ In general, time signals are calculated by integration of all orientations (see .. math:: g(t) = \int f[\omega_\text{int}(\theta, \phi)t]\sin\theta\,\mathrm{d}\theta\,\mathrm{d}\phi -with :math:`f(\theta, \phi, t) = \cos[\omega_\text{int}(\theta, \phi) t]` or :math:`\exp[i\omega_\text{int}(\theta) t]` and fourier transform for a spectrum. +with :math:`f(\theta, \phi, t) = \cos[\omega_\text{int}(\theta, \phi) t]` or :math:`\exp[i\omega_\text{int}(\theta) t]` +and fourier transform for a spectrum. However, summation over :math:`\theta`, :math:`\phi`, and calculating :math:`f(\theta, \phi, t)` for each orientation is time consuming. Alternatively, if the orientations are equidistant in :math:`\cos\theta`, one can get to the spectrum directly by creating a histogram of :math:`\omega_\text{int}(\theta, \phi)`, thus circumventing a lot of calculations. diff --git a/doc/source/user_guide/fit.rst b/doc/source/user_guide/fit.rst index 959e836..310873d 100644 --- a/doc/source/user_guide/fit.rst +++ b/doc/source/user_guide/fit.rst @@ -4,10 +4,6 @@ Fitting data ============ -.. image:: ../_static/fit_dialog.png - :scale: 80% - :align: center - The picture gives an example of dialog to setup and start fits. First, there is the possibiity to fit different functions, called models to differentiate from the functions inside each model, to different data simultaneously. diff --git a/doc/source/user_guide/index.rst b/doc/source/user_guide/index.rst index 2ec252f..60ff693 100644 --- a/doc/source/user_guide/index.rst +++ b/doc/source/user_guide/index.rst @@ -1,11 +1,13 @@ -========== +********** User Guide -========== +********** .. toctree:: :maxdepth: 2 - read + gui/index + read/index + edit_signals fit shift_scale diff --git a/doc/source/user_guide/read.rst b/doc/source/user_guide/read.rst deleted file mode 100644 index a423962..0000000 --- a/doc/source/user_guide/read.rst +++ /dev/null @@ -1,19 +0,0 @@ -.. _user_guide.read: - -************* -Reading files -************* - -Supported filetypes are - - * Text files, - * DAMARIS HDF5 files, - * Grace images. - * HP alpha-analyzer EPS files - * NTNMR .tnt files - -DAMARIS HDF files -================= - -After scanning the selected file the program shows a list of the available data. - diff --git a/nmreval/distributions/gengamma.py b/nmreval/distributions/gengamma.py deleted file mode 100644 index 3c96063..0000000 --- a/nmreval/distributions/gengamma.py +++ /dev/null @@ -1,111 +0,0 @@ -from typing import Union - -import numpy as np -from scipy.integrate import simps -from scipy.special import gammaln - -from .base import Distribution - - -class GGAlpha(Distribution): - name = r'General \Gamma (\alpha-process)' - parameter = [r'\alpha', r'\beta'] - - @staticmethod - def correlation(t, tau0, *args): - logtau0 = np.log(tau0) - logtau = np.linspace(logtau0-20, logtau0+20, num=4001) - taus = np.exp(logtau) - gtau = GGAlpha.distribution(taus, tau0, *args) - ret_val = np.array([simps(np.exp(-xvals/taus)*gtau, logtau) for xvals in t]) - return ret_val - - @staticmethod - def susceptibility(omega, tau0, *args): - logtau0 = np.log(tau0) - logtau = np.linspace(logtau0 - 20, logtau0 + 20, num=4001) - taus = np.exp(logtau) - gtau = GGAlpha.distribution(taus, tau0, *args) - ret_val = np.array([simps(1/(1+1j*xvals*taus) * gtau, logtau) for xvals in omega]) - return ret_val - - @staticmethod - def distribution(taus: Union[float, np.ndarray], tau: float, *args) -> Union[float, np.ndarray]: - alpha, beta = args - b_to_a = beta / alpha - norm = np.exp(gammaln(b_to_a) - b_to_a * np.log(b_to_a)) / alpha - t_to_t0 = taus / tau - ret_val = np.exp(-b_to_a * t_to_t0 ** alpha) * t_to_t0 ** beta - - return ret_val / norm - - -class GGAlphaEW(Distribution): - name = r'General \Gamma (\alpha-process + EW)' - parameter = [r'\alpha', r'\beta'] - - @staticmethod - def correlation(t, tau0, *args): - logtau0 = np.log(tau0) - logtau = np.linspace(logtau0-20, logtau0+20, num=4001) - taus = np.exp(logtau) - gtau = GGAlphaEW.distribution(taus, tau0, *args) - # wir integrieren ueber lntau, nicht tau - ret_val = np.array([simps(np.exp(-xvals/taus)*gtau, logtau) for xvals in t]) - return ret_val - - @staticmethod - def susceptibility(omega, tau0, *args): - logtau0 = np.log(tau0) - logtau = np.linspace(logtau0 - 20, logtau0 + 20, num=4001) - taus = np.exp(logtau) - gtau = GGAlphaEW.distribution(taus, tau0, *args) - ret_val = np.array([simps(1/(1+1j*xvals*taus) * gtau, logtau) for xvals in omega]) - return ret_val - - @staticmethod - def distribution(tau: Union[float, np.ndarray], tau0: float, *args) -> Union[float, np.ndarray]: - alpha, beta, sigma, gamma = args - if gamma == beta: - return GGAlpha.distribution(tau, tau0, alpha, beta) - b_to_a = beta / alpha - g_to_a = gamma / alpha - t_to_t0 = tau / tau0 - norm = (np.exp(gammaln(b_to_a)) + sigma**(gamma-beta) * - np.exp(gammaln(g_to_a) + (b_to_a-g_to_a)*np.log(b_to_a))) / np.exp(b_to_a*np.log(b_to_a)) / alpha - - ret_val = np.exp(-b_to_a * t_to_t0**alpha) * t_to_t0**beta * (1 + (t_to_t0*sigma)**(gamma-beta)) - - return ret_val / norm - - -class GGBeta(Distribution): - name = r'General \Gamma (\beta-process)' - parameter = [r'\alpha', r'\beta'] - - @staticmethod - def correlation(t, tau0, *args): - logtau0 = np.log(tau0) - logtau = np.linspace(logtau0-20, logtau0+20, num=4001) - taus = np.exp(logtau) - gtau = GGBeta.distribution(taus, tau0, *args) - # wir integrieren ueber lntau, nicht tau - ret_val = np.array([simps(np.exp(-xvals/taus)*gtau, logtau) for xvals in t]) - return ret_val - - @staticmethod - def susceptibility(omega, tau0, *args): - logtau0 = np.log(tau0) - logtau = np.linspace(logtau0 - 20, logtau0 + 20, num=4001) - taus = np.exp(logtau) - gtau = GGBeta.distribution(taus, tau0, *args) - ret_val = np.array([simps(1/(1+1j*xvals*taus) * gtau, logtau) for xvals in omega]) - return ret_val - - @staticmethod - def distribution(tau: Union[float, np.ndarray], tau0: float, *args) -> Union[float, np.ndarray]: - a, b = args - norm = a * (1+b) * np.sin(np.pi*b/(1+b)) * b**(b/(1+b)) / np.pi - ret_val = b * (tau/tau0)**a + (tau/tau0)**(-a*b) - - return norm / ret_val diff --git a/nmreval/gui_qt/_py/fitcreationdialog.py b/nmreval/gui_qt/_py/fitcreationdialog.py deleted file mode 100644 index f2abd98..0000000 --- a/nmreval/gui_qt/_py/fitcreationdialog.py +++ /dev/null @@ -1,189 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'resources/_ui/fitcreationdialog.ui' -# -# Created by: PyQt5 UI code generator 5.12.3 -# -# WARNING! All changes made in this file will be lost! - - -from PyQt5 import QtCore, QtGui, QtWidgets - - -class Ui_Dialog(object): - def setupUi(self, Dialog): - Dialog.setObjectName("Dialog") - Dialog.resize(614, 776) - self.verticalLayout_5 = QtWidgets.QVBoxLayout(Dialog) - self.verticalLayout_5.setContentsMargins(3, 3, 3, 3) - self.verticalLayout_5.setSpacing(3) - self.verticalLayout_5.setObjectName("verticalLayout_5") - self.groupBox = QtWidgets.QGroupBox(Dialog) - self.groupBox.setCheckable(True) - self.groupBox.setChecked(False) - self.groupBox.setObjectName("groupBox") - self.verticalLayout_7 = QtWidgets.QVBoxLayout(self.groupBox) - self.verticalLayout_7.setContentsMargins(3, 3, 3, 3) - self.verticalLayout_7.setSpacing(3) - self.verticalLayout_7.setObjectName("verticalLayout_7") - self.widget_2 = QtWidgets.QWidget(self.groupBox) - self.widget_2.setObjectName("widget_2") - self.gridLayout_2 = QtWidgets.QGridLayout(self.widget_2) - self.gridLayout_2.setContentsMargins(0, 0, 0, 0) - self.gridLayout_2.setSpacing(3) - self.gridLayout_2.setObjectName("gridLayout_2") - self.name_lineedit = QtWidgets.QLineEdit(self.widget_2) - self.name_lineedit.setObjectName("name_lineedit") - self.gridLayout_2.addWidget(self.name_lineedit, 0, 1, 1, 1) - self.group_lineedit = QtWidgets.QLineEdit(self.widget_2) - self.group_lineedit.setObjectName("group_lineedit") - self.gridLayout_2.addWidget(self.group_lineedit, 1, 1, 1, 1) - self.group_label = QtWidgets.QLabel(self.widget_2) - self.group_label.setObjectName("group_label") - self.gridLayout_2.addWidget(self.group_label, 1, 0, 1, 1) - self.name_label = QtWidgets.QLabel(self.widget_2) - self.name_label.setObjectName("name_label") - self.gridLayout_2.addWidget(self.name_label, 0, 0, 1, 1) - self.lineEdit = QtWidgets.QLineEdit(self.widget_2) - self.lineEdit.setObjectName("lineEdit") - self.gridLayout_2.addWidget(self.lineEdit, 2, 1, 1, 1) - self.label_2 = QtWidgets.QLabel(self.widget_2) - self.label_2.setObjectName("label_2") - self.gridLayout_2.addWidget(self.label_2, 2, 0, 1, 1) - self.verticalLayout_7.addWidget(self.widget_2) - self.verticalLayout_5.addWidget(self.groupBox) - self.groupBox_2 = QtWidgets.QGroupBox(Dialog) - self.groupBox_2.setCheckable(True) - self.groupBox_2.setChecked(False) - self.groupBox_2.setObjectName("groupBox_2") - self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.groupBox_2) - self.verticalLayout_2.setContentsMargins(3, 3, 3, 3) - self.verticalLayout_2.setSpacing(3) - self.verticalLayout_2.setObjectName("verticalLayout_2") - self.widget_3 = QtWidgets.QWidget(self.groupBox_2) - self.widget_3.setObjectName("widget_3") - self.verticalLayout_8 = QtWidgets.QVBoxLayout(self.widget_3) - self.verticalLayout_8.setContentsMargins(0, 0, 0, 0) - self.verticalLayout_8.setSpacing(3) - self.verticalLayout_8.setObjectName("verticalLayout_8") - self.tableWidget = QtWidgets.QTableWidget(self.widget_3) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.tableWidget.sizePolicy().hasHeightForWidth()) - self.tableWidget.setSizePolicy(sizePolicy) - self.tableWidget.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection) - self.tableWidget.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) - self.tableWidget.setColumnCount(4) - self.tableWidget.setObjectName("tableWidget") - self.tableWidget.setRowCount(0) - item = QtWidgets.QTableWidgetItem() - self.tableWidget.setHorizontalHeaderItem(0, item) - item = QtWidgets.QTableWidgetItem() - self.tableWidget.setHorizontalHeaderItem(1, item) - item = QtWidgets.QTableWidgetItem() - self.tableWidget.setHorizontalHeaderItem(2, item) - item = QtWidgets.QTableWidgetItem() - self.tableWidget.setHorizontalHeaderItem(3, item) - self.verticalLayout_8.addWidget(self.tableWidget) - self.parameter_button = QtWidgets.QToolButton(self.widget_3) - self.parameter_button.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) - self.parameter_button.setAutoRaise(False) - self.parameter_button.setArrowType(QtCore.Qt.RightArrow) - self.parameter_button.setObjectName("parameter_button") - self.verticalLayout_8.addWidget(self.parameter_button) - self.verticalLayout_2.addWidget(self.widget_3) - self.verticalLayout_5.addWidget(self.groupBox_2) - self.groupBox_3 = QtWidgets.QGroupBox(Dialog) - self.groupBox_3.setCheckable(True) - self.groupBox_3.setChecked(False) - self.groupBox_3.setObjectName("groupBox_3") - self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.groupBox_3) - self.verticalLayout_3.setContentsMargins(3, 3, 3, 3) - self.verticalLayout_3.setSpacing(3) - self.verticalLayout_3.setObjectName("verticalLayout_3") - self.widget = QtWidgets.QWidget(self.groupBox_3) - self.widget.setObjectName("widget") - self.verticalLayout_6 = QtWidgets.QVBoxLayout(self.widget) - self.verticalLayout_6.setContentsMargins(0, 0, 0, 0) - self.verticalLayout_6.setSpacing(3) - self.verticalLayout_6.setObjectName("verticalLayout_6") - self.use_nuclei = QtWidgets.QCheckBox(self.widget) - self.use_nuclei.setObjectName("use_nuclei") - self.verticalLayout_6.addWidget(self.use_nuclei) - self.tabWidget = QtWidgets.QTabWidget(self.widget) - self.tabWidget.setTabPosition(QtWidgets.QTabWidget.West) - self.tabWidget.setTabsClosable(True) - self.tabWidget.setObjectName("tabWidget") - self.verticalLayout_6.addWidget(self.tabWidget) - self.selection_button = QtWidgets.QToolButton(self.widget) - self.selection_button.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) - self.selection_button.setArrowType(QtCore.Qt.RightArrow) - self.selection_button.setObjectName("selection_button") - self.verticalLayout_6.addWidget(self.selection_button) - self.verticalLayout_3.addWidget(self.widget) - self.verticalLayout_5.addWidget(self.groupBox_3) - self.groupBox_4 = QtWidgets.QGroupBox(Dialog) - self.groupBox_4.setCheckable(True) - self.groupBox_4.setChecked(False) - self.groupBox_4.setObjectName("groupBox_4") - self.verticalLayout = QtWidgets.QVBoxLayout(self.groupBox_4) - self.verticalLayout.setObjectName("verticalLayout") - self.namespace_widget = QNamespaceWidget(self.groupBox_4) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.namespace_widget.sizePolicy().hasHeightForWidth()) - self.namespace_widget.setSizePolicy(sizePolicy) - self.namespace_widget.setObjectName("namespace_widget") - self.verticalLayout.addWidget(self.namespace_widget) - self.verticalLayout_5.addWidget(self.groupBox_4) - self.frame_4 = QtWidgets.QFrame(Dialog) - self.frame_4.setObjectName("frame_4") - self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.frame_4) - self.verticalLayout_4.setContentsMargins(3, 3, 3, 3) - self.verticalLayout_4.setSpacing(3) - self.verticalLayout_4.setObjectName("verticalLayout_4") - self.label = QtWidgets.QLabel(self.frame_4) - self.label.setObjectName("label") - self.verticalLayout_4.addWidget(self.label) - self.plainTextEdit = CodeEditor(self.frame_4) - self.plainTextEdit.setObjectName("plainTextEdit") - self.verticalLayout_4.addWidget(self.plainTextEdit) - self.verticalLayout_5.addWidget(self.frame_4) - self.buttonBox = QtWidgets.QDialogButtonBox(Dialog) - self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) - self.buttonBox.setObjectName("buttonBox") - self.verticalLayout_5.addWidget(self.buttonBox) - self.name_label.setBuddy(self.name_lineedit) - - self.retranslateUi(Dialog) - self.buttonBox.accepted.connect(Dialog.accept) - self.buttonBox.rejected.connect(Dialog.reject) - QtCore.QMetaObject.connectSlotsByName(Dialog) - - def retranslateUi(self, Dialog): - _translate = QtCore.QCoreApplication.translate - Dialog.setWindowTitle(_translate("Dialog", "Dialog")) - self.groupBox.setTitle(_translate("Dialog", "Description")) - self.group_label.setText(_translate("Dialog", "Group")) - self.name_label.setText(_translate("Dialog", "Name")) - self.label_2.setText(_translate("Dialog", "Equation")) - self.groupBox_2.setTitle(_translate("Dialog", "Variables")) - item = self.tableWidget.horizontalHeaderItem(0) - item.setText(_translate("Dialog", "Variable")) - item = self.tableWidget.horizontalHeaderItem(1) - item.setText(_translate("Dialog", "Name")) - item = self.tableWidget.horizontalHeaderItem(2) - item.setText(_translate("Dialog", "Lower bound")) - item = self.tableWidget.horizontalHeaderItem(3) - item.setText(_translate("Dialog", "Upper bound")) - self.parameter_button.setText(_translate("Dialog", "Add parameter")) - self.groupBox_3.setTitle(_translate("Dialog", "Multiple choice part")) - self.use_nuclei.setText(_translate("Dialog", "Add gyromagnetic ratios")) - self.selection_button.setText(_translate("Dialog", "Add selection")) - self.groupBox_4.setTitle(_translate("Dialog", "Available namespace")) - self.label.setText(_translate("Dialog", "Function y = func(x)")) -from ..lib.codeeditor import CodeEditor -from ..lib.namespace import QNamespaceWidget diff --git a/nmreval/gui_qt/fit/function_creation_dialog.py b/nmreval/gui_qt/fit/function_creation_dialog.py deleted file mode 100644 index 492e8ad..0000000 --- a/nmreval/gui_qt/fit/function_creation_dialog.py +++ /dev/null @@ -1,238 +0,0 @@ -import re - -import numexpr as ne -import numpy as np - -from ..Qt import QtCore, QtWidgets -from .._py.fitcreationdialog import Ui_Dialog - - -_numexpr_funcs = [] -for k, _ in ne.expressions.functions.items(): - pat = k + r'\(' - _numexpr_funcs.append((re.compile(pat), 'np.' + k + '(')) - - -class QUserFitCreator(QtWidgets.QDialog, Ui_Dialog): - classCreated = QtCore.pyqtSignal(object) - - def __init__(self, parent=None): - super().__init__(parent=parent) - self.setupUi(self) - - self.namespace_widget.make_namespace() - - self.tableWidget.itemChanged.connect(self.update_function) - - self.groupBox.toggled.connect(self.change_visibility) - self.groupBox_2.toggled.connect(self.change_visibility) - self.groupBox_3.toggled.connect(self.change_visibility) - self.groupBox_4.toggled.connect(self.change_visibility) - - self.groupBox.setChecked(True) - - def __call__(self, *args, **kwargs): - for w in [self.lineEdit_4, self.lineEdit, self.lineEdit_3, self.lineEdit_2, - self.parameterLineEdit, self.externalParametersLineEdit]: - w.clear() - - def check(self): - self.name = self.name_lineedit.text() - self.group = self.group_lineedit.text() - self.eq = str(self.lineEdit.text()) - self.p = str(self.parameterLineEdit.text()).split() - self.func = str(self.lineEdit_4.text()) - self._func_string = '' - - error = [] - for k, v in [('Name', self.name), ('Group', self.group), ('Parameters', self.p), ('Function', self.func)]: - if not v: - error.append('Empty ' + str(k)) - if self.name: - if self.name[0].isdigit(): - error.append('Name starts with digit') - if self.p: - if set(self.p) & set(self.ext_p): - error.append('Duplicate entries: {}'.format(list(set(self.p) & set(self.ext_p)))) - if self.p and self.func: - p_test = np.ones((len(self.p)+len(self.ext_p))) - _x = np.arange(2) - namespace = {'x': _x} - for i, pp in enumerate(p_test): - namespace[f'p_{i}'] = pp - self._func_string = self.func + '' - self._func_string = self._func_string.replace('[', '_').replace(']', '') - try: - ne.evaluate(self._func_string, local_dict=namespace) - except KeyError: - error.append(f'Incorrect evaluation {self.func}') - - if error: - QtWidgets.QMessageBox().warning(self, 'Invalid entries', '\n'.join(error)) - else: - return True - - def accept(self): - self.confirm() - super().accept() - - def confirm(self): - print(f' name = {self.name_lineedit.text()}') - group_type = self.group_lineedit.text() - if group_type: - print(f' group = "{group_type}"') - else: - print(' group = "User-defined"') - var = [] - for row in range(self.tableWidget.rowCount()): - var.append(self.tableWidget.item(row, 1).text()) - if var: - print(' params = [r"', end='') - print('", r"'.join(var) + '"]') - else: - print(' params = []') - - print('\n@staticmethod') - print(self.label.text()) - import inspect - for k, v in self.namespace_widget.namespace.flatten().items(): - if inspect.isfunction(v): - print(k, inspect.getmodule(v)) - print(k, [cc[1] for cc in inspect.getmembers(v) if cc[0] == '__qualname__']) - else: - print(k, v) - print(self.plainTextEdit.toPlainText()) - - @QtCore.pyqtSlot(name='on_parameter_button_clicked') - def add_variable(self): - self.tableWidget.blockSignals(True) - row = self.tableWidget.rowCount() - self.tableWidget.setRowCount(row+1) - - self.tableWidget.setItem(row, 0, QtWidgets.QTableWidgetItem('p'+str(row))) - self.tableWidget.setItem(row, 1, QtWidgets.QTableWidgetItem('p_{'+str(row)+'}')) - self.tableWidget.setItem(row, 2, QtWidgets.QTableWidgetItem('--')) - self.tableWidget.setItem(row, 3, QtWidgets.QTableWidgetItem('--')) - self.tableWidget.blockSignals(False) - self.update_function(None) - - @QtCore.pyqtSlot(name='on_selection_button_clicked') - def add_choice(self): - cnt = self.tabWidget.count() - self.tabWidget.addTab(ChoiceWidget(self), 'choice' + str(cnt)) - self.tabWidget.setCurrentIndex(cnt) - - def register(self): - i = 0 - basename = self.name.replace(' ', '') - classname = basename - # while classname in _userfits: - # classname = basename + '_' + str(i) - # i += 1 - c = register_class(classname, self.name, self.group, self.p, self.eq, self._func_string) - self.classCreated.emit(c) - return classname, c - - def save(self, cname): - t = '\n# Created automatically\n' \ - 'class {cname:}(object):\n'\ - ' name = "{name:}"\n' \ - ' type = "{group:}"\n'\ - ' equation = "{eq:}"\n'\ - ' params = {p:}\n' \ - ' ext_params = {ep:}\n\n' \ - ' @staticmethod\n' \ - ' def func(p, x):\n' \ - ' return {func:}\n' - f_string = self.func - for pat, repl in _numexpr_funcs: - f_string = re.sub(pat, repl, f_string) - - @QtCore.pyqtSlot(QtWidgets.QTableWidgetItem) - @QtCore.pyqtSlot(str) - def update_function(self, _): - var = [] - for row in range(self.tableWidget.rowCount()): - var.append(self.tableWidget.item(row, 0).text()) - - if self.use_nuclei.isChecked(): - var.append('nucleus=2.67522128e8') - - # for row in range(self.selection_combobox.count()): - # var.append(self.selection_combobox.itemText(row) + '=') - - self.label.setText('def func(x, ' + ', '.join(var) + '):') - - def change_visibility(self): - sender = self.sender() - - for gb in [self.groupBox, self.groupBox_2, self.groupBox_3, self.groupBox_4]: - gb.blockSignals(True) - gb.setChecked(sender == gb) - gb.blockSignals(False) - - self.widget_2.setVisible(sender == self.groupBox) - self.widget_3.setVisible(sender == self.groupBox_2) - self.widget.setVisible(sender == self.groupBox_3) - self.namespace_widget.setVisible(sender == self.groupBox_4) - - -class ChoiceWidget(QtWidgets.QWidget): - def __init__(self, parent=None): - super().__init__(parent=parent) - - self._init_ui() - - def _init_ui(self): - layout = QtWidgets.QGridLayout() - layout.setContentsMargins(3, 3, 3, 3) - layout.setHorizontalSpacing(6) - - self.label = QtWidgets.QLabel('Name', parent=self) - layout.addWidget(self.label, 0, 0) - self.name_line = QtWidgets.QLineEdit(self) - layout.addWidget(self.name_line, 0, 1) - - self.label_2 = QtWidgets.QLabel('Displayed name', parent=self) - layout.addWidget(self.label_2, 0, 2) - self.display_line = QtWidgets.QLineEdit(self) - layout.addWidget(self.display_line, 0, 3) - - self.label_3 = QtWidgets.QLabel('Type', parent=self) - layout.addWidget(self.label_3) - self.types = QtWidgets.QComboBox(self) - self.types.addItems(['str', 'int', 'float']) - layout.addWidget(self.types) - - self.add_button = QtWidgets.QPushButton('Add option') - layout.addWidget(self.add_button) - - self.table = QtWidgets.QTableWidget(self) - self.table.setColumnCount(2) - self.table.setHorizontalHeaderLabels(['Name', 'Value']) - layout.addWidget(self.table, 2, 0, 1, 4) - - self.setLayout(layout) - - -def register_class(cname, name, group, p, eq, func): - c = type(cname, (), {}) - c.name = name - c.type = group - c.params = p - c.equation = eq - c.func = func_decorator(func) - - return c - - -def func_decorator(f_string): - # we need this decorator because the result is used in a class - - def wrapped_f(*args): - namespace = {'x': args[1]} - for i, pp in enumerate(args[0]): - namespace['p_{}'.format(i)] = pp - return ne.evaluate(f_string, local_dict=namespace) - - return wrapped_f diff --git a/nmreval/math/wideline.py b/nmreval/math/wideline.py deleted file mode 100644 index f996392..0000000 --- a/nmreval/math/wideline.py +++ /dev/null @@ -1,357 +0,0 @@ -import numpy as np -from scipy.integrate import trapz - -from .orientations import zcw_spherical as crystallites - - -class Powder(object): - def __init__(self, n=100): - self.alpha, self.beta, self.wt = crystallites(n) - - -class Pake(object): - parameter = {'delta': 0., 'eta': 0., 'w_iso': 0., - 'x': None, 'y': None, 'half': False} - - def __init__(self, samples=10000): - self.powder = Powder(n=samples) - self.dw = None - self.parameter = {} - self.GB = 1000 - self.pw = 1e-6 - self.legendre = 0 - self.axial = 0 - self.calc_prefactor() - - def calc_prefactor(self): - """ - Calculates angular dependencies - Returns - ------- - - """ - self.legendre = 3 * np.square(np.cos(self.powder.beta)) - 1 - self.axial = np.square(np.sin(self.powder.beta)) * np.cos(2 * self.powder.alpha) - - def set_parameter(self, p, dw=None): - self.parameter['delta'] = p[0] * 1e3 - self.parameter['eta'] = p[1] - self.GB = p[2] * 1e3 - self.pw = p[3] * 1e-6 - if len(p) == 5: - self.parameter['w_iso'] = p[4] * 1e3 - if dw is not None: - self.dw = dw - - @staticmethod - def _check_old_data(x, d, e, w, h): - if Pake.parameter['x'] is None: - return False - if Pake.parameter['w_iso'] == w and Pake.parameter['delta'] == d and \ - Pake.parameter['eta'] == e and Pake.parameter['half'] == h and \ - Pake.parameter['x'][0] == x[0] and Pake.parameter['x'][1] == x[1]: - return True - return False - - def calc_timesignal(self, tt, p, half=False): - """ - Calculate time signal of pake spectrum - Parameters - ---------- - tt: time array - p: list of parameters [delta, eta, GB, omega_iso] - half: if False, Pake spectrum will be calculated, if True, chemical shift spectrum will be calculated - - Returns - ------- - timesignal - """ - _delta, _eta, _wiso = p - omega = 0.5 * _delta * (self.legendre - _eta * self.axial) - if half: - omega += _wiso - weight = self.powder.wt - if half: - fid_real = np.zeros_like(tt, dtype=float) - fid_imag = np.zeros_like(tt, dtype=float) - for k, v in zip(omega, weight): - pha = 2 * np.pi * k * tt - fid_real += (np.cos(pha)) * v - fid_imag += (np.sin(pha)) * v - fid = 1j * fid_imag - fid += fid_real - else: - fid = np.zeros_like(tt, dtype=float) - for k, v in zip(omega, weight): - fid += np.cos(2 * np.pi * k * tt) * v - return fid - - @staticmethod - def calc_pulse(pw, f): - _phi = 2 * np.pi * f * pw - pulse = ((0.5 * np.pi * np.sin(np.sqrt(0.25 * np.pi ** 2 + 0.5 * _phi ** 2))) / - np.sqrt(0.25 * np.pi ** 2 + 0.25 * _phi ** 2)) ** 1 - - return pulse - - def pake_spectrum(self, x, p=None, half=False): - if p is None: - _gb = self.GB - _pw = self.pw - try: - _delta = self.parameter['delta'] - _eta = self.parameter['eta'] - _wiso = self.parameter['w_iso'] - except KeyError: - _delta = Pake.parameter['delta'] - _eta = Pake.parameter['eta'] - _wiso = Pake.parameter['w_iso'] - else: - _delta = p[0] * 1e3 - _eta = p[1] - _gb = p[2] * 1e3 - _pw = p[3] * 1e-6 - _wiso = p[4] * 1e3 - - # x is time - if abs(x[1] - x[0]) < 1: - if self.dw is None: - self.dw = x[1] - x[0] - t = x - nop = len(x) - isfreq = False - # x is frequency - else: - df = (x[1] - x[0]) - if self.dw is None: - self.dw = 1 / (df * len(x)) - if len(x) != 1 / (self.dw * df): - nop = int(1 / (self.dw * df)) - else: - nop = len(x) - - # avoid calculation for to much points - t = np.arange(0, min(8192, nop)) * self.dw - isfreq = True - - new_data = self._check_old_data((nop, self.dw), _delta, _eta, _wiso, half) - - if new_data: - fid = Pake.parameter['y'] + 0 - Pake.parameter['delta'] = _delta - Pake.parameter['eta'] = _eta - Pake.parameter['w_iso'] = _wiso - Pake.parameter['x'] = (nop, self.dw) - Pake.parameter['half'] = half - self.GB = _gb - self.pw = _pw - fid = self.calc_timesignal(t, [_delta, _eta, _wiso], half=half) - Pake.parameter['y'] = fid + 0 - - - fid *= np.exp(-(_gb * t) ** 2) - - # add zeros to get desired signal length - if len(fid) != nop: - fid = np.append(fid, np.zeros((nop - len(fid))), axis=0) - - spec = np.fft.fftshift(np.fft.fft(fid)) - spec -= np.mean(spec[:10]) - _f = np.fft.fftshift(np.fft.fftfreq(nop, d=self.dw)) - - # take finite pulse length into account - if _pw != 0: - pulse = self.calc_pulse(_pw, _f) - spec *= pulse - - # shift pake spectrum by isotropic shift - if not half: - spec = np.roll(spec, int(self.dw * _wiso * nop)) - - # cut to original frequency range - if isfreq: - # mask = np.ma.masked_inside(_f, min(x), max(x)).mask - # spec = spec[mask] - spec = np.interp(x, _f, spec.real) - - spec.real -= np.mean(spec.real[:10]) - - return spec.real / max(spec.real) - - def pake(self, x, p=None): - return self.pake_spectrum(x, p=p) - - def halfpake(self, x, p=None): - return self.pake_spectrum(x, p=p, half=True) - - -class SecondOrder(object): - parameter = {'c_q': 1e6, 'eta': 0., - 'x': None, 'y': None} - - def __init__(self, samples=200000): - self.powder = Powder(n=samples) - self.dw = None - self.parameter = {} - self.GB = 1000 - self.pw = 1e-6 - self.legendre = 0 - self.axial = 0 - self.coupling = 1 - self.larmor = 2 * np.pi * 100e6 - - def set_parameter(self, p, dw=None, larmor=None, spin=2.5): - self.parameter['c_q'] = 2 * np.pi * p[0] * 1e6 - self.parameter['eta'] = p[1] - self.GB = p[2] * 1e3 - if dw is not None: - self.dw = dw - if larmor is not None: - self.larmor = 2 * np.pi * larmor - self._calc_coupling(2 * np.pi * p[0] * 1e6, spin=spin) - - def _calc_coupling(self, c_q, spin=2.5): - omega_q = c_q / (2 * spin * (2 * spin - 1)) - self.coupling = 1.5 * omega_q ** 2 / self.larmor * (spin * (spin + 1) - 0.75) - - def calc_omega(self, eta, delta): - self._calc_coupling(delta) - cos2phi = np.cos(2 * self.powder.alpha) - cos_theta_square = 0.5 + 0.5 * np.cos(2 * self.powder.beta) - prefactor_a = -3.375 + 2.25 * eta * cos2phi - 0.375 * (eta * cos2phi) ** 2 - prefactor_b = 3.75 - 0.5 * eta ** 2 - 2 * eta * cos2phi + 0.75 * (eta * cos2phi) ** 2 - prefactor_c = -0.375 + (eta ** 2) / 3. - 0.25 * eta * cos2phi - 0.375 * (eta * cos2phi) ** 2 - ret_val = np.zeros_like(cos2phi) - ret_val += prefactor_a * cos_theta_square ** 2 - ret_val += prefactor_b * cos_theta_square - ret_val += prefactor_c - return self.coupling * ret_val - - def calc_timesignal(self, tt, p): - delta, eta = p - omega = self.calc_omega(eta, delta) - weight = self.powder.wt - fid_real = np.zeros_like(tt, dtype=float) - fid_imag = np.zeros_like(tt, dtype=float) - - for o, w in zip(omega, weight): - pha = o * tt - co_pha = np.cos(pha) - si_pha = np.sin(pha) - fid_real += co_pha * w - fid_imag += si_pha * w - - fid = 1j * fid_imag - fid += fid_real - return fid - - def spectrum(self, x, p=None): - if p is None: - p = [self.parameter['c_q'], self.parameter['eta'], self.GB] - if abs(x[1] - x[0]) < 1: - if self.dw is None: - self.dw = x[1] - x[0] - t = x - nop = len(x) - isfreq = False - else: - df = (x[1] - x[0]) - if self.dw is None: - self.dw = 1 / (df * len(x)) - if len(x) != 1 / (self.dw * df): - nop = int(1 / (self.dw * df)) - else: - nop = len(x) - t = np.arange(0, min(8192, nop)) * self.dw - isfreq = True - - fid = self.calc_timesignal(t, p[:-1]) - fid *= np.exp(-(p[-1] * t) ** 2) - - if len(fid) != nop: - fid = np.append(fid, np.zeros((nop - len(fid))), axis=0) - - spec = np.fft.fftshift(np.fft.fft(fid)) - _f = np.fft.fftshift(np.fft.fftfreq(nop, d=self.dw)) - - if isfreq: - mask = np.ma.masked_inside(_f, min(x), max(x)).mask - spec = spec[mask] - - return spec.real - np.mean(spec.real[:10]) - - -def csa(x: np.ndarray, delta: float, eta: float, wiso: float, gb: float, sw: float): - dw = 1 / sw - a, b, _ = crystallites(200000) - bins = 0.5 * (x[1:] + x[:-1]) - bins = np.hstack((np.array([0.5 * (-x[1] + 3 * x[0])]), bins, np.array([0.5 * (3 * x[-1] - x[-2])]))) - - omega = wiso + delta * 0.5 * (3 * np.cos(b) ** 2 - 1 - eta * np.square(np.sin(b)) * np.cos(2 * a)) - - s_left = np.histogram(omega, bins=bins)[0] - s = s_left - - if gb != 0: - apd = np.exp(-4 * np.log(2) * (np.fft.fftshift(np.fft.fftfreq(len(x), d=dw)) / sw) ** 2) * \ - 2 * np.sqrt(np.log(2) / np.pi) / gb - ret_val = np.convolve(s, apd, mode='same') - else: - ret_val = s - - return ret_val / trapz(ret_val, x) - - -def pake(p, x): - dw = 1/p[-1] - a, b, _ = crystallites(200000) - bins = 0.5 * (x[1:] + x[:-1]) - bins = np.hstack((np.array([0.5 * (-x[1] + 3 * x[0])]), bins, np.array([0.5 * (3 * x[-1] - x[-2])]))) - - omega = p[0] * 0.5 * (3*np.cos(b)**2 - 1 - p[1] * np.square(np.sin(b)) * np.cos(2 * a)) - - s_left = np.histogram(omega, bins=bins)[0] - s_right = np.histogram(-omega, bins=bins)[0] - s = s_left + s_right - - if p[2] != 0: - apd = np.exp(-4 * np.log(2) * (np.fft.fftshift(np.fft.fftfreq(len(x), d=dw)) / p[2]) ** 2) * \ - 2 * np.sqrt(np.log(2) / np.pi) / p[2] - ret_val = np.convolve(s, apd, mode='same') - else: - ret_val = s - - return ret_val/trapz(ret_val, x) - - -def sec_order(p, x, spin=2.5): - dw = 1/p[-1] - a, b, _ = crystallites(200000) - bins = 0.5 * (x[1:] + x[:-1]) - bins = np.hstack((np.array([0.5 * (-x[1] + 3 * x[0])]), bins, np.array([0.5 * (3 * x[-1] - x[-2])]))) - - omega_q = 2 * np.pi * p[0] / (2*spin * (2*spin - 1)) - coupling = 1.5 * (omega_q**2 / (2 * np.pi *p[3])) * (spin*(spin + 1) - 0.75) - - cos2phi = np.cos(2 * a) - cos_theta_square = 0.5+0.5*np.cos(2*b) - prefactor_a = -3.375 + 2.25*p[1] * cos2phi - 0.375 * (p[1] * cos2phi)**2 - prefactor_b = 3.75 - 0.5 * p[1]**2 - 2*p[1]*cos2phi + 0.75 * (p[1]*cos2phi)**2 - prefactor_c = -0.375 + (p[1]**2)/3. - 0.25*p[1]*cos2phi - 0.375 * (p[1]*cos2phi)**2 - orient = np.zeros_like(cos2phi) - orient += prefactor_a * cos_theta_square ** 2 - orient += prefactor_b * cos_theta_square - orient += prefactor_c - - omega = coupling * orient - - s = np.histogram(omega/(2*np.pi), bins=bins)[0] - - if p[2] != 0: - apd = np.exp(-4 * np.log(2) * (np.fft.fftshift(np.fft.fftfreq(len(x), d=dw)) / p[2]) ** 2) * \ - 2 * np.sqrt(np.log(2) / np.pi) / p[2] - ret_val = np.convolve(s, apd, mode='same') - else: - ret_val = s - - return ret_val / trapz(ret_val, x) diff --git a/nmreval/models/gengamma.py b/nmreval/models/gengamma.py deleted file mode 100644 index 0d332ef..0000000 --- a/nmreval/models/gengamma.py +++ /dev/null @@ -1,268 +0,0 @@ -import numpy as np -from scipy.special import gammaln -from ..math.logfourier import logft - -stepsize = 0.2 # 0.05 -span1 = 20 -span2 = 30 - - -class GeneralGamma(object): - lower_b = 20 - upper_b = 20 - dx = 0.2 - - @staticmethod - def gga_dist(tau, tau0, alpha, beta): - b_to_a = beta / alpha - norm = np.exp(gammaln(b_to_a) - b_to_a * np.log(b_to_a)) / alpha - t_to_t0 = tau / tau0 - ret_val = np.exp(-b_to_a * t_to_t0 ** alpha) * t_to_t0 ** beta - - return ret_val / norm - - @staticmethod - def gga_ew_dist(tau, tau0, alpha, beta, sigma, gamma): - if gamma == beta: - return GeneralGamma.gga_dist(tau, tau0, alpha, beta) - b_to_a = beta / alpha - g_to_a = gamma / alpha - t_to_t0 = tau / tau0 - norm = (np.exp(gammaln(b_to_a)) + sigma**(gamma-beta) * np.exp(gammaln(g_to_a) + (b_to_a-g_to_a)*np.log(b_to_a))) / np.exp(b_to_a*np.log(b_to_a)) / alpha - - ret_val = np.exp(-b_to_a * t_to_t0**alpha) * t_to_t0**beta * (1 + (t_to_t0*sigma)**(gamma-beta)) - - return ret_val / norm - - @staticmethod - def ggb_dist(tau, tau0, a, b): - norm = a * (1+b) * np.sin(np.pi*b/(1+b)) * b**(b/(1+b)) / np.pi - ret_val = b * (tau/tau0)**a + (tau/tau0)**(-a*b) - - return norm / ret_val - - @staticmethod - def _gg_time(t, tau0, *args, **kwargs): - logtau = np.log(tau0) - steps = np.arange(logtau - GeneralGamma.lower_b, logtau + GeneralGamma.upper_b, GeneralGamma.dx) - taus = np.exp(steps) - ret_val = np.zeros_like(t) - dist = {'gga': GeneralGamma.gga_dist, - 'gga_ew': GeneralGamma.gga_ew_dist, - 'ggb': GeneralGamma.ggb_dist}[kwargs.pop('mode', 'gga')] - gtau = dist(taus, tau0, *args) - for i, xval in enumerate(t): - y = np.exp(- xval / taus) - y *= gtau - y = y[1:] + y[:-1] - ret_val[i] = np.sum(y) * GeneralGamma.dx / 2 - return ret_val - - @staticmethod - def ggaew_b_freq(f, tau0, alpha, beta, sigma, gamma, tau1, a, b, r, dec=5): - t = np.logspace(np.log10(1 / max(f)) - dec, np.log10(1 / min(f)) + dec, num=int(len(f) * (0.5 * dec))) - phi_a = GeneralGamma.ggaew(t, tau0, alpha, beta, sigma, gamma) - phi_b = GeneralGamma.ggb(t, tau1, a, b) - temp = phi_a * (1 - r + r * phi_b) - - ret_val = logft(t, temp, new_x=2 * np.pi * f)[1].y - - return ret_val * f * 2 * np.pi - - @staticmethod - def gga_b_freq(f, tau0, alpha, beta, tau1, a, b, r, dec=5): - t = np.logspace(np.log10(1 / max(f)) - dec, np.log10(1 / min(f)) + dec, num=int(len(f) * (0.5 * dec))) - phi_a = GeneralGamma.gga(t, tau0, alpha, beta) - phi_b = GeneralGamma.ggb(t, tau1, a, b) - temp = phi_a * (1 - r + r * phi_b) - - ret_val = logft(t, temp, new_x=2 * np.pi * f)[1].y - - return ret_val * f * 2 * np.pi - - @staticmethod - def gga(t, tau0, alpha, beta): - return GeneralGamma._gg_time(t, tau0, alpha, beta, mode='gga') - - @staticmethod - def ggaew(t, tau0, alpha, beta, sigma, gamma): - return GeneralGamma._gg_time(t, tau0, alpha, beta, sigma, gamma, mode='gga_ew') - - @staticmethod - def ggb(t, tau0, a, b): - return GeneralGamma._gg_time(t, tau0, a, b, mode='ggb') - - @staticmethod - def ggaew_b(t, tau0, alpha, beta, sigma, gamma, tau1, a, b, r): - phi_a = GeneralGamma.ggaew(t, tau0, alpha, beta, sigma, gamma) - phi_b = GeneralGamma.ggb(t, tau1, a, b) - ret_val = phi_a * (1 - r + r * phi_b) - return ret_val - - @staticmethod - def gga_b(t, tau0, alpha, beta, tau1, a, b, r): - phi_a = GeneralGamma.gga(t, tau0, alpha, beta) - phi_b = GeneralGamma.ggb(t, tau1, a, b) - ret_val = phi_a * (1 - r + r * phi_b) - return ret_val - - -class FitGG(object): - name = 'Alpha + Beta + EW' - type = 'Gamma-Functions' - equation = r'A*\Phi_{\alpha,EW} * [1 - C + C*\Phi_{\beta}] + B' - params = ['A', 'B', - r'\tau_{\alpha}', r'\alpha', r'\beta', '\sigma', '\gamma', - r'\tau_{\beta}', 'a', 'b', 'C'] - - @staticmethod - def func(p, x): - amp, base, tau0, alpha, beta, sigma, gamma, tau1, a, b, c = p - phi_a = GeneralGamma.ggaew(x, tau0, alpha, beta, sigma, gamma) - phi_b = GeneralGamma.ggb(x, tau1, a, b) - ret_val = amp * phi_a * (1 - c + c * phi_b) + base - return ret_val - - -# Definiere Funktionen # -def glntau1_td(ttime, tau, alpha, beta): - lnx = np.log(tau) + span1 - intmin = np.log(tau) - span2 - steps = np.arange(lnx, intmin, -stepsize) - explnx = np.exp(steps) - betatoalpha = beta / alpha - logtau = np.log(tau) - if betatoalpha > 80: - norm = np.exp(.5 * np.log(2 * np.pi / betatoalpha) - betatoalpha) / alpha - else: - norm = np.exp(gammaln(betatoalpha)) / alpha / np.power(betatoalpha, betatoalpha) - y = np.exp(-np.exp((steps - logtau) * alpha) * betatoalpha) * np.power(explnx / tau, beta) * np.exp(-ttime / explnx) - y = y[1:] + y[:-1] - intval = np.sum(y) / 2 - intval = intval * stepsize / norm - return intval - - -def gga(t, tau0, alpha, beta): - logtau = np.log(tau0) - stepsize = 0.2 - steps = np.arange(logtau - 20, logtau + 20, stepsize) - taus = np.exp(steps)/tau0 - betatoalpha = beta / alpha - norm = np.exp(gammaln(betatoalpha) - betatoalpha*np.log(betatoalpha)) / alpha - ret_val = np.zeros_like(t) - gtau = np.exp(-taus ** alpha * betatoalpha) * taus ** beta - for i, xval in enumerate(t): - # exponent = -taus**alpha * betatoalpha - xval/taus/tau0 - y = np.exp(- xval/taus/tau0) - y *= gtau - y = y[1:] + y[:-1] - ret_val[i] = np.sum(y) * stepsize / norm / 2 - return ret_val - - -def ggaew(t, tau0, alpha, beta, sigma, gamma): - logtau = np.log(tau0) - stepsize = 0.2 - steps = np.arange(logtau - 20, logtau + 20, stepsize) - taus = np.exp(steps) / tau0 - q1 = beta / alpha - q2 = gamma / alpha - norm = (np.exp(gammaln(q1)) + sigma**(gamma-beta) * np.exp((q1-q2)*np.log(q1)) * np.exp(gammaln(q2))) / alpha / np.exp(q1*np.log(q1)) - ret_val = np.empty_like(t) - gtau = np.exp(-taus**alpha * q1) * taus**beta * (1 + (taus*sigma)**(gamma-beta)) - for i, xval in enumerate(t): - y = np.exp(-xval/taus/tau0) - y *= gtau - y = y[1:] + y[:-1] - ret_val[i] = np.sum(y) * stepsize / norm / 2 - return ret_val - - -def ggaew_b(t, tau0, alpha, beta, sigma, gamma, tau1, a, b, r): - phi_a = ggaew(t, tau0, alpha, beta,sigma, gamma) - phi_b = ggb(t, tau1, a, b) - ret_val = phi_a * (1-r + r*phi_b) - return ret_val - - -def ggb(t, tau0, a, b): - logtau = np.log(tau0) - stepsize = 0.2 - steps = np.arange(logtau - 20, logtau + 20, stepsize) - taus = np.exp(steps) / tau0 - norm = np.pi / (a*(1+b)) / b**(b/(1+b)) / np.sin(np.pi*b / (1+b)) - ret_val = np.empty_like(t) - gtau = 1. / (b * taus**a + taus**(-b*a)) - for i, xval in enumerate(t): - y = np.exp(-xval / taus / tau0) - y *= gtau - y = y[1:] + y[:-1] - ret_val[i] = np.sum(y) * stepsize / norm / 2 - return ret_val - - -def glntau2_td(ttime, tau, alpha, beta, sigma, gam): - intval = 0 - lnx = np.log(tau) + span1 - intmin = np.log(tau) - span2 - steps = np.arange(lnx, intmin, -stepsize) - explnx = np.exp(steps) - logtau = np.log(tau) - q1 = beta / alpha - q2 = gam / alpha - - if q2 > 80: - norm = (np.exp(.5 * np.log(2 * np.pi / q1) - q1) + np.power(sigma, alpha * (q2 - q1)) * np.power(q2 / q1, - -q2) * np.exp( - .5 * np.log(2 * np.PI / q2) - q2)) / alpha - elif q1 > 80: - norm = (np.exp(.5 * np.log(2 * np.pi / q1) - q1) + np.power(sigma, alpha * (q2 - q1)) * np.power(q2 / q1, - -q2) * np.exp( - gammaln(q2)) * np.power(q1, -q1)) / alpha - else: - norm = (np.exp(gammaln(q1)) + np.power(sigma, gam - beta) * np.power(q1, q1 - q2) * np.exp(gammaln(q2))) / ( - alpha * np.power(q1, q1)) - y = np.exp(-np.exp((steps - logtau) * alpha) * q1) * np.power(explnx / tau, beta) * ( - 1 + np.power(explnx * sigma / tau, gam - beta)) * np.exp(-ttime / explnx) - y = y[1:] + y[:-1] - intval = np.sum(y) / 2 - intval = intval * stepsize / norm - return intval - - -def glnbeta_td(ttime, tau, a, b): - intval = 0 - lnx = np.log(tau) + span1 - intmin = np.log(tau) - span2 - steps = np.arange(lnx, intmin, -stepsize) - explnx = np.exp(steps) - norm = np.pi / (a * (1 + b)) / np.power(b, b / (1. + b)) / np.sin(np.pi * b / (1. + b)) - y = 1. / (b * np.power(explnx / tau, a) + np.power(explnx / tau, -(b * a))) * np.exp(-ttime / explnx) - y = y[1:] + y[:-1] - intval = np.sum(y) / 2 - - intval = intval * stepsize / norm - return intval - - -def g2(p, x): - ret_val = np.empty(np.shape(x)) - for i, xval in enumerate(x): - # fkt1 = glntau2_td(xval, p[1], p[2], p[3], p[4], p[5]) - # fkt1 = glntau1_td(xval, p[1], p[2], p[3]) - fkt1 = glntau2_td(xval, p[1], p[2], p[3], p[4], p[5]) - fkt2 = glnbeta_td(xval, p[6], p[7], p[8]) - # ret_val[i] = (fkt1 * ((1 - p[4]) + p[4] * fkt2) * p[0]) + np.abs(p[9]) * np.exp(-(xval/p[10])**p[11]) + p[8] - ret_val[i] = fkt1 * (1-p[0] + p[0]*fkt2) - return ret_val - - -def g1(p, x): - ret_val = np.empty(np.shape(x)) - for i, xval in enumerate(x): - # fkt1 = glntau1_td(xval,p[1],p[2],p[3]) - fkt1 = glntau2_td(xval, p[1], p[2], p[3], p[11], p[12]) - fkt2 = glnbeta_td(xval, p[5], p[6], p[7]) - ret_val[i] = p[0] * (fkt1 * ((1 - p[4]) + p[4] * fkt2)) + np.abs(p[8]) * np.exp(-(xval / p[9]) ** p[10]) - return ret_val diff --git a/requirements.txt b/requirements.txt index 96d9f90..c035f4f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ matplotlib numpy scipy +pyqt +h5py pyqtgraph bsddb3 -h5py -pyqt diff --git a/resources/_ui/fitcreationdialog.ui b/resources/_ui/fitcreationdialog.ui deleted file mode 100644 index 689327a..0000000 --- a/resources/_ui/fitcreationdialog.ui +++ /dev/null @@ -1,419 +0,0 @@ - - - Dialog - - - - 0 - 0 - 614 - 776 - - - - Dialog - - - - 3 - - - 3 - - - 3 - - - 3 - - - 3 - - - - - Description - - - true - - - false - - - - 3 - - - 3 - - - 3 - - - 3 - - - 3 - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 3 - - - - - - - - - - - Group - - - - - - - Name - - - name_lineedit - - - - - - - - - - Equation - - - - - - - - - - - - - Variables - - - true - - - false - - - - 3 - - - 3 - - - 3 - - - 3 - - - 3 - - - - - - 3 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - 4 - - - - Variable - - - - - Name - - - - - Lower bound - - - - - Upper bound - - - - - - - - Add parameter - - - Qt::ToolButtonTextBesideIcon - - - false - - - Qt::RightArrow - - - - - - - - - - - - - Multiple choice part - - - true - - - false - - - - 3 - - - 3 - - - 3 - - - 3 - - - 3 - - - - - - 3 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Add gyromagnetic ratios - - - - - - - QTabWidget::West - - - true - - - - - - - Add selection - - - Qt::ToolButtonTextBesideIcon - - - Qt::RightArrow - - - - - - - - - - - - - Available namespace - - - true - - - false - - - - - - - 0 - 0 - - - - - - - - - - - - 3 - - - 3 - - - 3 - - - 3 - - - 3 - - - - - Function y = func(x) - - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - QNamespaceWidget - QWidget -
..lib.namespace
- 1 -
- - CodeEditor - QPlainTextEdit -
..lib.codeeditor
-
-
- - - - buttonBox - accepted() - Dialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Dialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - -
diff --git a/nmreval/gui_qt/Qt.py b/src/gui_qt/Qt.py similarity index 81% rename from nmreval/gui_qt/Qt.py rename to src/gui_qt/Qt.py index 1a85709..42e02e7 100644 --- a/nmreval/gui_qt/Qt.py +++ b/src/gui_qt/Qt.py @@ -1,7 +1,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets, QtPrintSupport -# from PySide2 import QtCore, QtGui, QtWidgets +# from PySide2 import QtCore, QtGui, QtWidgets, QtPrintSupport # QtCore.pyqtSignal = QtCore.Signal # QtCore.pyqtProperty = QtCore.Property # QtCore.pyqtSlot = QtCore.Slot diff --git a/nmreval/gui_qt/__init__.py b/src/gui_qt/__init__.py similarity index 89% rename from nmreval/gui_qt/__init__.py rename to src/gui_qt/__init__.py index cd017b5..30ce690 100644 --- a/nmreval/gui_qt/__init__.py +++ b/src/gui_qt/__init__.py @@ -1,6 +1,7 @@ +from nmreval.configs import read_configuration + from .Qt import QtWidgets from .lib.styles import MyProxyStyle -from ..configs import read_configuration class App(QtWidgets.QApplication): diff --git a/nmreval/gui_qt/_py/__init__.py b/src/gui_qt/_py/__init__.py similarity index 100% rename from nmreval/gui_qt/_py/__init__.py rename to src/gui_qt/_py/__init__.py diff --git a/nmreval/gui_qt/_py/agroptiondialog.py b/src/gui_qt/_py/agroptiondialog.py similarity index 100% rename from nmreval/gui_qt/_py/agroptiondialog.py rename to src/gui_qt/_py/agroptiondialog.py diff --git a/nmreval/gui_qt/_py/apod_dialog.py b/src/gui_qt/_py/apod_dialog.py similarity index 100% rename from nmreval/gui_qt/_py/apod_dialog.py rename to src/gui_qt/_py/apod_dialog.py diff --git a/nmreval/gui_qt/_py/asciidialog.py b/src/gui_qt/_py/asciidialog.py similarity index 100% rename from nmreval/gui_qt/_py/asciidialog.py rename to src/gui_qt/_py/asciidialog.py diff --git a/nmreval/gui_qt/_py/axisConfigTemplate.py b/src/gui_qt/_py/axisConfigTemplate.py similarity index 100% rename from nmreval/gui_qt/_py/axisConfigTemplate.py rename to src/gui_qt/_py/axisConfigTemplate.py diff --git a/nmreval/gui_qt/_py/baseline_dialog.py b/src/gui_qt/_py/baseline_dialog.py similarity index 100% rename from nmreval/gui_qt/_py/baseline_dialog.py rename to src/gui_qt/_py/baseline_dialog.py diff --git a/nmreval/gui_qt/_py/basewindow.py b/src/gui_qt/_py/basewindow.py similarity index 100% rename from nmreval/gui_qt/_py/basewindow.py rename to src/gui_qt/_py/basewindow.py diff --git a/nmreval/gui_qt/_py/bdsdialog.py b/src/gui_qt/_py/bdsdialog.py similarity index 100% rename from nmreval/gui_qt/_py/bdsdialog.py rename to src/gui_qt/_py/bdsdialog.py diff --git a/nmreval/gui_qt/_py/color_palette.py b/src/gui_qt/_py/color_palette.py similarity index 100% rename from nmreval/gui_qt/_py/color_palette.py rename to src/gui_qt/_py/color_palette.py diff --git a/nmreval/gui_qt/_py/coupling_calculator.py b/src/gui_qt/_py/coupling_calculator.py similarity index 100% rename from nmreval/gui_qt/_py/coupling_calculator.py rename to src/gui_qt/_py/coupling_calculator.py diff --git a/nmreval/gui_qt/_py/coupling_t1_from_tau.py b/src/gui_qt/_py/coupling_t1_from_tau.py similarity index 100% rename from nmreval/gui_qt/_py/coupling_t1_from_tau.py rename to src/gui_qt/_py/coupling_t1_from_tau.py diff --git a/nmreval/gui_qt/_py/datawidget.py b/src/gui_qt/_py/datawidget.py similarity index 100% rename from nmreval/gui_qt/_py/datawidget.py rename to src/gui_qt/_py/datawidget.py diff --git a/nmreval/gui_qt/_py/dscfile_dialog.py b/src/gui_qt/_py/dscfile_dialog.py similarity index 100% rename from nmreval/gui_qt/_py/dscfile_dialog.py rename to src/gui_qt/_py/dscfile_dialog.py diff --git a/nmreval/gui_qt/_py/editsignalwidget.py b/src/gui_qt/_py/editsignalwidget.py similarity index 100% rename from nmreval/gui_qt/_py/editsignalwidget.py rename to src/gui_qt/_py/editsignalwidget.py diff --git a/nmreval/gui_qt/_py/eval_expr_dialog.py b/src/gui_qt/_py/eval_expr_dialog.py similarity index 100% rename from nmreval/gui_qt/_py/eval_expr_dialog.py rename to src/gui_qt/_py/eval_expr_dialog.py diff --git a/nmreval/gui_qt/_py/evalexpression.py b/src/gui_qt/_py/evalexpression.py similarity index 100% rename from nmreval/gui_qt/_py/evalexpression.py rename to src/gui_qt/_py/evalexpression.py diff --git a/nmreval/gui_qt/_py/expandablewidget.py b/src/gui_qt/_py/expandablewidget.py similarity index 100% rename from nmreval/gui_qt/_py/expandablewidget.py rename to src/gui_qt/_py/expandablewidget.py diff --git a/nmreval/gui_qt/_py/exportConfigTemplate.py b/src/gui_qt/_py/exportConfigTemplate.py similarity index 100% rename from nmreval/gui_qt/_py/exportConfigTemplate.py rename to src/gui_qt/_py/exportConfigTemplate.py diff --git a/nmreval/gui_qt/_py/fcreader.py b/src/gui_qt/_py/fcreader.py similarity index 100% rename from nmreval/gui_qt/_py/fcreader.py rename to src/gui_qt/_py/fcreader.py diff --git a/nmreval/gui_qt/_py/filedialog.py b/src/gui_qt/_py/filedialog.py similarity index 100% rename from nmreval/gui_qt/_py/filedialog.py rename to src/gui_qt/_py/filedialog.py diff --git a/src/gui_qt/_py/fitcreationdialog.py b/src/gui_qt/_py/fitcreationdialog.py new file mode 100644 index 0000000..d1c6075 --- /dev/null +++ b/src/gui_qt/_py/fitcreationdialog.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'resources/_ui/fitcreationdialog.ui' +# +# Created by: PyQt5 UI code generator 5.15.4 +# +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. + + +from PyQt5 import QtCore, QtGui, QtWidgets + + +class Ui_Dialog(object): + def setupUi(self, Dialog): + Dialog.setObjectName("Dialog") + Dialog.resize(773, 633) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.MinimumExpanding) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(Dialog.sizePolicy().hasHeightForWidth()) + Dialog.setSizePolicy(sizePolicy) + self.verticalLayout = QtWidgets.QVBoxLayout(Dialog) + self.verticalLayout.setObjectName("verticalLayout") + self.splitter = QtWidgets.QSplitter(Dialog) + self.splitter.setOrientation(QtCore.Qt.Vertical) + self.splitter.setObjectName("splitter") + self.tabWidget = QtWidgets.QTabWidget(self.splitter) + self.tabWidget.setObjectName("tabWidget") + self.description_box = QtWidgets.QWidget() + self.description_box.setObjectName("description_box") + self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.description_box) + self.verticalLayout_2.setContentsMargins(3, 3, 3, 3) + self.verticalLayout_2.setSpacing(0) + self.verticalLayout_2.setObjectName("verticalLayout_2") + self.tabWidget.addTab(self.description_box, "") + self.args_box = QtWidgets.QWidget() + self.args_box.setObjectName("args_box") + self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.args_box) + self.verticalLayout_3.setContentsMargins(3, 3, 3, 3) + self.verticalLayout_3.setSpacing(0) + self.verticalLayout_3.setObjectName("verticalLayout_3") + self.tabWidget.addTab(self.args_box, "") + self.kwargs_box = QtWidgets.QWidget() + self.kwargs_box.setObjectName("kwargs_box") + self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.kwargs_box) + self.verticalLayout_5.setObjectName("verticalLayout_5") + self.tabWidget.addTab(self.kwargs_box, "") + self.namespace_box = QtWidgets.QWidget() + self.namespace_box.setObjectName("namespace_box") + self.verticalLayout_6 = QtWidgets.QVBoxLayout(self.namespace_box) + self.verticalLayout_6.setObjectName("verticalLayout_6") + self.tabWidget.addTab(self.namespace_box, "") + self.plainTextEdit = CodeEditor(self.splitter) + self.plainTextEdit.setEnabled(True) + self.plainTextEdit.setObjectName("plainTextEdit") + self.verticalLayout.addWidget(self.splitter) + self.buttonBox = QtWidgets.QDialogButtonBox(Dialog) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) + self.buttonBox.setObjectName("buttonBox") + self.verticalLayout.addWidget(self.buttonBox) + + self.retranslateUi(Dialog) + self.tabWidget.setCurrentIndex(0) + self.buttonBox.accepted.connect(Dialog.accept) + self.buttonBox.rejected.connect(Dialog.reject) + QtCore.QMetaObject.connectSlotsByName(Dialog) + + def retranslateUi(self, Dialog): + _translate = QtCore.QCoreApplication.translate + Dialog.setWindowTitle(_translate("Dialog", "Create fit function")) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.description_box), _translate("Dialog", "Description")) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.args_box), _translate("Dialog", "Variables")) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.kwargs_box), _translate("Dialog", "Multiple choice")) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.namespace_box), _translate("Dialog", "Available Functions")) +from ..lib.codeeditor import CodeEditor diff --git a/nmreval/gui_qt/_py/fitdialog.py b/src/gui_qt/_py/fitdialog.py similarity index 100% rename from nmreval/gui_qt/_py/fitdialog.py rename to src/gui_qt/_py/fitdialog.py diff --git a/nmreval/gui_qt/_py/fitdialog_window.py b/src/gui_qt/_py/fitdialog_window.py similarity index 100% rename from nmreval/gui_qt/_py/fitdialog_window.py rename to src/gui_qt/_py/fitdialog_window.py diff --git a/nmreval/gui_qt/_py/fitfunctionwidget.py b/src/gui_qt/_py/fitfunctionwidget.py similarity index 100% rename from nmreval/gui_qt/_py/fitfunctionwidget.py rename to src/gui_qt/_py/fitfunctionwidget.py diff --git a/nmreval/gui_qt/_py/fitfuncwidget.py b/src/gui_qt/_py/fitfuncwidget.py similarity index 100% rename from nmreval/gui_qt/_py/fitfuncwidget.py rename to src/gui_qt/_py/fitfuncwidget.py diff --git a/nmreval/gui_qt/_py/fitfuncwidget_old.py b/src/gui_qt/_py/fitfuncwidget_old.py similarity index 100% rename from nmreval/gui_qt/_py/fitfuncwidget_old.py rename to src/gui_qt/_py/fitfuncwidget_old.py diff --git a/nmreval/gui_qt/_py/fitmodelfixwidget.py b/src/gui_qt/_py/fitmodelfixwidget.py similarity index 100% rename from nmreval/gui_qt/_py/fitmodelfixwidget.py rename to src/gui_qt/_py/fitmodelfixwidget.py diff --git a/nmreval/gui_qt/_py/fitmodelwidget.py b/src/gui_qt/_py/fitmodelwidget.py similarity index 100% rename from nmreval/gui_qt/_py/fitmodelwidget.py rename to src/gui_qt/_py/fitmodelwidget.py diff --git a/nmreval/gui_qt/_py/fitparametertable.py b/src/gui_qt/_py/fitparametertable.py similarity index 100% rename from nmreval/gui_qt/_py/fitparametertable.py rename to src/gui_qt/_py/fitparametertable.py diff --git a/nmreval/gui_qt/_py/fitparameterwidget.py b/src/gui_qt/_py/fitparameterwidget.py similarity index 100% rename from nmreval/gui_qt/_py/fitparameterwidget.py rename to src/gui_qt/_py/fitparameterwidget.py diff --git a/nmreval/gui_qt/_py/fitresult.py b/src/gui_qt/_py/fitresult.py similarity index 100% rename from nmreval/gui_qt/_py/fitresult.py rename to src/gui_qt/_py/fitresult.py diff --git a/nmreval/gui_qt/_py/ftdialog.py b/src/gui_qt/_py/ftdialog.py similarity index 100% rename from nmreval/gui_qt/_py/ftdialog.py rename to src/gui_qt/_py/ftdialog.py diff --git a/nmreval/gui_qt/_py/function_tree_widget.py b/src/gui_qt/_py/function_tree_widget.py similarity index 100% rename from nmreval/gui_qt/_py/function_tree_widget.py rename to src/gui_qt/_py/function_tree_widget.py diff --git a/nmreval/gui_qt/_py/gol.py b/src/gui_qt/_py/gol.py similarity index 100% rename from nmreval/gui_qt/_py/gol.py rename to src/gui_qt/_py/gol.py diff --git a/nmreval/gui_qt/_py/gracemsgdialog.py b/src/gui_qt/_py/gracemsgdialog.py similarity index 100% rename from nmreval/gui_qt/_py/gracemsgdialog.py rename to src/gui_qt/_py/gracemsgdialog.py diff --git a/nmreval/gui_qt/_py/gracereader.py b/src/gui_qt/_py/gracereader.py similarity index 100% rename from nmreval/gui_qt/_py/gracereader.py rename to src/gui_qt/_py/gracereader.py diff --git a/nmreval/gui_qt/_py/graph.py b/src/gui_qt/_py/graph.py similarity index 100% rename from nmreval/gui_qt/_py/graph.py rename to src/gui_qt/_py/graph.py diff --git a/nmreval/gui_qt/_py/guidelinewidget.py b/src/gui_qt/_py/guidelinewidget.py similarity index 100% rename from nmreval/gui_qt/_py/guidelinewidget.py rename to src/gui_qt/_py/guidelinewidget.py diff --git a/nmreval/gui_qt/_py/hdftree.py b/src/gui_qt/_py/hdftree.py similarity index 100% rename from nmreval/gui_qt/_py/hdftree.py rename to src/gui_qt/_py/hdftree.py diff --git a/nmreval/gui_qt/_py/integral_widget.py b/src/gui_qt/_py/integral_widget.py similarity index 100% rename from nmreval/gui_qt/_py/integral_widget.py rename to src/gui_qt/_py/integral_widget.py diff --git a/nmreval/gui_qt/_py/integratederive_dialog.py b/src/gui_qt/_py/integratederive_dialog.py similarity index 100% rename from nmreval/gui_qt/_py/integratederive_dialog.py rename to src/gui_qt/_py/integratederive_dialog.py diff --git a/nmreval/gui_qt/_py/interpol_dialog.py b/src/gui_qt/_py/interpol_dialog.py similarity index 100% rename from nmreval/gui_qt/_py/interpol_dialog.py rename to src/gui_qt/_py/interpol_dialog.py diff --git a/nmreval/gui_qt/_py/lineedit_dialog.py b/src/gui_qt/_py/lineedit_dialog.py similarity index 100% rename from nmreval/gui_qt/_py/lineedit_dialog.py rename to src/gui_qt/_py/lineedit_dialog.py diff --git a/nmreval/gui_qt/_py/mean_form.py b/src/gui_qt/_py/mean_form.py similarity index 100% rename from nmreval/gui_qt/_py/mean_form.py rename to src/gui_qt/_py/mean_form.py diff --git a/nmreval/gui_qt/_py/meandialog.py b/src/gui_qt/_py/meandialog.py similarity index 100% rename from nmreval/gui_qt/_py/meandialog.py rename to src/gui_qt/_py/meandialog.py diff --git a/nmreval/gui_qt/_py/modelwidget.py b/src/gui_qt/_py/modelwidget.py similarity index 100% rename from nmreval/gui_qt/_py/modelwidget.py rename to src/gui_qt/_py/modelwidget.py diff --git a/nmreval/gui_qt/_py/move_dialog.py b/src/gui_qt/_py/move_dialog.py similarity index 100% rename from nmreval/gui_qt/_py/move_dialog.py rename to src/gui_qt/_py/move_dialog.py diff --git a/nmreval/gui_qt/_py/namespace_widget.py b/src/gui_qt/_py/namespace_widget.py similarity index 100% rename from nmreval/gui_qt/_py/namespace_widget.py rename to src/gui_qt/_py/namespace_widget.py diff --git a/nmreval/gui_qt/_py/option_selection.py b/src/gui_qt/_py/option_selection.py similarity index 100% rename from nmreval/gui_qt/_py/option_selection.py rename to src/gui_qt/_py/option_selection.py diff --git a/nmreval/gui_qt/_py/parameterform.py b/src/gui_qt/_py/parameterform.py similarity index 100% rename from nmreval/gui_qt/_py/parameterform.py rename to src/gui_qt/_py/parameterform.py diff --git a/nmreval/gui_qt/_py/phase_corr_dialog.py b/src/gui_qt/_py/phase_corr_dialog.py similarity index 100% rename from nmreval/gui_qt/_py/phase_corr_dialog.py rename to src/gui_qt/_py/phase_corr_dialog.py diff --git a/nmreval/gui_qt/_py/plotConfigTemplate.py b/src/gui_qt/_py/plotConfigTemplate.py similarity index 100% rename from nmreval/gui_qt/_py/plotConfigTemplate.py rename to src/gui_qt/_py/plotConfigTemplate.py diff --git a/nmreval/gui_qt/_py/pokemon.py b/src/gui_qt/_py/pokemon.py similarity index 100% rename from nmreval/gui_qt/_py/pokemon.py rename to src/gui_qt/_py/pokemon.py diff --git a/nmreval/gui_qt/_py/propwidget.py b/src/gui_qt/_py/propwidget.py similarity index 100% rename from nmreval/gui_qt/_py/propwidget.py rename to src/gui_qt/_py/propwidget.py diff --git a/nmreval/gui_qt/_py/ptstab.py b/src/gui_qt/_py/ptstab.py similarity index 100% rename from nmreval/gui_qt/_py/ptstab.py rename to src/gui_qt/_py/ptstab.py diff --git a/nmreval/gui_qt/_py/qfiledialog.py b/src/gui_qt/_py/qfiledialog.py similarity index 100% rename from nmreval/gui_qt/_py/qfiledialog.py rename to src/gui_qt/_py/qfiledialog.py diff --git a/nmreval/gui_qt/_py/save_fit_parameter.py b/src/gui_qt/_py/save_fit_parameter.py similarity index 100% rename from nmreval/gui_qt/_py/save_fit_parameter.py rename to src/gui_qt/_py/save_fit_parameter.py diff --git a/nmreval/gui_qt/_py/save_fitmodel_dialog.py b/src/gui_qt/_py/save_fitmodel_dialog.py similarity index 100% rename from nmreval/gui_qt/_py/save_fitmodel_dialog.py rename to src/gui_qt/_py/save_fitmodel_dialog.py diff --git a/nmreval/gui_qt/_py/save_options.py b/src/gui_qt/_py/save_options.py similarity index 100% rename from nmreval/gui_qt/_py/save_options.py rename to src/gui_qt/_py/save_options.py diff --git a/nmreval/gui_qt/_py/saveoptions.py b/src/gui_qt/_py/saveoptions.py similarity index 100% rename from nmreval/gui_qt/_py/saveoptions.py rename to src/gui_qt/_py/saveoptions.py diff --git a/nmreval/gui_qt/_py/sdmodelwidget.py b/src/gui_qt/_py/sdmodelwidget.py similarity index 100% rename from nmreval/gui_qt/_py/sdmodelwidget.py rename to src/gui_qt/_py/sdmodelwidget.py diff --git a/nmreval/gui_qt/_py/selection_widget.py b/src/gui_qt/_py/selection_widget.py similarity index 100% rename from nmreval/gui_qt/_py/selection_widget.py rename to src/gui_qt/_py/selection_widget.py diff --git a/nmreval/gui_qt/_py/setbyfunction_dialog.py b/src/gui_qt/_py/setbyfunction_dialog.py similarity index 100% rename from nmreval/gui_qt/_py/setbyfunction_dialog.py rename to src/gui_qt/_py/setbyfunction_dialog.py diff --git a/nmreval/gui_qt/_py/shift_scale_dialog.py b/src/gui_qt/_py/shift_scale_dialog.py similarity index 99% rename from nmreval/gui_qt/_py/shift_scale_dialog.py rename to src/gui_qt/_py/shift_scale_dialog.py index b8605e5..7997c30 100644 --- a/nmreval/gui_qt/_py/shift_scale_dialog.py +++ b/src/gui_qt/_py/shift_scale_dialog.py @@ -310,5 +310,5 @@ class Ui_shift_dialog(object): self.overwrite_checkbox.setText(_translate("shift_dialog", "Overwrite data")) self.data_newgraph.setText(_translate("shift_dialog", "New graph")) self.values_newgraph.setText(_translate("shift_dialog", "New graph")) -from ..lib.utils import SciSpinBox +from ..lib.spinboxes import SciSpinBox from pyqtgraph import PlotWidget diff --git a/nmreval/gui_qt/_py/skipdialog.py b/src/gui_qt/_py/skipdialog.py similarity index 100% rename from nmreval/gui_qt/_py/skipdialog.py rename to src/gui_qt/_py/skipdialog.py diff --git a/nmreval/gui_qt/_py/smoothdialog.py b/src/gui_qt/_py/smoothdialog.py similarity index 100% rename from nmreval/gui_qt/_py/smoothdialog.py rename to src/gui_qt/_py/smoothdialog.py diff --git a/nmreval/gui_qt/_py/t1_calc_dialog.py b/src/gui_qt/_py/t1_calc_dialog.py similarity index 100% rename from nmreval/gui_qt/_py/t1_calc_dialog.py rename to src/gui_qt/_py/t1_calc_dialog.py diff --git a/nmreval/gui_qt/_py/t1_dock.py b/src/gui_qt/_py/t1_dock.py similarity index 100% rename from nmreval/gui_qt/_py/t1_dock.py rename to src/gui_qt/_py/t1_dock.py diff --git a/nmreval/gui_qt/_py/t1_tau_calculation.py b/src/gui_qt/_py/t1_tau_calculation.py similarity index 100% rename from nmreval/gui_qt/_py/t1_tau_calculation.py rename to src/gui_qt/_py/t1_tau_calculation.py diff --git a/nmreval/gui_qt/_py/t1dialog.py b/src/gui_qt/_py/t1dialog.py similarity index 100% rename from nmreval/gui_qt/_py/t1dialog.py rename to src/gui_qt/_py/t1dialog.py diff --git a/nmreval/gui_qt/_py/tntdialog.py b/src/gui_qt/_py/tntdialog.py similarity index 100% rename from nmreval/gui_qt/_py/tntdialog.py rename to src/gui_qt/_py/tntdialog.py diff --git a/nmreval/gui_qt/_py/typeconversion.py b/src/gui_qt/_py/typeconversion.py similarity index 100% rename from nmreval/gui_qt/_py/typeconversion.py rename to src/gui_qt/_py/typeconversion.py diff --git a/nmreval/gui_qt/_py/untitled.py b/src/gui_qt/_py/untitled.py similarity index 100% rename from nmreval/gui_qt/_py/untitled.py rename to src/gui_qt/_py/untitled.py diff --git a/nmreval/gui_qt/_py/userfitassist.py b/src/gui_qt/_py/userfitassist.py similarity index 100% rename from nmreval/gui_qt/_py/userfitassist.py rename to src/gui_qt/_py/userfitassist.py diff --git a/nmreval/gui_qt/_py/usermodeleditor.py b/src/gui_qt/_py/usermodeleditor.py similarity index 100% rename from nmreval/gui_qt/_py/usermodeleditor.py rename to src/gui_qt/_py/usermodeleditor.py diff --git a/nmreval/gui_qt/_py/valueeditor.py b/src/gui_qt/_py/valueeditor.py similarity index 100% rename from nmreval/gui_qt/_py/valueeditor.py rename to src/gui_qt/_py/valueeditor.py diff --git a/nmreval/gui_qt/data/__init__.py b/src/gui_qt/data/__init__.py similarity index 100% rename from nmreval/gui_qt/data/__init__.py rename to src/gui_qt/data/__init__.py diff --git a/nmreval/gui_qt/data/container.py b/src/gui_qt/data/container.py similarity index 98% rename from nmreval/gui_qt/data/container.py rename to src/gui_qt/data/container.py index 285f60e..b1b5b51 100644 --- a/nmreval/gui_qt/data/container.py +++ b/src/gui_qt/data/container.py @@ -1,3 +1,4 @@ +from __future__ import annotations from collections import OrderedDict from itertools import cycle from typing import Any @@ -5,14 +6,14 @@ from typing import Any import numpy as np from pyqtgraph import mkPen -from ...data.points import Points -from ...data.signals import Signal -from ...utils.text import convert -from ...data.bds import BDS -from ...lib.colors import BaseColor, TUColors -from ...lib.lines import LineStyle -from ...lib.symbols import SymbolStyle, symbolcycle -from ...data.nmr import Spectrum, FID +from nmreval.data.points import Points +from nmreval.data.signals import Signal +from nmreval.utils.text import convert +from nmreval.data.bds import BDS +from nmreval.lib.colors import BaseColor, TUColors +from nmreval.lib.lines import LineStyle +from nmreval.lib.symbols import SymbolStyle, symbolcycle +from nmreval.data.nmr import Spectrum, FID from ..Qt import QtCore, QtGui from ..io.exporters import GraceExporter @@ -254,7 +255,7 @@ class ExperimentContainer(QtCore.QObject): def has_fits(self): return len(self._fits) != 0 - def set_fits(self, value: str or list, replace: bool = False): + def set_fits(self, value: str | list, replace: bool = False): if isinstance(value, str): value = [value] diff --git a/nmreval/gui_qt/data/conversion.py b/src/gui_qt/data/conversion.py similarity index 100% rename from nmreval/gui_qt/data/conversion.py rename to src/gui_qt/data/conversion.py diff --git a/nmreval/gui_qt/data/datawidget/__init__.py b/src/gui_qt/data/datawidget/__init__.py similarity index 100% rename from nmreval/gui_qt/data/datawidget/__init__.py rename to src/gui_qt/data/datawidget/__init__.py diff --git a/nmreval/gui_qt/data/datawidget/datawidget.py b/src/gui_qt/data/datawidget/datawidget.py similarity index 99% rename from nmreval/gui_qt/data/datawidget/datawidget.py rename to src/gui_qt/data/datawidget/datawidget.py index 55298ad..09ed6a0 100644 --- a/nmreval/gui_qt/data/datawidget/datawidget.py +++ b/src/gui_qt/data/datawidget/datawidget.py @@ -1,6 +1,7 @@ from typing import List, Tuple, Union from nmreval.lib.colors import available_cycles + from .properties import PropWidget from ...Qt import QtWidgets, QtGui, QtCore from ..._py.datawidget import Ui_DataWidget diff --git a/nmreval/gui_qt/data/datawidget/properties.py b/src/gui_qt/data/datawidget/properties.py similarity index 100% rename from nmreval/gui_qt/data/datawidget/properties.py rename to src/gui_qt/data/datawidget/properties.py diff --git a/nmreval/gui_qt/data/integral_widget.py b/src/gui_qt/data/integral_widget.py similarity index 100% rename from nmreval/gui_qt/data/integral_widget.py rename to src/gui_qt/data/integral_widget.py diff --git a/nmreval/gui_qt/data/interpolate_dialog.py b/src/gui_qt/data/interpolate_dialog.py similarity index 100% rename from nmreval/gui_qt/data/interpolate_dialog.py rename to src/gui_qt/data/interpolate_dialog.py diff --git a/nmreval/gui_qt/data/plot_dialog.py b/src/gui_qt/data/plot_dialog.py similarity index 96% rename from nmreval/gui_qt/data/plot_dialog.py rename to src/gui_qt/data/plot_dialog.py index 9291bcc..3fb878d 100644 --- a/nmreval/gui_qt/data/plot_dialog.py +++ b/src/gui_qt/data/plot_dialog.py @@ -2,9 +2,9 @@ from random import randint import numpy as np -from ... import models -from ...lib.importer import find_models -from ...lib.utils import valid_function +from nmreval import models +from nmreval.lib.importer import find_models +from nmreval.lib.utils import valid_function from ..Qt import QtGui, QtCore, QtWidgets from .._py.setbyfunction_dialog import Ui_NewCurveDialog diff --git a/nmreval/gui_qt/data/point_select.py b/src/gui_qt/data/point_select.py similarity index 100% rename from nmreval/gui_qt/data/point_select.py rename to src/gui_qt/data/point_select.py index c400249..f821ccd 100644 --- a/nmreval/gui_qt/data/point_select.py +++ b/src/gui_qt/data/point_select.py @@ -2,10 +2,10 @@ import re from ..Qt import QtCore, QtWidgets from .._py.ptstab import Ui_Form +from ..lib.pg_objects import LogInfiniteLine, RegionItem __all__ = ['PointSelectWidget'] -from ..lib.pg_objects import LogInfiniteLine, RegionItem REGION_RE = re.compile(r'(?P[+-]*\d+(?:\.\d*)*(?:[eE][+-]*\d+)*)' r'(?: ?- ?(?P[+-]*\d+(?:\.\d*)*(?:[eE][+-]*\d+)*))*') diff --git a/nmreval/gui_qt/data/shift_graphs.py b/src/gui_qt/data/shift_graphs.py similarity index 99% rename from nmreval/gui_qt/data/shift_graphs.py rename to src/gui_qt/data/shift_graphs.py index 3ea8201..fdbd033 100644 --- a/nmreval/gui_qt/data/shift_graphs.py +++ b/src/gui_qt/data/shift_graphs.py @@ -3,7 +3,8 @@ from itertools import cycle from pyqtgraph import mkColor, mkPen -from ...lib.colors import Tab10 +from nmreval.lib.colors import Tab10 + from ..Qt import QtGui, QtCore, QtWidgets from .._py.shift_scale_dialog import Ui_shift_dialog from ..lib.pg_objects import PlotItem diff --git a/nmreval/gui_qt/data/signaledit/__init__.py b/src/gui_qt/data/signaledit/__init__.py similarity index 100% rename from nmreval/gui_qt/data/signaledit/__init__.py rename to src/gui_qt/data/signaledit/__init__.py diff --git a/nmreval/gui_qt/data/signaledit/baseline_dialog.py b/src/gui_qt/data/signaledit/baseline_dialog.py similarity index 94% rename from nmreval/gui_qt/data/signaledit/baseline_dialog.py rename to src/gui_qt/data/signaledit/baseline_dialog.py index c231cd7..79ca27b 100644 --- a/nmreval/gui_qt/data/signaledit/baseline_dialog.py +++ b/src/gui_qt/data/signaledit/baseline_dialog.py @@ -16,14 +16,16 @@ class QBaselineDialog(QtWidgets.QDialog, Ui_SignalEdit): self.data = None - self.graph = pg.PlotDataItem(x=[], y=[], pen=pg.mkPen({'color': 'b'})) - self.graph_corr = pg.PlotDataItem(x=[], y=[], pen=pg.mkPen({'color': 'r'})) - self.baseline = pg.PlotDataItem(x=[], y=[]) + self.graph = pg.PlotDataItem(x=[], y=[], pen=pg.mkPen({'color': 'b'}), name='Original') + self.graph_corr = pg.PlotDataItem(x=[], y=[], pen=pg.mkPen({'color': 'r'}), name='Corrected') + self.baseline = pg.PlotDataItem(x=[], y=[], name='Baseline') self.anchors = [] self.anchor_lines = [] self.spline = None + self.legend = self.graphicsView.addLegend() + self.graphicsView.scene().sigMouseClicked.connect(self.add_node) self.graphicsView.addItem(self.graph_corr) self.graphicsView.addItem(self.graph) diff --git a/nmreval/gui_qt/data/signaledit/editsignalwidget.py b/src/gui_qt/data/signaledit/editsignalwidget.py similarity index 96% rename from nmreval/gui_qt/data/signaledit/editsignalwidget.py rename to src/gui_qt/data/signaledit/editsignalwidget.py index 23bb9cd..1137ce3 100644 --- a/nmreval/gui_qt/data/signaledit/editsignalwidget.py +++ b/src/gui_qt/data/signaledit/editsignalwidget.py @@ -1,6 +1,6 @@ -from ....math import apodization -from ....lib.importer import find_models -from ....utils.text import convert +from src.nmreval.math import apodization +from src.nmreval.lib.importer import find_models +from src.nmreval.utils.text import convert from ...Qt import QtCore, QtWidgets, QtGui from ...lib.forms import FormWidget diff --git a/nmreval/gui_qt/data/signaledit/phase_dialog.py b/src/gui_qt/data/signaledit/phase_dialog.py similarity index 95% rename from nmreval/gui_qt/data/signaledit/phase_dialog.py rename to src/gui_qt/data/signaledit/phase_dialog.py index 6bd670f..ceeb3a7 100644 --- a/nmreval/gui_qt/data/signaledit/phase_dialog.py +++ b/src/gui_qt/data/signaledit/phase_dialog.py @@ -1,12 +1,14 @@ +from __future__ import annotations + import numpy as np from pyqtgraph import mkPen from numpy import inf, linspace from numpy.fft import fft, fftfreq, fftshift from ...lib.pg_objects import PlotItem, LogInfiniteLine -from ....lib.importer import find_models -from ....math import apodization as apodization -from ....utils.text import convert +from nmreval.lib.importer import find_models +from nmreval.math import apodization as apodization +from nmreval.utils.text import convert from ...Qt import QtCore, QtWidgets from ..._py.apod_dialog import Ui_ApodEdit @@ -36,7 +38,7 @@ class QPreviewDialogs(QtWidgets.QDialog): def add_data(self, x, y): self.data.append((x, y)) - real_plt = PlotItem(x=x, y=y.real, pen=mkPen('b')) + real_plt = PlotItem(x=x, y=y.real, pen=mkPen('b'), ) imag_plt = PlotItem(x=x, y=y.imag, pen=mkPen('r')) self.graphs.append((real_plt, imag_plt)) self.graphicsView.addItem(real_plt) @@ -91,7 +93,7 @@ class QPhasedialog(QPreviewDialogs, Ui_SignalEdit): self.pvt_line.setValue(pvt) for i, (x, y) in enumerate(self.data): - phasecorr = np.exp(1j * (ph0 + ph1*(x-pvt)/np.max(x))*np.pi/180.) + phasecorr = np.exp(-1j * (ph0 + ph1*(x-pvt)/np.max(x))*np.pi/180.) _y = y * phasecorr self.graphs[i][0].setData(x=x, y=_y.real) diff --git a/nmreval/gui_qt/data/valueeditwidget.py b/src/gui_qt/data/valueeditwidget.py similarity index 99% rename from nmreval/gui_qt/data/valueeditwidget.py rename to src/gui_qt/data/valueeditwidget.py index fc39a73..4d9f4b2 100644 --- a/nmreval/gui_qt/data/valueeditwidget.py +++ b/src/gui_qt/data/valueeditwidget.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Any, List +from typing import Any import numpy as np @@ -227,7 +227,7 @@ class ValueModel(QtCore.QAbstractTableModel): def columnCount(self, *args, **kwargs) -> int: return len(self.headers) - def loadData(self, data: List[np.ndarray], mask: np.ndarray): + def loadData(self, data: list[np.ndarray], mask: np.ndarray): self.beginResetModel() self._data = [] for x, y, y_err in zip(*data): diff --git a/nmreval/gui_qt/fit/__init__.py b/src/gui_qt/fit/__init__.py similarity index 100% rename from nmreval/gui_qt/fit/__init__.py rename to src/gui_qt/fit/__init__.py diff --git a/nmreval/gui_qt/fit/fit_forms.py b/src/gui_qt/fit/fit_forms.py similarity index 98% rename from nmreval/gui_qt/fit/fit_forms.py rename to src/gui_qt/fit/fit_forms.py index 354d02d..fe33211 100644 --- a/nmreval/gui_qt/fit/fit_forms.py +++ b/src/gui_qt/fit/fit_forms.py @@ -1,8 +1,7 @@ from __future__ import annotations -from typing import List, Tuple, Union +from nmreval.utils.text import convert -from ...utils.text import convert from ..Qt import QtCore, QtWidgets, QtGui from .._py.fitmodelwidget import Ui_FitParameter from .._py.save_fitmodel_dialog import Ui_SaveDialog @@ -68,7 +67,7 @@ class FitModelWidget(QtWidgets.QWidget, Ui_FitParameter): self.lineEdit.setEnabled(value == 2) self.lineEdit_2.setEnabled(value == 2) - def set_parameter(self, p: float | None, bds: Tuple[float, float, bool] = None, + def set_parameter(self, p: float | None, bds: tuple[float, float, bool] = None, fixed: bool = None, glob: bool = None): if p is None: # bad hack: linked parameter return (None, linked parameter) @@ -281,7 +280,7 @@ class FitModelTree(QtWidgets.QTreeWidget): idx = item.data(0, self.counterRole) self.itemRemoved.emit(idx) - def add_function(self, idx: int, cnt: int, op: int, name: str, color: Union[QtGui.QColor, str, tuple], + def add_function(self, idx: int, cnt: int, op: int, name: str, color: QtGui.QColor | str | tuple, parent: QtWidgets.QTreeWidgetItem = None, children: list = None, active: bool = True, **kwargs): """ Add function to tree and dictionary of functions. @@ -403,7 +402,7 @@ class FitTableWidget(QtWidgets.QTableWidget): self.hideColumn(1) self.resizeColumnToContents(0) - def load(self, set_ids: List[str]): + def load(self, set_ids: list[str]): self.blockSignals(True) while self.rowCount(): diff --git a/nmreval/gui_qt/fit/fit_parameter.py b/src/gui_qt/fit/fit_parameter.py similarity index 99% rename from nmreval/gui_qt/fit/fit_parameter.py rename to src/gui_qt/fit/fit_parameter.py index f2d4111..1027519 100644 --- a/nmreval/gui_qt/fit/fit_parameter.py +++ b/src/gui_qt/fit/fit_parameter.py @@ -1,6 +1,7 @@ from __future__ import annotations -from ...utils.text import convert +from nmreval.utils.text import convert + from ..Qt import QtWidgets, QtCore, QtGui from .._py.fitfuncwidget import Ui_FormFit from ..lib.forms import SelectionWidget diff --git a/nmreval/gui_qt/fit/fitfunction.py b/src/gui_qt/fit/fitfunction.py similarity index 94% rename from nmreval/gui_qt/fit/fitfunction.py rename to src/gui_qt/fit/fitfunction.py index 0d98c4b..9eab41f 100644 --- a/nmreval/gui_qt/fit/fitfunction.py +++ b/src/gui_qt/fit/fitfunction.py @@ -1,15 +1,16 @@ +from __future__ import annotations + from itertools import cycle, count -from typing import List, Tuple, Union + +from nmreval.configs import config_paths +from nmreval import models +from nmreval.lib.importer import find_models +from nmreval.lib.colors import BaseColor, Tab10 +from nmreval.utils.text import convert from ..lib import get_icon from .._py.fitfunctionwidget import Ui_Form from ..Qt import QtWidgets, QtCore, QtGui -from ...configs import config_paths -from ... import models -from ...lib.importer import find_models -from ...lib.colors import BaseColor, Tab10 -from ...utils.text import convert - class QFunctionWidget(QtWidgets.QWidget, Ui_Form): func_cnt = count() @@ -104,7 +105,7 @@ class QFunctionWidget(QtWidgets.QWidget, Ui_Form): self.add_function(idx, cnt, op, name, col) def add_function(self, idx: int, cnt: int, op: int, - name: str, color: Union[str, Tuple[float, float, float], BaseColor], **kwargs): + name: str, color: str | tuple[float, float, float] | BaseColor, **kwargs): """ Add function to tree and dictionary of functions. """ @@ -160,7 +161,7 @@ class QFunctionWidget(QtWidgets.QWidget, Ui_Form): return used_functions - def _prepare_function_for_model(self, func_list: List[dict], + def _prepare_function_for_model(self, func_list: list[dict], full: bool = True, clsname: bool = False, include_all: bool = True): for func_args in func_list: diff --git a/nmreval/gui_qt/fit/fitwindow.py b/src/gui_qt/fit/fitwindow.py similarity index 99% rename from nmreval/gui_qt/fit/fitwindow.py rename to src/gui_qt/fit/fitwindow.py index 99abc5f..173d6e6 100644 --- a/nmreval/gui_qt/fit/fitwindow.py +++ b/src/gui_qt/fit/fitwindow.py @@ -9,13 +9,14 @@ from typing import Dict, List, Tuple import numpy as np from pyqtgraph import mkPen +from nmreval.fit._meta import MultiModel, ModelFactory +from nmreval.fit.result import FitResult + from .fit_forms import FitTableWidget from .fit_parameter import QFitParameterWidget from ..lib.pg_objects import PlotItem from ..Qt import QtGui, QtCore, QtWidgets from .._py.fitdialog import Ui_FitDialog -from ...fit._meta import MultiModel, ModelFactory -from ...fit.result import FitResult class QFitDialog(QtWidgets.QWidget, Ui_FitDialog): diff --git a/src/gui_qt/fit/function_creation_dialog.py b/src/gui_qt/fit/function_creation_dialog.py new file mode 100644 index 0000000..8d6c2a0 --- /dev/null +++ b/src/gui_qt/fit/function_creation_dialog.py @@ -0,0 +1,449 @@ +from __future__ import annotations + +import inspect +import numbers +import textwrap +from typing import Any + +import numpy as np + +from gui_qt.Qt import QtCore, QtWidgets, QtGui +from gui_qt._py.fitcreationdialog import Ui_Dialog +from gui_qt.lib.namespace import QNamespaceWidget + +__all__ = ['QUserFitCreator'] + +validator = QtGui.QRegExpValidator(QtCore.QRegExp('[A-Za-z]\S*')) + + +class QUserFitCreator(QtWidgets.QDialog, Ui_Dialog): + classCreated = QtCore.pyqtSignal(object) + + def __init__(self, parent=None): + super().__init__(parent=parent) + self.setupUi(self) + + self.description_widget = DescWidget(self) + self.args_widget = ArgWidget(self) + self.kwargs_widget = KwargsWidget(self) + self.kwargs_widget.Changed.connect(self.update_function) + self.namespace_widget = QNamespaceWidget(self) + self.namespace_widget.make_namespace() + self.namespace_widget.sendKey.connect(self.namespace_made) + + for b, w in [(self.description_box, self.description_widget), (self.args_box, self.args_widget), + (self.kwargs_box, self.kwargs_widget), (self.namespace_box, self.namespace_widget)]: + b.layout().addWidget(w) + try: + w.Changed.connect(self.update_function) + except AttributeError: + pass + b.layout().addStretch() + + self._imports = set() + + self.update_function() + + def __call__(self, *args, **kwargs): + return self + + def update_function(self): + try: + var = self.args_widget.get_parameter() + var += self.kwargs_widget.get_parameter() + + k = '' + for imps in self._imports: + if len(imps) == 2: + k += f'from {imps[0]} import {imps[1]}\n' + elif imps[0] == 'numpy': + k += 'import numpy as np\n' + + if len(self._imports): + k += '\n\n' + + k += self.description_widget.get_strings() + k += self.args_widget.get_strings() + k += self.kwargs_widget.get_strings() + + k += '\n @staticmethod\n' + k += f" def func(x, {', '.join(var)}):\n" + + self.plainTextEdit.setPlainText(k) + except Exception as e: + QtWidgets.QMessageBox.warning(self, 'Failure', f'Error found: {e.args[0]}') + + def change_visibility(self): + sender = self.sender() + + for box in (self.description_box, self.args_box, self.kwargs_box, self.namespace_box): + box.blockSignals(True) + box.setExpansion(sender == box) + box.blockSignals(False) + + def namespace_made(self, invalue: str): + ns = self.namespace_widget.namespace.namespace + func_value = ns[invalue][0] + ret_func = '' + + if func_value is None: + ret_func = invalue + + elif isinstance(func_value, numbers.Number): + ret_func = func_value + + elif isinstance(func_value, np.ufunc): + self._imports.add(('numpy',)) + ret_func = 'np.'+func_value.__name__ + '(x)' + + else: + f_string = ns[invalue][-1] + args = f_string[f_string.find('('):] + if inspect.ismethod(func_value): + ret_func = func_value.__self__.__name__ + '.func'+args + elif hasattr(func_value, '__qualname__'): + ret_func = func_value.__qualname__.split('.')[0] + self._imports.add((inspect.getmodule(func_value).__name__, ret_func)) + + self.plainTextEdit.insertPlainText(ret_func) + self.update_function() + + +class KwargsWidget(QtWidgets.QWidget): + Changed = QtCore.pyqtSignal() + + def __init__(self, parent=None): + super().__init__(parent=parent) + self._num_kwargs = 0 + + self._setup_ui() + + def _setup_ui(self): + layout = QtWidgets.QGridLayout() + layout.setContentsMargins(3, 3, 3, 3) + layout.setHorizontalSpacing(3) + + self.use_nuclei = QtWidgets.QCheckBox('Add gyromagnetic ratio', self) + self.use_nuclei.stateChanged.connect(lambda x: self.Changed.emit()) + layout.addWidget(self.use_nuclei, 0, 0, 1, 3) + + self.choices = QtWidgets.QTabWidget(self) + layout.addWidget(self.choices, 1, 0, 1, 3) + + self.add_choice_button = QtWidgets.QPushButton('Add choice', self) + self.add_choice_button.clicked.connect(self.add_choice) + layout.addWidget(self.add_choice_button, 2, 0, 1, 1) + + self.rem_choice_button = QtWidgets.QPushButton('Remove choice', self) + self.rem_choice_button.clicked.connect(self.remove_choice) + layout.addWidget(self.rem_choice_button, 2, 1, 1, 1) + + self.setLayout(layout) + + def add_choice(self): + cnt = self._num_kwargs + c = ChoiceWidget(cnt, self) + c.Changed.connect(self.update_choice) + self.choices.addTab(c, c.name_line.text()) + + self._num_kwargs += 1 + + self.choices.setCurrentIndex(cnt) + self.Changed.emit() + + def remove_choice(self): + cnt = self.choices.currentIndex() + self.choices.removeTab(cnt) + self.Changed.emit() + + def update_choice(self): + idx = self.choices.currentIndex() + self.choices.setTabText(idx, self.sender().name_line.text()) + self.Changed.emit() + + def get_parameter(self): + if self.use_nuclei.isChecked(): + var = ['nucleus=2.67522128e7'] + else: + var = [] + var += [self.choices.widget(idx).get_parameter() for idx in range(self.choices.count())] + + return var + + def get_strings(self) -> str: + kwargs = [] + if self.use_nuclei.isChecked(): + kwargs.append("(r'\gamma', 'nucleus', gamma)") + + for i in range(self.choices.count()): + kwargs.append(self.choices.widget(i).get_strings()) + if kwargs: + return f" choices = {', '.join(kwargs)}\n" + else: + return '' + + +class ChoiceWidget(QtWidgets.QWidget): + Changed = QtCore.pyqtSignal() + + def __init__(self, idx: int, parent=None): + super().__init__(parent=parent) + + self._setup_ui() + + self.name_line.setText('choice' + str(idx)) + self.add_option() + + def _setup_ui(self): + layout = QtWidgets.QGridLayout() + layout.setContentsMargins(3, 3, 3, 3) + layout.setHorizontalSpacing(3) + + self.name_label = QtWidgets.QLabel('Name', self) + layout.addWidget(self.name_label, 0, 0, 1, 1) + self.name_line = QtWidgets.QLineEdit(self) + self.name_line.textChanged.connect(lambda x: self.Changed.emit()) + layout.addWidget(self.name_line, 0, 1, 1, 1) + + self.disp_label = QtWidgets.QLabel('Disp. name', self) + layout.addWidget(self.disp_label, 1, 0, 1, 1) + self.display_line = QtWidgets.QLineEdit(self) + self.display_line.textChanged.connect(lambda x: self.Changed.emit()) + layout.addWidget(self.display_line, 1, 1, 1, 1) + + self.add_button = QtWidgets.QPushButton('Add option', self) + self.add_button.clicked.connect(self.add_option) + layout.addWidget(self.add_button, 2, 0, 1, 2) + + self.remove_button = QtWidgets.QPushButton('Remove option', self) + self.remove_button.clicked.connect(self.remove_option) + layout.addWidget(self.remove_button, 3, 0, 1, 2) + + self.table = QtWidgets.QTableWidget(self) + self.table.setColumnCount(3) + self.table.setHorizontalHeaderLabels(['Name', 'Value', 'Type']) + self.table.itemChanged.connect(lambda x: self.Changed.emit()) + layout.addWidget(self.table, 0, 2, 4, 1) + + self.setLayout(layout) + + def add_option(self): + self.table.blockSignals(True) + row = self.table.rowCount() + self.table.setRowCount(row+1) + + self.table.setItem(row, 0, QtWidgets.QTableWidgetItem('opt' + str(row))) + lineedit = QtWidgets.QLineEdit() + lineedit.setValidator(validator) + lineedit.setFrame(False) + lineedit.setText('opt'+str(row)) + lineedit.textChanged.connect(lambda x: self.Changed.emit()) + self.table.setCellWidget(row, 0, lineedit) + self.table.setItem(row, 1, QtWidgets.QTableWidgetItem('None')) + + self.table.setItem(row, 2, QtWidgets.QTableWidgetItem('')) + cb = QtWidgets.QComboBox() + cb.addItems(['None', 'str', 'float', 'int', 'bool']) + cb.currentIndexChanged.connect(lambda x: self.Changed.emit()) + self.table.setCellWidget(row, 2, cb) + + self.table.blockSignals(False) + + self.Changed.emit() + + def remove_option(self): + if self.table.rowCount() > 1: + self.table.blockSignals(True) + self.table.removeRow(self.table.currentRow()) + self.table.blockSignals(False) + self.Changed.emit() + + def get_parameter(self) -> str: + return f'{self.name_line.text()}={self._make_value(0)!r}' + + def get_strings(self) -> str: + opts = [] + for i in range(self.table.rowCount()): + name = self.table.item(i, 0).text() + val = self._make_value(i) + opts.append(f'{name!r}: {val!r}') + + opts = f"{{{', '.join(opts)}}}" + + disp = self.display_line.text() + name = self.name_line.text() + if disp == '': + ret_val = '(' + ', '.join([repr(name), repr(name), opts]) + ')' + else: + ret_val = '(' + ', '.join([repr(name), repr(disp), opts]) + ')' + + return ret_val + + def _make_value(self, i) -> Any: + dtype = self.table.cellWidget(i, 2).currentIndex() + val = self.table.item(i, 1).text() + cast = [None, str, float, int, bool] + if dtype == 0: + val = None + else: + try: + val = cast[dtype](val) + except: + raise ValueError(f'Invalid argument for {self.table.cellWidget(i, 0).text()}') + + return val + + +class ArgWidget(QtWidgets.QWidget): + Changed = QtCore.pyqtSignal() + + def __init__(self, parent=None): + super().__init__(parent=parent) + + self._setup_ui() + + def _setup_ui(self): + layout = QtWidgets.QGridLayout() + layout.setContentsMargins(3, 3, 3, 3) + layout.setHorizontalSpacing(3) + + self.table = QtWidgets.QTableWidget(self) + self.table.setColumnCount(4) + self.table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) + self.table.setRowCount(0) + self.table.setHorizontalHeaderLabels(['Variable', 'Disp. name', 'Lower bound', 'Upper bound']) + self.table.itemChanged.connect(lambda x: self.Changed.emit()) + layout.addWidget(self.table, 0, 0, 1, 3) + + self.add_button = QtWidgets.QPushButton('Add parameter', self) + self.add_button.clicked.connect(self.add_variable) + layout.addWidget(self.add_button, 1, 0, 1, 1) + + self.rem_button = QtWidgets.QPushButton('Remove parameter', self) + self.rem_button.clicked.connect(self.remove_variable) + layout.addWidget(self.rem_button, 1, 1, 1, 1) + + spacer = QtWidgets.QSpacerItem(0, 0) + layout.addItem(spacer, 1, 2, 1, 1) + + self.setLayout(layout) + + def add_variable(self): + self.table.blockSignals(True) + row = self.table.rowCount() + self.table.setRowCount(row + 1) + + self.table.setItem(row, 0, QtWidgets.QTableWidgetItem('p' + str(row))) + # arguments cannot start with a number or have spaces + lineedit = QtWidgets.QLineEdit() + lineedit.setValidator(validator) + lineedit.setFrame(False) + lineedit.setText('p'+str(row)) + lineedit.textChanged.connect(lambda x: self.Changed.emit()) + self.table.setCellWidget(row, 0, lineedit) + + self.table.setItem(row, 1, QtWidgets.QTableWidgetItem('p_{' + str(row) + '}')) + self.table.setItem(row, 2, QtWidgets.QTableWidgetItem('--')) + self.table.setItem(row, 3, QtWidgets.QTableWidgetItem('--')) + self.table.blockSignals(False) + + self.Changed.emit() + + def remove_variable(self): + self.table.blockSignals(True) + self.table.removeRow(self.table.currentRow()) + self.table.blockSignals(False) + + self.Changed.emit() + + def get_parameter(self) -> list[str]: + var = [] + for row in range(self.table.rowCount()): + var.append(self.table.cellWidget(row, 0).text()) + + return var + + def get_strings(self): + args = [] + bnds = [] + for row in range(self.table.rowCount()): + args.append(self.table.item(row, 1).text()) + lb = self.table.item(row, 2).text() + lb = None if lb in ['--', 'None'] else float(lb) + + ub = self.table.item(row, 3).text() + ub = None if ub in ['--', 'None'] else float(ub) + + if ub is not None and lb is not None: + if not (lb < ub): + raise ValueError('Some bounds are invalid') + + bnds.append(f'({lb}, {ub})') + + stringi = f' params = {args}\n' + stringi += f" bounds = [{', '.join(bnds)}]\n" + + return stringi + + +class DescWidget(QtWidgets.QWidget): + Changed = QtCore.pyqtSignal() + + def __init__(self, parent=None): + super().__init__(parent=parent) + + self._setup_ui() + + def _setup_ui(self): + layout = QtWidgets.QGridLayout() + layout.setContentsMargins(3, 3, 3, 3) + layout.setSpacing(3) + + self.klass_label = QtWidgets.QLabel('Class', self) + layout.addWidget(self.klass_label, 0, 0, 1, 1) + self.klass_lineedit = QtWidgets.QLineEdit(self) + self.klass_lineedit.setValidator(validator) + self.klass_lineedit.setText('UserClass') + self.klass_lineedit.textChanged.connect(lambda x: self.Changed.emit()) + layout.addWidget(self.klass_lineedit, 0, 1, 1, 1) + + self.name_label = QtWidgets.QLabel('Name', self) + layout.addWidget(self.name_label, 1, 0, 1, 1) + self.name_lineedit = QtWidgets.QLineEdit(self) + self.name_lineedit.setText('Name of function') + self.name_lineedit.textChanged.connect(lambda x: self.Changed.emit()) + layout.addWidget(self.name_lineedit, 1, 1, 1, 1) + + self.group_label = QtWidgets.QLabel('Group', self) + layout.addWidget(self.group_label, 2, 0, 1, 1) + self.group_lineedit = QtWidgets.QLineEdit(self) + self.group_lineedit.setText('User-defined') + self.group_lineedit.textChanged.connect(lambda x: self.Changed.emit()) + layout.addWidget(self.group_lineedit, 2, 1, 1, 1) + + self.eq_label = QtWidgets.QLabel('Disp. equation', self) + layout.addWidget(self.eq_label, 3, 0, 1, 1) + self.eq_lineedit = QtWidgets.QLineEdit(self) + self.eq_lineedit.textChanged.connect(lambda x: self.Changed.emit()) + layout.addWidget(self.eq_lineedit, 3, 1, 1, 1) + + self.setLayout(layout) + + def get_strings(self) -> str: + if self.klass_lineedit.text() == '': + raise ValueError('Class name is empty') + stringi = f'class {self.klass_lineedit.text()}:\n' \ + f' name = {self.name_lineedit.text()!r}\n' \ + f' group = {self.group_lineedit.text()!r}\n' \ + f' equation = {self.eq_lineedit.text()!r}\n' + + return stringi + + +if __name__ == '__main__': + import sys + app = QtWidgets.QApplication([]) + win = QUserFitCreator() + win.show() + + sys.exit(app.exec()) diff --git a/nmreval/gui_qt/fit/result.py b/src/gui_qt/fit/result.py similarity index 99% rename from nmreval/gui_qt/fit/result.py rename to src/gui_qt/fit/result.py index fc13198..9fd24a4 100644 --- a/nmreval/gui_qt/fit/result.py +++ b/src/gui_qt/fit/result.py @@ -1,10 +1,10 @@ from math import isnan -from numpy import r_ from pyqtgraph import mkBrush +from nmreval.utils.text import convert + from ..lib.utils import RdBuCMap -from ...utils.text import convert from ..Qt import QtWidgets, QtGui, QtCore from .._py.fitresult import Ui_Dialog from ..lib.pg_objects import PlotItem diff --git a/nmreval/gui_qt/graphs/__init__.py b/src/gui_qt/graphs/__init__.py similarity index 100% rename from nmreval/gui_qt/graphs/__init__.py rename to src/gui_qt/graphs/__init__.py diff --git a/nmreval/gui_qt/graphs/graphwindow.py b/src/gui_qt/graphs/graphwindow.py similarity index 99% rename from nmreval/gui_qt/graphs/graphwindow.py rename to src/gui_qt/graphs/graphwindow.py index 0004b93..64ab6f3 100644 --- a/nmreval/gui_qt/graphs/graphwindow.py +++ b/src/gui_qt/graphs/graphwindow.py @@ -1,15 +1,17 @@ +from __future__ import annotations + import itertools import os import uuid from math import isnan -from typing import List, Union from numpy import errstate, floor, log10 from pyqtgraph import GraphicsObject, getConfigOption, mkColor +from nmreval.utils.text import convert + from ..lib.pg_objects import LegendItemBlock, RegionItem -from ...utils.text import convert from ..Qt import QtCore, QtWidgets, QtGui from .._py.graph import Ui_GraphWindow from ..lib import make_action_icons @@ -127,7 +129,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): self.setWindowTitle(str(value)) @property - def ranges(self): + def ranges(self) -> tuple: r = self.plotItem.getViewBox().viewRange() for i in [0, 1]: if self.log[i]: @@ -137,7 +139,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): return tuple(r) - def add(self, name: Union[str, List], plots: List): + def add(self, name: str | list, plots: list): if isinstance(name, str): name = [name] plots = [plots] @@ -165,7 +167,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): self.show_item(name) - def remove(self, name: Union[str, List]): + def remove(self, name: str | list): if isinstance(name, str): name = [name] @@ -191,7 +193,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): self._update_zorder() self.show_legend() - def move_sets(self, sets, position): + def move_sets(self, sets: list, position: int): move_plots = [] move_items = [] diff --git a/nmreval/gui_qt/graphs/guide_lines.py b/src/gui_qt/graphs/guide_lines.py similarity index 100% rename from nmreval/gui_qt/graphs/guide_lines.py rename to src/gui_qt/graphs/guide_lines.py diff --git a/nmreval/gui_qt/graphs/movedialog.py b/src/gui_qt/graphs/movedialog.py similarity index 100% rename from nmreval/gui_qt/graphs/movedialog.py rename to src/gui_qt/graphs/movedialog.py diff --git a/nmreval/gui_qt/io/__init__.py b/src/gui_qt/io/__init__.py similarity index 100% rename from nmreval/gui_qt/io/__init__.py rename to src/gui_qt/io/__init__.py diff --git a/nmreval/gui_qt/io/asciireader.py b/src/gui_qt/io/asciireader.py similarity index 99% rename from nmreval/gui_qt/io/asciireader.py rename to src/gui_qt/io/asciireader.py index 43a6a9f..f609407 100644 --- a/nmreval/gui_qt/io/asciireader.py +++ b/src/gui_qt/io/asciireader.py @@ -1,4 +1,4 @@ -from ...io.asciireader import AsciiReader +from nmreval.io.asciireader import AsciiReader from ..Qt import QtGui, QtCore, QtWidgets from .._py.asciidialog import Ui_ascii_reader diff --git a/nmreval/gui_qt/io/bdsreader.py b/src/gui_qt/io/bdsreader.py similarity index 98% rename from nmreval/gui_qt/io/bdsreader.py rename to src/gui_qt/io/bdsreader.py index 5f3af5a..dc52c4c 100644 --- a/nmreval/gui_qt/io/bdsreader.py +++ b/src/gui_qt/io/bdsreader.py @@ -1,4 +1,4 @@ -from ...io.bds_reader import BDSReader +from nmreval.io.bds_reader import BDSReader from ..Qt import QtCore, QtWidgets from .._py.bdsdialog import Ui_Dialog diff --git a/nmreval/gui_qt/io/dscreader.py b/src/gui_qt/io/dscreader.py similarity index 98% rename from nmreval/gui_qt/io/dscreader.py rename to src/gui_qt/io/dscreader.py index c272cfe..33f7938 100644 --- a/nmreval/gui_qt/io/dscreader.py +++ b/src/gui_qt/io/dscreader.py @@ -5,10 +5,11 @@ from pathlib import Path import numpy as np from pyqtgraph import PlotDataItem +from nmreval.data.points import Points +from nmreval.io.dsc import Cyclohexane, DSCCalibrator, DSCSample + from ..Qt import QtWidgets, QtCore from .._py.dscfile_dialog import Ui_Dialog -from ...data.points import Points -from ...io.dsc import Cyclohexane, DSCCalibrator, DSCSample class QDSCReader(QtWidgets.QDialog, Ui_Dialog): diff --git a/nmreval/gui_qt/io/exporters.py b/src/gui_qt/io/exporters.py similarity index 97% rename from nmreval/gui_qt/io/exporters.py rename to src/gui_qt/io/exporters.py index 8dec1ed..363fdd5 100644 --- a/nmreval/gui_qt/io/exporters.py +++ b/src/gui_qt/io/exporters.py @@ -2,8 +2,8 @@ from __future__ import annotations from numpy import c_ -from ...io.graceeditor import GraceEditor -from ...utils.text import convert +from nmreval.io.graceeditor import GraceEditor +from nmreval.utils.text import convert from ..Qt import QtGui, QtCore, QtPrintSupport diff --git a/nmreval/gui_qt/io/fcbatchreader.py b/src/gui_qt/io/fcbatchreader.py similarity index 96% rename from nmreval/gui_qt/io/fcbatchreader.py rename to src/gui_qt/io/fcbatchreader.py index 40bf518..0cffdd2 100644 --- a/nmreval/gui_qt/io/fcbatchreader.py +++ b/src/gui_qt/io/fcbatchreader.py @@ -1,6 +1,7 @@ import pathlib -from ...io.fcbatchreader import FCReader +from nmreval.io.fcbatchreader import FCReader + from ..lib.utils import busy_cursor from ..Qt import QtCore, QtWidgets, QtGui from .._py.fcreader import Ui_FCEval_dialog @@ -86,8 +87,7 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog): try: fc_eval.load_magnetization(region=region, overwrite=self.overwrite_cb.isChecked()) except OSError as e: - QtWidgets.QMessageBox.warning(self, 'Mssing data', e.strerror) - self.statelabel.setText('') + QtWidgets.QMessageBox.warning(self, 'Missing data', e.strerror) return fc_eval.fit(kww=self.kww_checkbox.isChecked(), save_fits=True, save_fig=True) diff --git a/nmreval/gui_qt/io/filedialog.py b/src/gui_qt/io/filedialog.py similarity index 100% rename from nmreval/gui_qt/io/filedialog.py rename to src/gui_qt/io/filedialog.py diff --git a/nmreval/gui_qt/io/filereaders.py b/src/gui_qt/io/filereaders.py similarity index 95% rename from nmreval/gui_qt/io/filereaders.py rename to src/gui_qt/io/filereaders.py index b2c3db5..54cacb1 100755 --- a/nmreval/gui_qt/io/filereaders.py +++ b/src/gui_qt/io/filereaders.py @@ -1,9 +1,9 @@ +from __future__ import annotations + from pathlib import Path import struct -from typing import List, Union from ..Qt import QtCore - from .asciireader import QAsciiReader from .hdfreader import QHdfViewer from .bdsreader import QBDSReader @@ -31,7 +31,7 @@ class QFileReader(QtCore.QObject): ]: self.register(ext, reader) - def __call__(self, files: Union[List[str], str]) -> List: + def __call__(self, files: list[str] | str) -> list: self.data = [] if isinstance(files, str): self.filenames = [files] @@ -40,7 +40,7 @@ class QFileReader(QtCore.QObject): return self.readfiles(files) - def readfiles(self, fname: Union[List[str], str]) -> List: + def readfiles(self, fname: list[str] | str) -> list: if not isinstance(fname, list): fname = [fname] diff --git a/nmreval/gui_qt/io/gracereader.py b/src/gui_qt/io/gracereader.py similarity index 95% rename from nmreval/gui_qt/io/gracereader.py rename to src/gui_qt/io/gracereader.py index 57435f2..9196e61 100644 --- a/nmreval/gui_qt/io/gracereader.py +++ b/src/gui_qt/io/gracereader.py @@ -1,7 +1,7 @@ -from ...lib.lines import LineStyle -from ...lib.symbols import SymbolStyle -from ...data.points import Points -from ...io.graceeditor import GraceEditor +from nmreval.lib.lines import LineStyle +from nmreval.lib.symbols import SymbolStyle +from nmreval.data.points import Points +from nmreval.io.graceeditor import GraceEditor from ..Qt import QtCore, QtWidgets, QtGui from .._py.gracereader import Ui_Dialog diff --git a/nmreval/gui_qt/io/hdfreader.py b/src/gui_qt/io/hdfreader.py similarity index 99% rename from nmreval/gui_qt/io/hdfreader.py rename to src/gui_qt/io/hdfreader.py index d272413..c59ad01 100644 --- a/nmreval/gui_qt/io/hdfreader.py +++ b/src/gui_qt/io/hdfreader.py @@ -1,4 +1,4 @@ -from ...io.hdfreader import HdfReader +from nmreval.io.hdfreader import HdfReader from ..Qt import QtGui, QtCore, QtWidgets from .._py.hdftree import Ui_Hdf_Dialog diff --git a/nmreval/gui_qt/io/nmrreader.py b/src/gui_qt/io/nmrreader.py similarity index 95% rename from nmreval/gui_qt/io/nmrreader.py rename to src/gui_qt/io/nmrreader.py index 6e2a374..95614f3 100644 --- a/nmreval/gui_qt/io/nmrreader.py +++ b/src/gui_qt/io/nmrreader.py @@ -1,6 +1,6 @@ from struct import unpack -from ...io.nmrreader import NMRReader +from nmreval.io.nmrreader import NMRReader from ..Qt import QtCore diff --git a/nmreval/gui_qt/io/save_fitparameter.py b/src/gui_qt/io/save_fitparameter.py similarity index 100% rename from nmreval/gui_qt/io/save_fitparameter.py rename to src/gui_qt/io/save_fitparameter.py diff --git a/nmreval/gui_qt/io/tntreader.py b/src/gui_qt/io/tntreader.py similarity index 98% rename from nmreval/gui_qt/io/tntreader.py rename to src/gui_qt/io/tntreader.py index cd97c76..f094518 100644 --- a/nmreval/gui_qt/io/tntreader.py +++ b/src/gui_qt/io/tntreader.py @@ -1,4 +1,4 @@ -from ...io.tntreader import TNTReader +from nmreval.io.tntreader import TNTReader from ..Qt import QtCore, QtWidgets from .._py.tntdialog import Ui_tntdialog diff --git a/nmreval/gui_qt/lib/__init__.py b/src/gui_qt/lib/__init__.py similarity index 100% rename from nmreval/gui_qt/lib/__init__.py rename to src/gui_qt/lib/__init__.py diff --git a/nmreval/gui_qt/lib/codeeditor.py b/src/gui_qt/lib/codeeditor.py similarity index 100% rename from nmreval/gui_qt/lib/codeeditor.py rename to src/gui_qt/lib/codeeditor.py diff --git a/nmreval/gui_qt/lib/color_dialog.py b/src/gui_qt/lib/color_dialog.py similarity index 96% rename from nmreval/gui_qt/lib/color_dialog.py rename to src/gui_qt/lib/color_dialog.py index f9a5601..538938a 100644 --- a/nmreval/gui_qt/lib/color_dialog.py +++ b/src/gui_qt/lib/color_dialog.py @@ -1,7 +1,8 @@ -from ...configs import config_paths +from nmreval.configs import config_paths +from nmreval.lib.colors import Colors, available_cycles + from ..Qt import QtWidgets, QtCore, QtGui from .._py.color_palette import Ui_Dialog -from ...lib.colors import Colors, available_cycles class ColorDialog(QtWidgets.QDialog, Ui_Dialog): diff --git a/nmreval/gui_qt/lib/configurations.py b/src/gui_qt/lib/configurations.py similarity index 98% rename from nmreval/gui_qt/lib/configurations.py rename to src/gui_qt/lib/configurations.py index 0bc114f..c92f065 100644 --- a/nmreval/gui_qt/lib/configurations.py +++ b/src/gui_qt/lib/configurations.py @@ -1,7 +1,7 @@ import os -from ...configs import * -from ...io.graceeditor import GraceEditor +from nmreval.configs import * +from nmreval.io.graceeditor import GraceEditor from ..Qt import QtWidgets, QtGui from .._py.agroptiondialog import Ui_Dialog diff --git a/nmreval/gui_qt/lib/decorators.py b/src/gui_qt/lib/decorators.py similarity index 100% rename from nmreval/gui_qt/lib/decorators.py rename to src/gui_qt/lib/decorators.py diff --git a/nmreval/gui_qt/lib/delegates.py b/src/gui_qt/lib/delegates.py similarity index 98% rename from nmreval/gui_qt/lib/delegates.py rename to src/gui_qt/lib/delegates.py index d26c1f0..bbad0b7 100644 --- a/nmreval/gui_qt/lib/delegates.py +++ b/src/gui_qt/lib/delegates.py @@ -1,10 +1,10 @@ import re -from ..Qt import QtWidgets, QtGui, QtCore +from nmreval.lib.colors import BaseColor, Colors +from nmreval.lib.lines import LineStyle +from nmreval.lib.symbols import SymbolStyle, make_symbol_pixmap -from ...lib.colors import BaseColor, Colors -from ...lib.lines import LineStyle -from ...lib.symbols import SymbolStyle, make_symbol_pixmap +from ..Qt import QtWidgets, QtGui, QtCore class PropertyDelegate(QtWidgets.QStyledItemDelegate): diff --git a/nmreval/gui_qt/lib/expandablewidget.py b/src/gui_qt/lib/expandablewidget.py similarity index 100% rename from nmreval/gui_qt/lib/expandablewidget.py rename to src/gui_qt/lib/expandablewidget.py diff --git a/nmreval/gui_qt/lib/forms.py b/src/gui_qt/lib/forms.py similarity index 99% rename from nmreval/gui_qt/lib/forms.py rename to src/gui_qt/lib/forms.py index f42bc00..6a51c3a 100644 --- a/nmreval/gui_qt/lib/forms.py +++ b/src/gui_qt/lib/forms.py @@ -1,6 +1,6 @@ from numpy import inf -from ...utils.text import convert +from nmreval.utils.text import convert from ..Qt import QtGui, QtCore, QtWidgets from .._py.mean_form import Ui_mean_form diff --git a/nmreval/gui_qt/lib/gol.py b/src/gui_qt/lib/gol.py similarity index 100% rename from nmreval/gui_qt/lib/gol.py rename to src/gui_qt/lib/gol.py diff --git a/nmreval/gui_qt/lib/namespace.py b/src/gui_qt/lib/namespace.py similarity index 97% rename from nmreval/gui_qt/lib/namespace.py rename to src/gui_qt/lib/namespace.py index 0083683..a5eb34f 100644 --- a/nmreval/gui_qt/lib/namespace.py +++ b/src/gui_qt/lib/namespace.py @@ -4,11 +4,12 @@ from collections import namedtuple import numpy as np -from ... import models -from ...configs import config_paths -from ...lib.importer import find_models, import_ -from ...utils import constants as constants -from ...utils.text import convert +from nmreval import models +from nmreval.configs import config_paths +from nmreval.lib.importer import find_models, import_ +from nmreval.utils import constants as constants +from nmreval.utils.text import convert + from ..Qt import QtWidgets, QtCore from .._py.namespace_widget import Ui_Form diff --git a/nmreval/gui_qt/lib/pg_objects.py b/src/gui_qt/lib/pg_objects.py similarity index 98% rename from nmreval/gui_qt/lib/pg_objects.py rename to src/gui_qt/lib/pg_objects.py index d412a06..3a287e6 100644 --- a/nmreval/gui_qt/lib/pg_objects.py +++ b/src/gui_qt/lib/pg_objects.py @@ -8,9 +8,9 @@ from pyqtgraph import ( LegendItem, ) -from ...lib.colors import BaseColor, Colors, TUColors -from ...lib.lines import LineStyle -from ...lib.symbols import SymbolStyle +from nmreval.lib.colors import BaseColor, Colors +from nmreval.lib.lines import LineStyle +from nmreval.lib.symbols import SymbolStyle from ..Qt import QtCore, QtGui @@ -274,6 +274,7 @@ class PlotItem(PlotDataItem): self.scatter.hide() def set_symbol(self, symbol=None, size=None, color=None): + print(symbol, type(symbol), isinstance(symbol, SymbolStyle)) if symbol is not None: if isinstance(symbol, int): self.setSymbol(SymbolStyle(symbol).to_str()) diff --git a/nmreval/gui_qt/lib/randpok.py b/src/gui_qt/lib/randpok.py similarity index 100% rename from nmreval/gui_qt/lib/randpok.py rename to src/gui_qt/lib/randpok.py diff --git a/nmreval/gui_qt/lib/spinboxes.py b/src/gui_qt/lib/spinboxes.py similarity index 100% rename from nmreval/gui_qt/lib/spinboxes.py rename to src/gui_qt/lib/spinboxes.py diff --git a/nmreval/gui_qt/lib/stuff.py b/src/gui_qt/lib/stuff.py similarity index 100% rename from nmreval/gui_qt/lib/stuff.py rename to src/gui_qt/lib/stuff.py diff --git a/nmreval/gui_qt/lib/styles.py b/src/gui_qt/lib/styles.py similarity index 100% rename from nmreval/gui_qt/lib/styles.py rename to src/gui_qt/lib/styles.py diff --git a/nmreval/gui_qt/lib/tables.py b/src/gui_qt/lib/tables.py similarity index 100% rename from nmreval/gui_qt/lib/tables.py rename to src/gui_qt/lib/tables.py diff --git a/nmreval/gui_qt/lib/undos.py b/src/gui_qt/lib/undos.py similarity index 100% rename from nmreval/gui_qt/lib/undos.py rename to src/gui_qt/lib/undos.py diff --git a/nmreval/gui_qt/lib/usermodeleditor.py b/src/gui_qt/lib/usermodeleditor.py similarity index 100% rename from nmreval/gui_qt/lib/usermodeleditor.py rename to src/gui_qt/lib/usermodeleditor.py diff --git a/nmreval/gui_qt/lib/utils.py b/src/gui_qt/lib/utils.py similarity index 100% rename from nmreval/gui_qt/lib/utils.py rename to src/gui_qt/lib/utils.py diff --git a/nmreval/gui_qt/main/__init__.py b/src/gui_qt/main/__init__.py similarity index 100% rename from nmreval/gui_qt/main/__init__.py rename to src/gui_qt/main/__init__.py diff --git a/nmreval/gui_qt/main/mainwindow.py b/src/gui_qt/main/mainwindow.py similarity index 99% rename from nmreval/gui_qt/main/mainwindow.py rename to src/gui_qt/main/mainwindow.py index c0090b3..5dd24f6 100644 --- a/nmreval/gui_qt/main/mainwindow.py +++ b/src/gui_qt/main/mainwindow.py @@ -1,11 +1,14 @@ +from __future__ import annotations + import pathlib import re from pathlib import Path -from typing import List, Tuple from numpy import geomspace, linspace from pyqtgraph import ViewBox, PlotDataItem +from nmreval.configs import * + from .management import UpperManagement from ..Qt import QtCore, QtGui, QtPrintSupport, QtWidgets from ..data.shift_graphs import QShift @@ -24,7 +27,6 @@ from ..math.smooth import QSmooth from ..nmr.coupling_calc import QCoupCalcDialog from ..nmr.t1_from_tau import QRelaxCalc from .._py.basewindow import Ui_BaseWindow -from ...configs import * class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): @@ -268,7 +270,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): @QtCore.pyqtSlot() @QtCore.pyqtSlot(list) - def save_fit_parameter(self, fit_sets: List[str] = None): + def save_fit_parameter(self, fit_sets: list[str] = None): fname, _ = QtWidgets.QFileDialog.getSaveFileName(self, 'Save fit parameter', directory=str(self.path), filter='All files(*, *);;Text files(*.dat *.txt)') @@ -472,7 +474,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): self._set_pick_block(pick_required, block_window) - def _select_ptswidget(self, onoff: bool, pick_required: bool, block_window: bool) -> Tuple[bool, bool]: + def _select_ptswidget(self, onoff: bool, pick_required: bool, block_window: bool) -> tuple[bool, bool]: if self.current_graph_widget is None: return pick_required, block_window diff --git a/nmreval/gui_qt/main/management.py b/src/gui_qt/main/management.py similarity index 98% rename from nmreval/gui_qt/main/management.py rename to src/gui_qt/main/management.py index fc0f9a5..bfbde4d 100644 --- a/nmreval/gui_qt/main/management.py +++ b/src/gui_qt/main/management.py @@ -5,15 +5,15 @@ import re import uuid from typing import List -from ...fit import data as fit_d -from ...fit.model import Model -from ...fit.result import FitResult -from ...fit.minimizer import FitRoutine -from ...lib.colors import TUColorsC, available_cycles -from ...math.interpol import interpolate -from ...math.logfourier import logft -from ...math.smooth import smooth -from ...nmr.relaxation import Relaxation +from nmreval.fit import data as fit_d +from nmreval.fit.model import Model +from nmreval.fit.result import FitResult +from nmreval.fit.minimizer import FitRoutine +from nmreval.lib.colors import TUColorsC, available_cycles +from nmreval.math.interpol import interpolate +from nmreval.math.logfourier import logft +from nmreval.math.smooth import smooth +from nmreval.nmr.relaxation import Relaxation from ..lib.undos import * from ..data.container import * diff --git a/nmreval/io/__init__.py b/src/gui_qt/math/__init__.py similarity index 100% rename from nmreval/io/__init__.py rename to src/gui_qt/math/__init__.py diff --git a/nmreval/gui_qt/math/bootstrap.py b/src/gui_qt/math/bootstrap.py similarity index 100% rename from nmreval/gui_qt/math/bootstrap.py rename to src/gui_qt/math/bootstrap.py diff --git a/nmreval/gui_qt/math/evaluation.py b/src/gui_qt/math/evaluation.py similarity index 98% rename from nmreval/gui_qt/math/evaluation.py rename to src/gui_qt/math/evaluation.py index 112b5fb..617e5f9 100644 --- a/nmreval/gui_qt/math/evaluation.py +++ b/src/gui_qt/math/evaluation.py @@ -1,6 +1,5 @@ from ..Qt import QtCore, QtWidgets, QtGui from .._py.eval_expr_dialog import Ui_CalcDialog -from ..lib.namespace import Namespace class QEvalDialog(QtWidgets.QDialog, Ui_CalcDialog): diff --git a/nmreval/gui_qt/math/integrate_derive.py b/src/gui_qt/math/integrate_derive.py similarity index 100% rename from nmreval/gui_qt/math/integrate_derive.py rename to src/gui_qt/math/integrate_derive.py diff --git a/nmreval/gui_qt/math/interpol.py b/src/gui_qt/math/interpol.py similarity index 100% rename from nmreval/gui_qt/math/interpol.py rename to src/gui_qt/math/interpol.py diff --git a/nmreval/gui_qt/math/mean_dialog.py b/src/gui_qt/math/mean_dialog.py similarity index 97% rename from nmreval/gui_qt/math/mean_dialog.py rename to src/gui_qt/math/mean_dialog.py index 18b60fd..4fd0d87 100644 --- a/nmreval/gui_qt/math/mean_dialog.py +++ b/src/gui_qt/math/mean_dialog.py @@ -1,4 +1,5 @@ -from ...distributions import ColeDavidson, HavriliakNegami, KWW, LogGaussian +from nmreval.distributions import ColeDavidson, HavriliakNegami, KWW, LogGaussian + from ..Qt import QtWidgets, QtCore from .._py.meandialog import Ui_calc_means_dialog from ..lib.forms import Widget diff --git a/nmreval/gui_qt/math/skipping.py b/src/gui_qt/math/skipping.py similarity index 100% rename from nmreval/gui_qt/math/skipping.py rename to src/gui_qt/math/skipping.py diff --git a/nmreval/gui_qt/math/smooth.py b/src/gui_qt/math/smooth.py similarity index 100% rename from nmreval/gui_qt/math/smooth.py rename to src/gui_qt/math/smooth.py diff --git a/nmreval/lib/__init__.py b/src/gui_qt/nmr/__init__.py similarity index 100% rename from nmreval/lib/__init__.py rename to src/gui_qt/nmr/__init__.py diff --git a/nmreval/gui_qt/nmr/coupling_calc.py b/src/gui_qt/nmr/coupling_calc.py similarity index 96% rename from nmreval/gui_qt/nmr/coupling_calc.py rename to src/gui_qt/nmr/coupling_calc.py index ecd0632..30f146a 100644 --- a/nmreval/gui_qt/nmr/coupling_calc.py +++ b/src/gui_qt/nmr/coupling_calc.py @@ -1,5 +1,5 @@ -from ...nmr.coupling import * -from ...utils.text import convert +from nmreval.nmr.coupling import * +from nmreval.utils.text import convert from ..Qt import QtWidgets, QtCore from .._py.coupling_calculator import Ui_coupling_calc_dialog diff --git a/nmreval/gui_qt/nmr/t1_from_tau.py b/src/gui_qt/nmr/t1_from_tau.py similarity index 96% rename from nmreval/gui_qt/nmr/t1_from_tau.py rename to src/gui_qt/nmr/t1_from_tau.py index f7f3557..5e16eba 100644 --- a/nmreval/gui_qt/nmr/t1_from_tau.py +++ b/src/gui_qt/nmr/t1_from_tau.py @@ -1,9 +1,9 @@ -from typing import List, Tuple +from __future__ import annotations -from ...nmr.coupling import * -from ...distributions import ColeCole, ColeDavidson, HavriliakNegami, KWW, LogGaussian -from ...utils import pi -from ...utils.text import convert +from nmreval.nmr.coupling import * +from nmreval.distributions import ColeCole, ColeDavidson, HavriliakNegami, KWW, LogGaussian +from nmreval.utils import pi +from nmreval.utils.text import convert from ..Qt import QtGui, QtCore, QtWidgets from ..lib.forms import SelectionWidget, Widget @@ -59,7 +59,7 @@ class QRelaxCalc(QtWidgets.QDialog, Ui_Dialog): self.update_coupling_model(self.coupling_combobox.currentIndex()) self.tau_graph_changed(self.tau_graph_combobox.currentIndex()) - def update_graphs(self, graphs: List[Tuple[str, str]]): + def update_graphs(self, graphs: list[tuple[str, str]]): current_id = self.graph_combobox.currentData() self.graph_combobox.clear() for (gid, name) in graphs: diff --git a/nmreval/gui_qt/nmr/t1widget.py b/src/gui_qt/nmr/t1widget.py similarity index 98% rename from nmreval/gui_qt/nmr/t1widget.py rename to src/gui_qt/nmr/t1widget.py index f615080..2521224 100644 --- a/nmreval/gui_qt/nmr/t1widget.py +++ b/src/gui_qt/nmr/t1widget.py @@ -1,12 +1,12 @@ import numpy as np from pyqtgraph import mkBrush, mkPen -from ..lib.pg_objects import PlotItem -from ...data.points import Points -from ...nmr.relaxation import RelaxationEvaluation -from ...nmr.coupling import * -from ...distributions import * +from nmreval.data.points import Points +from nmreval.nmr.relaxation import RelaxationEvaluation +from nmreval.nmr.coupling import * +from nmreval.distributions import * +from ..lib.pg_objects import PlotItem from ..Qt import QtCore, QtWidgets, QtGui from .._py.t1dialog import Ui_t1dialog from ..lib.forms import FormWidget, SelectionWidget diff --git a/nmreval/__init__.py b/src/nmreval/__init__.py similarity index 100% rename from nmreval/__init__.py rename to src/nmreval/__init__.py diff --git a/nmreval/bds/__init__.py b/src/nmreval/bds/__init__.py similarity index 100% rename from nmreval/bds/__init__.py rename to src/nmreval/bds/__init__.py diff --git a/nmreval/configs.py b/src/nmreval/configs.py similarity index 100% rename from nmreval/configs.py rename to src/nmreval/configs.py diff --git a/nmreval/data/__init__.py b/src/nmreval/data/__init__.py similarity index 100% rename from nmreval/data/__init__.py rename to src/nmreval/data/__init__.py diff --git a/nmreval/data/bds.py b/src/nmreval/data/bds.py similarity index 100% rename from nmreval/data/bds.py rename to src/nmreval/data/bds.py diff --git a/nmreval/data/dsc.py b/src/nmreval/data/dsc.py similarity index 100% rename from nmreval/data/dsc.py rename to src/nmreval/data/dsc.py diff --git a/nmreval/data/nmr.py b/src/nmreval/data/nmr.py similarity index 99% rename from nmreval/data/nmr.py rename to src/nmreval/data/nmr.py index 23d501a..8f5229a 100644 --- a/nmreval/data/nmr.py +++ b/src/nmreval/data/nmr.py @@ -1,5 +1,4 @@ import warnings -from typing import Union import numpy as np diff --git a/nmreval/data/points.py b/src/nmreval/data/points.py similarity index 94% rename from nmreval/data/points.py rename to src/nmreval/data/points.py index a9c4fc3..926b9c4 100644 --- a/nmreval/data/points.py +++ b/src/nmreval/data/points.py @@ -1,7 +1,9 @@ +from __future__ import annotations + import copy from numbers import Number, Real from pathlib import Path -from typing import Any, List, Optional, Tuple, TypeVar, Union +from typing import Any, TypeVar import numpy as np try: @@ -25,7 +27,7 @@ class Points: y_err (array_like, optional): errors """ - def __init__(self, x: ArrayLike, y: ArrayLike, y_err: Optional[ArrayLike] = None, **kwargs: Any): + def __init__(self, x: ArrayLike, y: ArrayLike, y_err: ArrayLike = None, **kwargs: Any): self._x, self._y, self._y_err, self.mask = self._prepare_xy(x, y, y_err=y_err) @@ -57,7 +59,7 @@ class Points: self.name = str(value) @staticmethod - def _prepare_xy(x: ArrayLike, y: ArrayLike, y_err: Optional[ArrayLike] = None): + def _prepare_xy(x: ArrayLike, y: ArrayLike, y_err: ArrayLike = None): x = np.atleast_1d(x).astype(float) if x.ndim > 1: raise TypeError('x axis cannot be multidimensional') @@ -270,9 +272,9 @@ class Points: def length(self): return len(self._x) - def points(self, idx: Optional[list] = None, special: Optional[str] = None, - avg_range: Tuple[int, int] = (0, 0), avg_mode: str = 'mean', - pts: Optional[list] = None) -> List[tuple]: + def points(self, idx: list = None, special: str = None, + avg_range: tuple[int, int] = (0, 0), avg_mode: str = 'mean', + pts: list = None) -> list[tuple]: """ Return (x, y) values at specified positions. @@ -351,7 +353,7 @@ class Points: return pts - def _average(self, mode: str, idx, left: int, right: int) -> Tuple[float, float]: + def _average(self, mode: str, idx, left: int, right: int) -> tuple[float, float]: if mode == 'mean': y_mean = np.mean(self._y[self.mask][left:right].real) y_err = np.linalg.norm(self._y_err[self.mask][left:right]) / (right - left) @@ -388,7 +390,7 @@ class Points: return self - def integrate(self, log: bool = False, limits: Tuple[float, float] = None) -> PointLike: + def integrate(self, log: bool = False, limits: tuple[float, float] = None) -> PointLike: new_data = self.copy() if limits is not None: @@ -401,7 +403,7 @@ class Points: return new_data - def diff(self, log: bool = False, limits: Optional[Tuple[float, float]] = None) -> PointLike: + def diff(self, log: bool = False, limits: tuple[float, float] = None) -> PointLike: """ Calculate first derivate :math:`dy/dx` or :math:`dy/d(\ln x)`. @@ -447,7 +449,7 @@ class Points: """ return copy.deepcopy(self) - def get_values(self, idx: int) -> Tuple[np.ndarray, np.ndarray, np.ndarray]: + def get_values(self, idx: int) -> tuple[np.ndarray, np.ndarray, np.ndarray]: """ Return values at a given index @@ -459,7 +461,7 @@ class Points: """ return self._x[idx], self._y[idx], self._y_err[idx] - def set_values(self, idx: int, value: Union[list, tuple, np.ndarray]) -> PointLike: + def set_values(self, idx: int, value: list | tuple | np.ndarray) -> PointLike: if not (isinstance(value, (list, tuple, np.ndarray)) and (len(value) in [2, 3])): raise TypeError('Values should be list type of length 2 or 3') @@ -473,10 +475,7 @@ class Points: return self - def set_data(self, - x: Optional[np.ndarray] = None, - y: Optional[np.ndarray] = None, - y_err: Optional[np.ndarray] = None) -> PointLike: + def set_data(self, x: np.ndarray = None, y: np.ndarray = None, y_err: np.ndarray = None) -> PointLike: if x is None: x = self._x if y is None: @@ -488,7 +487,7 @@ class Points: return self - def append(self, x: ArrayLike, y: ArrayLike, y_err: Optional[ArrayLike] = None): + def append(self, x: ArrayLike, y: ArrayLike, y_err: ArrayLike = None): x, y, y_err, mask = self._prepare_xy(x, y, y_err) self._x = np.r_[self._x, x] diff --git a/nmreval/data/signals.py b/src/nmreval/data/signals.py similarity index 96% rename from nmreval/data/signals.py rename to src/nmreval/data/signals.py index c4cf9b1..5a408cb 100644 --- a/nmreval/data/signals.py +++ b/src/nmreval/data/signals.py @@ -1,6 +1,5 @@ import numpy as np - from .points import Points @@ -48,10 +47,10 @@ class Signal(Points): return self def manual_phase(self, ph0: float = 0., ph1: float = 0., pvt: float = 0): - self._y *= np.exp(1j * ph0 * np.pi / 180.) + self._y *= np.exp(-1j * ph0 * np.pi / 180.) if ph1 != 0: x = (self._x - pvt) / max(self._x) - self._y *= np.exp(1j * x * ph1 * np.pi / 180.) + self._y *= np.exp(-1j * x * ph1 * np.pi / 180.) self.meta['phase'].append((ph0, ph1, pvt)) return self diff --git a/nmreval/distributions/__init__.py b/src/nmreval/distributions/__init__.py similarity index 93% rename from nmreval/distributions/__init__.py rename to src/nmreval/distributions/__init__.py index 741b106..3489da6 100644 --- a/nmreval/distributions/__init__.py +++ b/src/nmreval/distributions/__init__.py @@ -9,7 +9,6 @@ types of correlation times. .. autosummary:: :toctree: generated/ - :template: autosummary/class_with_attributes.rst :nosignatures: Debye diff --git a/nmreval/distributions/base.py b/src/nmreval/distributions/base.py similarity index 95% rename from nmreval/distributions/base.py rename to src/nmreval/distributions/base.py index fb6eda8..ae9b72e 100644 --- a/nmreval/distributions/base.py +++ b/src/nmreval/distributions/base.py @@ -1,5 +1,7 @@ +from __future__ import annotations + import abc -from typing import Any, Union +from typing import Any import numpy as np @@ -31,7 +33,7 @@ class Distribution(abc.ABC): pass @classmethod - def specdens(cls, omega: ArrayLike, tau: ArrayLike, *args: Any) -> Union[np.ndarray, float]: + def specdens(cls, omega: ArrayLike, tau: ArrayLike, *args: Any) -> np.ndarray | float: return cls.susceptibility(omega, tau, *args).imag / omega @classmethod diff --git a/nmreval/distributions/colecole.py b/src/nmreval/distributions/colecole.py similarity index 59% rename from nmreval/distributions/colecole.py rename to src/nmreval/distributions/colecole.py index cc10f8d..b8551a8 100644 --- a/nmreval/distributions/colecole.py +++ b/src/nmreval/distributions/colecole.py @@ -1,7 +1,8 @@ +from __future__ import annotations + import numpy as np from .base import Distribution -from ..lib.utils import ArrayLike from ..lib.decorator import adjust_dims from ..math.mittagleffler import mlf @@ -19,29 +20,23 @@ class ColeCole(Distribution): """ Distribution of correlation times - .. math:: - G(\ln\\tau) = \\frac{1}{2\pi} \\frac{\\sin(\\pi\\alpha)}{\cosh[\\alpha\ln(\\tau/\\tau_0)] + \cos(\\alpha \pi))} - Args: - tau: - tau0: - alpha: + tau (array_like): + tau0 (array_like): + alpha (float): """ z = np.log(tau/tau0) return np.sin(np.pi*alpha)/(np.cosh(z*alpha) + np.cos(alpha*np.pi))/(2*np.pi) @staticmethod @adjust_dims - def susceptibility(omega: ArrayLike, tau: ArrayLike, alpha: float) -> ArrayLike: + def susceptibility(omega, tau, alpha: float): r""" Complex susceptibility - .. math:: - \chi(\omega, \tau, \alpha) = \frac{1}{[1-(i\omega\tau)^\alpha]} - Args: - omega (array-like): Frequency axis in 1/s (not Hz). - tau (array-like): Correlation times :math:`\tau_\text{CC}` in s. + omega (array_like): Frequency axis in 1/s (not Hz). + tau (array_like): Correlation times :math:`\tau_\text{CC}` in s. alpha (float): Shape parameter. """ @@ -54,13 +49,10 @@ class ColeCole(Distribution): """ Spectral density - .. math:: - J(\omega, \\tau, \\alpha) = \\frac{\sin(\\alpha\pi/2)(\omega\\tau)^\\alpha}{\omega[1+(\omega\\tau)^{2\\alpha} + 2\\pi\cos(\\alpha\pi/2)(\omega\\tau)^\\alpha]} - Args: - omega: - tau: - alpha: + omega (array_like): + tau (array_like): + alpha (float): """ omtau = (omega*tau)**alpha return np.sin(alpha*np.pi/2) * omtau / (1 + omtau**2 + 2*np.cos(alpha*np.pi/2)*omtau) / omega @@ -71,14 +63,11 @@ class ColeCole(Distribution): """ Correlation function :math:`C(t)` - .. math:: - C(t) = E_\\alpha[-(t/\\tau_0)^\\alpha] - with Mittag-Leffler function :math:`E_a(x)` Args: - t: - tau0: - alpha: + t (array_like): + tau0 (array_like): + alpha (float): """ return mlf(-(t/tau0)**alpha, alpha) diff --git a/nmreval/distributions/coledavidson.py b/src/nmreval/distributions/coledavidson.py similarity index 93% rename from nmreval/distributions/coledavidson.py rename to src/nmreval/distributions/coledavidson.py index f19bf57..576bca5 100644 --- a/nmreval/distributions/coledavidson.py +++ b/src/nmreval/distributions/coledavidson.py @@ -1,11 +1,10 @@ -import numbers +from __future__ import annotations import numpy as np from scipy.special import psi, gammaincc from .base import Distribution from ..lib.decorator import adjust_dims -from ..lib.utils import ArrayLike from ..utils.constants import Eu @@ -44,7 +43,7 @@ class ColeDavidson(Distribution): @staticmethod @adjust_dims - def susceptibility(omega: ArrayLike, tau: ArrayLike, gamma: float) -> ArrayLike: + def susceptibility(omega: float | np.ndarray, tau: float | np.ndarray, gamma: float) -> float | np.ndarray: r""" Complex susceptibility @@ -52,8 +51,8 @@ class ColeDavidson(Distribution): \chi(\omega, \tau, \alpha, \gamma) = \frac{1}{[1-i\omega\tau]^\gamma} Args: - omega (array-like): Frequency axis in 1/s (not Hz). - tau (array-like): Correlation times in s. + omega (array_like): Frequency axis in 1/s (not Hz). + tau (array_like): Correlation times in s. gamma (float): Shape parameter. """ diff --git a/nmreval/distributions/debye.py b/src/nmreval/distributions/debye.py similarity index 89% rename from nmreval/distributions/debye.py rename to src/nmreval/distributions/debye.py index d342648..2fae2de 100644 --- a/nmreval/distributions/debye.py +++ b/src/nmreval/distributions/debye.py @@ -34,8 +34,8 @@ class Debye(Distribution): \chi(\omega, \tau) = \frac{1}{1-i\omega\tau} Args: - omega (array-like): Frequency axis in 1/s (not Hz). - tau (array-like): Correlation times in s. + omega (array_like): Frequency axis in 1/s (not Hz). + tau (array_like): Correlation times in s. """ return 1/(1 - 1j*omega*tau) diff --git a/nmreval/distributions/energy.py b/src/nmreval/distributions/energy.py similarity index 66% rename from nmreval/distributions/energy.py rename to src/nmreval/distributions/energy.py index 33653cc..a97a462 100644 --- a/nmreval/distributions/energy.py +++ b/src/nmreval/distributions/energy.py @@ -1,9 +1,10 @@ from itertools import product import numpy as np -from scipy.integrate import simps as simpson +from scipy.integrate import quad, simps as simpson from .base import Distribution +from ..lib.utils import ArrayLike from ..utils.constants import kB @@ -44,17 +45,8 @@ class EnergyBarriers(Distribution): return ret_val @staticmethod - def susceptibility(omega, temperature, *args): + def susceptibility(omega: ArrayLike, temperature: ArrayLike, tau0: float, e_m: float, e_b: float) -> ArrayLike: # in contrast to other spectral densities, it's omega and temperature - tau0, e_m, e_b = args - - def integrand_real(e_a, w, t0, mu, sigma, t): - r = EnergyBarriers.rate(t0, e_a, t) - return 1/(r**2 + w**2) * EnergyBarriers.energydistribution(e_a, mu, sigma) - - def integrand_imag(e_a, w, t0, mu, sigma, t): - r = EnergyBarriers.rate(t0, e_a, t) - return w*r/(r**2 + w**2) * EnergyBarriers.energydistribution(e_a, mu, sigma) omega = np.atleast_1d(omega) temperature = np.atleast_1d(temperature) @@ -62,8 +54,8 @@ class EnergyBarriers(Distribution): e_axis = np.linspace(max(0, e_m-50*e_b), e_m+50*e_b, num=5001) ret_val = [] for o, tt in product(omega, temperature): - ret_val.append(simpson(integrand_real(e_axis, o, tau0, e_m, e_b, tt), e_axis) - - 1j * simpson(integrand_imag(e_axis, o, tau0, e_m, e_b, tt), e_axis)) + ret_val.append(simpson(_integrand_freq_real(e_axis, o, tau0, e_m, e_b, tt), e_axis) - + 1j * simpson(_integrand_freq_imag(e_axis, o, tau0, e_m, e_b, tt), e_axis)) return np.array(ret_val) @@ -97,3 +89,32 @@ class EnergyBarriers(Distribution): @staticmethod def max(*args): return args[1] * np.exp(args[2] / (kB * args[0])) + + +def _integrate_process_imag(args): + pass + + +def _integrate_process_real(args): + omega_i, t, tau0, mu, sigma, temp_j = args + return quad(_integrand_freq_real(), 0, 10, args=(omega_i, t, tau0, mu, sigma, temp_j))[0] + + +def _integrate_process_time(args): + omega_i, t, tau0, mu, sigma, temp_j = args + return quad(_integrand_time, 0, 10, args=(omega_i, t, tau0, mu, sigma, temp_j))[0] + + +def _integrand_freq_real(u, omega, tau0, mu, sigma, temp): + r = EnergyBarriers.rate(tau0, u, temp) + return 1 / (r**2 + omega**2) * EnergyBarriers.energydistribution(u, mu, sigma) + + +def _integrand_freq_imag(u, omega, tau0, mu, sigma, temp): + rate = EnergyBarriers.rate(tau0, u, temp) + return omega * rate / (rate**2 + omega**2) * EnergyBarriers.energydistribution(u, mu, sigma) + + +def _integrand_time(u, t, tau0, mu, sigma, temp): + rate = EnergyBarriers.rate(tau0, u, temp) + return EnergyBarriers.energydistribution(u, mu, sigma) * np.exp(-t*rate) diff --git a/src/nmreval/distributions/gengamma.py b/src/nmreval/distributions/gengamma.py new file mode 100644 index 0000000..47b0479 --- /dev/null +++ b/src/nmreval/distributions/gengamma.py @@ -0,0 +1,178 @@ +from __future__ import annotations + +from abc import ABC + +import numpy as np +try: + from scipy.integrate import simpson +except ImportError: + from scipy.integrate import simps as simpson +from scipy.special import gammaln + +from nmreval.distributions.base import Distribution +from nmreval.math.logfourier import logft + + +class AbstractGG(Distribution, ABC): + """ + Base class for general gamma functions + """ + + @classmethod + def correlation(cls, t, tau0, *args): + tt = np.asanyarray(t) + taus, ln_tau = AbstractGG._prepare_integration(tau0) + g_tau = cls.distribution(taus, tau0, *args) + ret_val = np.array([simpson(np.exp(-t_i/taus) * g_tau, ln_tau) for t_i in tt]) + + return ret_val + + @classmethod + def susceptibility(cls, omega, tau0, *args): + r""" + Calculate spectral density \int G(ln(tau) tau/(1+(w*tau)^2) dln(tau) + """ + w = np.asanyarray(omega) + taus, ln_tau = AbstractGG._prepare_integration(tau0) + g_tau = cls.distribution(taus, tau0, *args) + + ret_val = np.array([simpson(g_tau / (1 - 1j*w_i*taus), ln_tau) for w_i in w]) + + return ret_val + + @classmethod + def specdens(cls, omega, tau0, *args): + r""" + Calculate spectral density \int G(ln(tau) tau/(1+(w*tau)^2) dln(tau) + """ + w = np.asanyarray(omega) + taus, ln_tau = AbstractGG._prepare_integration(tau0) + g_tau = cls.distribution(taus, tau0, *args) + + ret_val = np.array([simpson(g_tau * taus / (1 + (w_i*taus)**2), ln_tau) for w_i in w]) + + return ret_val + + @staticmethod + def _prepare_integration( + tau0: float, limits: tuple[int, int] = (20, 20), num_steps: int = 4001 + ) -> tuple[np.ndarray, np.ndarray]: + """ + Create array of correlation times for integration over ln(tau) + Args: + tau0 (float): center of correlation times + limits (tuple of int): Define limits ln(tau0)-limits[0] and ln(tau0)+limits[1] of array. Default is (20, 20) + num_steps (int): length of array. Default is 4001 + + Returns: + array of taus and array of ln(tau) + + """ + + ln_tau0 = np.log(tau0) + ln_tau = np.linspace(ln_tau0-limits[0], ln_tau0+limits[1], num=num_steps) + + return np.exp(ln_tau), ln_tau + + +# noinspection PyMethodOverriding +class GGAlpha(AbstractGG): + name = r'General \Gamma (\alpha)' + parameter = [r'\tau', r'\alpha', r'\beta'] + + @staticmethod + def distribution(taus: float | np.ndarray, tau: float, alpha: float, beta: float) -> float | np.ndarray: + b_to_a = beta / alpha + norm = np.exp(gammaln(b_to_a) - b_to_a * np.log(b_to_a)) / alpha + t_to_t0 = taus / tau + ret_val = np.exp(-b_to_a * t_to_t0**alpha) * t_to_t0**beta + + return ret_val / norm + + +# noinspection PyMethodOverriding +class GGAlphaEW(AbstractGG): + name = r'General \Gamma (\alpha + EW)' + parameter = [r'\tau', r'\alpha', r'\beta', r'\sigma', r'\gamma'] + + @staticmethod + def distribution(tau: float | np.ndarray, tau0: float, + alpha: float, beta: float, sigma: float, gamma: float) -> float | np.ndarray: + + if gamma == beta or sigma == 0: + return GGAlpha.distribution(tau, tau0, alpha, beta) + + b_to_a = beta / alpha + ln_b_to_a = np.log(b_to_a) + g_to_a = gamma / alpha + t_to_t0 = tau / tau0 + + norm = (np.exp(gammaln(b_to_a)) + sigma**(gamma-beta) * np.exp(gammaln(g_to_a) + (b_to_a-g_to_a)*ln_b_to_a)) / \ + np.exp(b_to_a*ln_b_to_a) / alpha + + ret_val = np.exp(-b_to_a * t_to_t0**alpha) * t_to_t0**beta * (1 + (t_to_t0*sigma)**(gamma-beta)) + + return ret_val / norm + + +# noinspection PyMethodOverriding +class GGBeta(AbstractGG): + name = r'General \Gamma (\beta)' + parameter = [r'\tau', 'a', 'b'] + + @staticmethod + def distribution(tau: float | np.ndarray, tau0: float, a: float, b: float) -> float | np.ndarray: + norm = a * (1+b) * np.sin(np.pi*b/(1+b)) * b**(b/(1+b)) / np.pi + ret_val = b * (tau/tau0)**a + (tau/tau0)**(-a*b) + + return norm / ret_val + + +class GGAlphaEWBeta(Distribution): + name = r'General Gamma (WW (\alpha + EW), \beta)' + parameter = [ + r'\tau_{\alpha}', r'\alpha', r'\beta', r'\sigma', r'\gamma', + r'\tau_{\beta}', 'a', 'b', 'R' + ] + + @staticmethod + def distribution(tau, tau0, *args): + pass + + @staticmethod + def correlation(t, *args): + tau_alpha, alpha, beta, sigma, gamma, tau_beta, a, b, r = args + if r == 0: + return GGAlphaEW.correlation(t, tau_alpha, alpha, beta, sigma, gamma) + elif r == 1: + return GGBeta.correlation(t, tau_beta, a, b) + + gg_alpha = GGAlphaEW.correlation(t, tau_alpha, alpha, beta, sigma, gamma) + gg_beta = GGBeta.correlation(t, tau_beta, a, b) + + return ((1-r)*gg_beta + r) * gg_alpha + + @staticmethod + def susceptibility(omega, *args): + t_axis, corr = GGAlphaEWBeta._correlation_for_ft(omega, *args) + + ft = logft(t_axis, corr, new_x=omega, mode='complex')[1] + + return 1 + omega * ft.imag + 1j * omega * ft.real + + @staticmethod + def specdens(omega, *args): + t_axis, corr = GGAlphaEWBeta._correlation_for_ft(omega, *args) + + return logft(t_axis, corr, new_x=omega, mode='real')[1] + + @staticmethod + def _correlation_for_ft(omega, *args): + # time axis for correlation function + additional_decades = 5 + lower_limit = np.log10(1 / np.max(omega)) - additional_decades + upper_limit = np.log10(1 / np.min(omega)) + additional_decades + num_steps = int(len(omega) * additional_decades) + t_axis = np.logspace(lower_limit, upper_limit, num=num_steps) + + return t_axis, GGAlphaEWBeta.correlation(t_axis, *args) diff --git a/nmreval/distributions/havriliaknegami.py b/src/nmreval/distributions/havriliaknegami.py similarity index 88% rename from nmreval/distributions/havriliaknegami.py rename to src/nmreval/distributions/havriliaknegami.py index e5d5986..9c12960 100644 --- a/nmreval/distributions/havriliaknegami.py +++ b/src/nmreval/distributions/havriliaknegami.py @@ -1,5 +1,3 @@ -from typing import Union - import numpy as np from scipy.special import psi @@ -30,7 +28,7 @@ class HavriliakNegami(Distribution): Args: tau (array_like) : - tau0 (array-like) : + tau0 (array_like) : alpha: gamma: @@ -68,8 +66,8 @@ class HavriliakNegami(Distribution): \text{E}_{a,b}^g (z) = \frac{1}{\Gamma(g)} \sum_{k=0}^\infty \frac{\Gamma(g+k) z^k}{k!\Gamma(ak+b)} Args: - t (array-like): Time axis in s. - tau (array-like): Correlation times :math:`\tau_\text{HN}` in s. + t (array_like): Time axis in s. + tau (array_like): Correlation times :math:`\tau_\text{HN}` in s. alpha (float): Cole-Cole shape parameter. gamma (float): Cole-Davidson shape parameter. @@ -82,7 +80,7 @@ class HavriliakNegami(Distribution): @staticmethod @adjust_dims - def susceptibility(omega: ArrayLike, tau: ArrayLike, alpha: float, gamma: float) -> Union[np.ndarray, complex]: + def susceptibility(omega: ArrayLike, tau: ArrayLike, alpha: float, gamma: float) -> ArrayLike: r""" Complex susceptibility @@ -90,8 +88,8 @@ class HavriliakNegami(Distribution): \chi(\omega, \tau, \alpha, \gamma) = \frac{1}{[1-(i\omega\tau)^\alpha]^\gamma} Args: - omega (array-like): Frequency axis in 1/s (not Hz). - tau (array-like): Correlation times in s. + omega (array_like): Frequency axis in 1/s (not Hz). + tau (array_like): Correlation times in s. alpha (float): Shape parameter. gamma (float): Even more shape parameter. @@ -100,7 +98,7 @@ class HavriliakNegami(Distribution): @staticmethod @adjust_dims - def specdens(omega: ArrayLike, tau: ArrayLike, alpha: float, gamma: float) -> Union[np.ndarray, float]: + def specdens(omega: ArrayLike, tau: ArrayLike, alpha: float, gamma: float) -> ArrayLike: r""" Spectral density :math:`J(\omega)` @@ -109,8 +107,8 @@ class HavriliakNegami(Distribution): {\omega \left[ 1+(\omega\tau)^\alpha \cos(\alpha\pi/2) + (\omega\tau)^{2\alpha} \right]^{\gamma/2}} Args: - omega (array-like): Frequency axis in 1/s (not Hz). - tau (array-like): Correlation times in s. + omega (array_like): Frequency axis in 1/s (not Hz). + tau (array_like): Correlation times in s. alpha (float): Cole-Cole shape parameter. gamma (float): Cole-Davidson shape parameter. @@ -127,7 +125,7 @@ class HavriliakNegami(Distribution): return result @staticmethod - def mean(tau: ArrayLike, alpha: float, gamma: float) -> Union[np.ndarray, float]: + def mean(tau: ArrayLike, alpha: float, gamma: float) -> ArrayLike: r""" .. math:: @@ -136,7 +134,7 @@ class HavriliakNegami(Distribution): This is an approximation given in `[1]`_ Args: - tau (array-like): Function parameter in s. + tau (array_like): Function parameter in s. alpha (float): Shape parameter. gamma (float): Even more shape parameter. diff --git a/nmreval/distributions/intermolecular.py b/src/nmreval/distributions/intermolecular.py similarity index 100% rename from nmreval/distributions/intermolecular.py rename to src/nmreval/distributions/intermolecular.py diff --git a/nmreval/distributions/kww.py b/src/nmreval/distributions/kww.py similarity index 100% rename from nmreval/distributions/kww.py rename to src/nmreval/distributions/kww.py diff --git a/nmreval/distributions/loggaussian.py b/src/nmreval/distributions/loggaussian.py similarity index 98% rename from nmreval/distributions/loggaussian.py rename to src/nmreval/distributions/loggaussian.py index 62cf0b3..e1736c8 100644 --- a/nmreval/distributions/loggaussian.py +++ b/src/nmreval/distributions/loggaussian.py @@ -3,8 +3,6 @@ from itertools import product import numpy as np -from ..lib.decorator import adjust_dims - try: from scipy.integrate import simpson except ImportError: diff --git a/nmreval/math/__init__.py b/src/nmreval/dsc/__init__.py similarity index 100% rename from nmreval/math/__init__.py rename to src/nmreval/dsc/__init__.py diff --git a/nmreval/dsc/calibration.py b/src/nmreval/dsc/calibration.py similarity index 99% rename from nmreval/dsc/calibration.py rename to src/nmreval/dsc/calibration.py index 1b293f7..bfae765 100644 --- a/nmreval/dsc/calibration.py +++ b/src/nmreval/dsc/calibration.py @@ -1,5 +1,3 @@ -__version__ = '0.1.3' - import os import argparse import sys @@ -9,7 +7,8 @@ import matplotlib.pyplot as plt import scipy.interpolate from scipy.integrate import simps -from nmreval.io.dsc import DSCSample, Cyclohexane +from ..io.dsc import DSCSample, Cyclohexane + parser = argparse.ArgumentParser(description='Calibrate DSC data') parser.add_argument('sample', type=str, help='filename of DSC sample') diff --git a/nmreval/dsc/dsc_calibration_fast_neu.py b/src/nmreval/dsc/dsc_calibration_fast_neu.py similarity index 100% rename from nmreval/dsc/dsc_calibration_fast_neu.py rename to src/nmreval/dsc/dsc_calibration_fast_neu.py diff --git a/nmreval/fit/__init__.py b/src/nmreval/fit/__init__.py similarity index 100% rename from nmreval/fit/__init__.py rename to src/nmreval/fit/__init__.py diff --git a/nmreval/fit/_meta.py b/src/nmreval/fit/_meta.py similarity index 97% rename from nmreval/fit/_meta.py rename to src/nmreval/fit/_meta.py index 68d92bd..e8b101f 100644 --- a/nmreval/fit/_meta.py +++ b/src/nmreval/fit/_meta.py @@ -1,4 +1,6 @@ -from typing import Union, Callable, Any +from __future__ import annotations + +from typing import Callable, Any import operator from inspect import signature, Parameter @@ -44,7 +46,7 @@ class MultiModel: str_op = {'+': operator.add, '*': operator.mul, '-': operator.sub, '/': operator.truediv} int_op = {0: operator.add, 1: operator.mul, 2: operator.sub, 3: operator.truediv} - def __init__(self, left: Any, right: Any, op: Union[str, Callable, int] = '+', left_idx=0, right_idx=1): + def __init__(self, left: Any, right: Any, op: str | Callable | int = '+', left_idx=0, right_idx=1): self._left = left self._right = right diff --git a/nmreval/fit/data.py b/src/nmreval/fit/data.py similarity index 100% rename from nmreval/fit/data.py rename to src/nmreval/fit/data.py diff --git a/nmreval/fit/minimizer.py b/src/nmreval/fit/minimizer.py similarity index 100% rename from nmreval/fit/minimizer.py rename to src/nmreval/fit/minimizer.py index f1dfb4d..bde5a93 100644 --- a/nmreval/fit/minimizer.py +++ b/src/nmreval/fit/minimizer.py @@ -6,9 +6,9 @@ import scipy.linalg as la from scipy import optimize import scipy.odr as odr +from . import EPS from .data import Data from .model import Model -from . import EPS from .parameter import Parameters from .result import FitResultCreator diff --git a/nmreval/fit/model.py b/src/nmreval/fit/model.py similarity index 100% rename from nmreval/fit/model.py rename to src/nmreval/fit/model.py diff --git a/nmreval/fit/parameter.py b/src/nmreval/fit/parameter.py similarity index 100% rename from nmreval/fit/parameter.py rename to src/nmreval/fit/parameter.py diff --git a/nmreval/fit/result.py b/src/nmreval/fit/result.py similarity index 100% rename from nmreval/fit/result.py rename to src/nmreval/fit/result.py index cbcae65..8b705ef 100644 --- a/nmreval/fit/result.py +++ b/src/nmreval/fit/result.py @@ -9,8 +9,8 @@ import numpy as np from scipy.stats import f as fdist from scipy.interpolate import interp1d -from ..data.points import Points from .parameter import Parameter +from ..data.points import Points from ..data.signals import Signal from ..utils.text import convert diff --git a/resources/__init__.py b/src/nmreval/io/__init__.py similarity index 100% rename from resources/__init__.py rename to src/nmreval/io/__init__.py diff --git a/nmreval/io/asciireader.py b/src/nmreval/io/asciireader.py similarity index 100% rename from nmreval/io/asciireader.py rename to src/nmreval/io/asciireader.py diff --git a/nmreval/io/bds_reader.py b/src/nmreval/io/bds_reader.py similarity index 99% rename from nmreval/io/bds_reader.py rename to src/nmreval/io/bds_reader.py index 03a0cef..4ab38fe 100644 --- a/nmreval/io/bds_reader.py +++ b/src/nmreval/io/bds_reader.py @@ -1,8 +1,9 @@ +from __future__ import annotations + import re import struct import warnings from pathlib import Path -from typing import List import numpy as np @@ -117,7 +118,7 @@ class BDSReader: # Z.imag*omega), Z.real, meas.time, meas. temp., ac voltage, dc voltage self.y = np.transpose(_y[:, :, :6], (2, 0, 1)) - def export(self, ymode: str = 'epsilon', xmode: str = 'freq') -> List[BDS]: + def export(self, ymode: str = 'epsilon', xmode: str = 'freq') -> list[BDS]: y = getattr(self, ymode)() useful_info = { diff --git a/nmreval/io/dsc.py b/src/nmreval/io/dsc.py similarity index 99% rename from nmreval/io/dsc.py rename to src/nmreval/io/dsc.py index 2017340..797714c 100644 --- a/nmreval/io/dsc.py +++ b/src/nmreval/io/dsc.py @@ -1,4 +1,5 @@ from __future__ import annotations + from pathlib import Path import re from collections import namedtuple diff --git a/nmreval/io/fcbatchreader.py b/src/nmreval/io/fcbatchreader.py similarity index 77% rename from nmreval/io/fcbatchreader.py rename to src/nmreval/io/fcbatchreader.py index 6e0c1ee..c0da0e0 100644 --- a/nmreval/io/fcbatchreader.py +++ b/src/nmreval/io/fcbatchreader.py @@ -1,19 +1,20 @@ +from __future__ import annotations + import pathlib -from typing import Union import matplotlib.pyplot as plt from scipy.optimize import curve_fit import numpy as np -from ..data.points import Points -from .asciireader import AsciiReader -from .hdfreader import HdfReader -from ..utils.utils import get_temperature, roundrobin +from nmreval.data.points import Points +from nmreval.io.asciireader import AsciiReader +from nmreval.io.hdfreader import HdfReader +from nmreval.utils.utils import get_temperature, roundrobin class FCReader: - def __init__(self, fname: Union[list, str]): - if type(fname) != list: + def __init__(self, fname: (list | str | pathlib.Path)): + if isinstance(fname, (str, pathlib.Path)): self.fnames = [fname] else: self.fnames = fname @@ -24,7 +25,9 @@ class FCReader: self.t_params = {} self.f_params = {} - def __call__(self, fname: Union[list, str]): + self._scipt_type = 'old' + + def __call__(self, fname: (list | str | pathlib.Path)): if isinstance(fname, (str, pathlib.Path)): self.fnames = [fname] else: @@ -71,11 +74,11 @@ class FCReader: continue v.savetxt(save_name) - @staticmethod - def _read_from_hdf(filename: Union[str, pathlib.Path]) -> dict: + def _read_from_hdf(self, filename: (str | pathlib.Path)) -> dict: _temp = {} reader = HdfReader(filename) - for mag in reader.get_selected('mag', dtype='points'): + mag_directory = 'mag' if self._scipt_type == 'old' else 'Magnetization' + for mag in reader.get_selected(mag_directory, dtype='points'): _temp[mag.value] = mag return _temp @@ -197,9 +200,9 @@ class FCReader: fig.savefig(image_path.joinpath(save_name).with_suffix('.png')) plt.close(fig) - freqs = np.array(freqs) - params = np.array(params) - errors = np.array(errors) + freqs = np.asanyarray(freqs) + params = np.asanyarray(params) + errors = np.asanyarray(errors) # das ist jetzt eher haesslich self.t_params[temperature] = np.c_[freqs, @@ -386,3 +389,101 @@ class FCReader: @staticmethod def kww(x, m0, off, t1, beta): return m0 * np.exp(-(x/t1)**beta) + off + + +class FCFileReader: + def __init__(self, fname: str): + self.filename = pathlib.Path(fname) + self._is_dir = self.filename.is_dir() + self._script_type = None + self.reader = None + if not self._is_dir: + self.reader = HdfReader(self.filename) + if 'mag' in self.reader: + self._script_type = 'old' + elif 'Magnetization' in self.reader: + self._script_type = '2022_09' + + self._temperature = get_temperature(self.filename.stem) + + def load_magnetization(self, region=None): + if self._is_dir: + _temp = self._read_from_dir() + + else: + if region is None: + _temp = self._read_from_hdf() + else: + _temp = self._read_signals(region) + + if not _temp: + raise OSError(-666, f'No magnetization found for {self.filename.name}.', self.filename.name) + + + def _read_from_hdf(self) -> dict: + _temp = {} + mag_directory = 'mag' if self._script_type == 'old' else 'Magnetization' + for mag in self.reader.get_selected(mag_directory, dtype='points'): + _temp[mag.value] = mag + + return _temp + + def _read_from_dir(self) -> dict: + fname_no_ext = self.filename.with_suffix('') + data_path = fname_no_ext / 'data' + _temp = {} + + for mag in data_path.glob('*.dat'): + d = AsciiReader(mag).export() + for v in d: + _temp[v.value] = v + break + + return _temp + + def _read_signals(self, region: tuple = None) -> dict: + start = 0 + stop = 30e-5 + + # This is one set with attributes to find default start:stop values + try: + p = self.reader.parameters('/ABS_ACC_FID') + start = p['start'] + stop = p['stop'] + except: + pass + + if region is None: + region = (start, stop) + + if region[0] is None: + region = (start, region[1]) + if region[1] is None: + region = (region[0], stop) + + sig = self.reader.get_selected('/data/B=*/ACC_ABS_FID*', dtype='signal') + _temp = {} + for s in sig: + pts = s.points([region]) + b = s.group + if b not in _temp: + _temp[b] = [] + + _temp[b].append([s.value, *[pp[1] for pp in pts]]) + + for b, m in sorted(_temp.items()): + m = np.array(m) + _temp[b] = Points(x=m[:, 0], y=m[:, 1], value=b, name=f'B={b}').sort() + + return _temp + + + +if __name__ == '__main__': + from pprint import pprint + test = FCReader('/autohome/dominik/nmreval/testdata/fc_test/2022-09-15_1344_new_script.h5') + # test = FCReader('/autohome/dominik/nmreval/testdata/fc_test/314K_2015-09-03_1605.h5') + + test.load_magnetization() + test.load_magnetization(region=(0, 10e-6)) + # pprint(test.data) diff --git a/nmreval/io/graceeditor.py b/src/nmreval/io/graceeditor.py similarity index 99% rename from nmreval/io/graceeditor.py rename to src/nmreval/io/graceeditor.py index 3949929..0f6cb23 100644 --- a/nmreval/io/graceeditor.py +++ b/src/nmreval/io/graceeditor.py @@ -687,10 +687,11 @@ def _convert_to_value(parse_string): for i, v in enumerate(tuples): v = v.strip() - if re.match(r'[+-]?\d+.\d+', v): - tuples[i] = float(v) - elif re.match(r'[+-]?\d+', v): - tuples[i] = int(v) + if re.match(r'[+-]?\d+(?:.\d+)?(?:[Ee][+-]?\d+)?', v): + try: + tuples[i] = int(v) + except ValueError: + tuples[i] = float(v) elif re.match(r'\".*\"', v): tuples[i] = v[1:-1] else: diff --git a/nmreval/io/hdfreader.py b/src/nmreval/io/hdfreader.py similarity index 99% rename from nmreval/io/hdfreader.py rename to src/nmreval/io/hdfreader.py index 2820ef1..ce2d0ef 100644 --- a/nmreval/io/hdfreader.py +++ b/src/nmreval/io/hdfreader.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import re from functools import reduce diff --git a/nmreval/io/merge_agr.py b/src/nmreval/io/merge_agr.py similarity index 99% rename from nmreval/io/merge_agr.py rename to src/nmreval/io/merge_agr.py index ff07088..a97c241 100755 --- a/nmreval/io/merge_agr.py +++ b/src/nmreval/io/merge_agr.py @@ -1,6 +1,5 @@ #! /usr/bin/env python -import sys import re import argparse diff --git a/nmreval/io/nmrreader.py b/src/nmreval/io/nmrreader.py similarity index 96% rename from nmreval/io/nmrreader.py rename to src/nmreval/io/nmrreader.py index 24bd2fe..2268c8c 100644 --- a/nmreval/io/nmrreader.py +++ b/src/nmreval/io/nmrreader.py @@ -1,11 +1,12 @@ +from __future__ import annotations + import pickle from collections import OrderedDict -from typing import Tuple, Union +from .read_old_nmr import HAS_BSDDB3, _read_file_v1 from ..data.nmr import FID, Spectrum from ..data.points import Points from ..fit.result import FitResult, FitResultCreator -from .read_old_nmr import HAS_BSDDB3, _read_file_v1 from ..lib.colors import Colors from ..lib.lines import LineStyle from ..lib.symbols import SymbolStyle @@ -32,7 +33,7 @@ class NMRReader: else: self.version = 2 - def make_data(self, fname: str = None) -> Union[Tuple[dict, dict], Tuple[dict]]: + def make_data(self, fname: str = None) -> tuple[dict, dict] | tuple[dict]: if fname is None: fname = self.filename @@ -43,7 +44,7 @@ class NMRReader: return self._make_new(fname) @staticmethod - def _make_new(fname) -> Tuple[dict, dict]: + def _make_new(fname) -> tuple[dict, dict]: with open(fname, 'rb') as fp: # remove magic _ = fp.read(16) diff --git a/nmreval/io/read_old_nmr.py b/src/nmreval/io/read_old_nmr.py similarity index 100% rename from nmreval/io/read_old_nmr.py rename to src/nmreval/io/read_old_nmr.py diff --git a/nmreval/io/sessionwriter.py b/src/nmreval/io/sessionwriter.py similarity index 100% rename from nmreval/io/sessionwriter.py rename to src/nmreval/io/sessionwriter.py diff --git a/nmreval/io/tntreader.py b/src/nmreval/io/tntreader.py similarity index 100% rename from nmreval/io/tntreader.py rename to src/nmreval/io/tntreader.py diff --git a/resources/icons/__init__.py b/src/nmreval/lib/__init__.py similarity index 100% rename from resources/icons/__init__.py rename to src/nmreval/lib/__init__.py diff --git a/nmreval/lib/colors.py b/src/nmreval/lib/colors.py similarity index 100% rename from nmreval/lib/colors.py rename to src/nmreval/lib/colors.py diff --git a/nmreval/lib/decorator.py b/src/nmreval/lib/decorator.py similarity index 100% rename from nmreval/lib/decorator.py rename to src/nmreval/lib/decorator.py diff --git a/nmreval/lib/importer.py b/src/nmreval/lib/importer.py similarity index 92% rename from nmreval/lib/importer.py rename to src/nmreval/lib/importer.py index e1a426a..3d324fa 100644 --- a/nmreval/lib/importer.py +++ b/src/nmreval/lib/importer.py @@ -1,14 +1,16 @@ +from __future__ import annotations + import inspect import sys + from importlib import reload as import_reload from importlib.util import spec_from_loader, module_from_spec from importlib.machinery import SourceFileLoader from pathlib import Path -from typing import Union -def import_(path: Union[str, Path], reload: bool = False): +def import_(path: str | Path, reload: bool = False): """ Import file from random destination as module """ @@ -44,7 +46,7 @@ def register_mixin(obj, cls): obj.__class__ = type(_obj_cls_name, (_obj_cls, cls), {}) -def reload_(filename: Union[str, Path]): +def reload_(filename: str | Path): return import_(filename, reload=True) diff --git a/nmreval/lib/lines.py b/src/nmreval/lib/lines.py similarity index 100% rename from nmreval/lib/lines.py rename to src/nmreval/lib/lines.py diff --git a/nmreval/lib/logger.py b/src/nmreval/lib/logger.py similarity index 100% rename from nmreval/lib/logger.py rename to src/nmreval/lib/logger.py diff --git a/nmreval/lib/symbols.py b/src/nmreval/lib/symbols.py similarity index 98% rename from nmreval/lib/symbols.py rename to src/nmreval/lib/symbols.py index 2c02a76..a5a9bea 100644 --- a/nmreval/lib/symbols.py +++ b/src/nmreval/lib/symbols.py @@ -1,6 +1,6 @@ import enum -from ..gui_qt.Qt import QtGui, QtCore +from gui_qt.Qt import QtGui, QtCore sym_list = ['o', 's', 'd', 't1', 't3', 't', 't2', '+', 'x', 'star'] diff --git a/nmreval/lib/utils.py b/src/nmreval/lib/utils.py similarity index 100% rename from nmreval/lib/utils.py rename to src/nmreval/lib/utils.py diff --git a/src/nmreval/math/__init__.py b/src/nmreval/math/__init__.py new file mode 100644 index 0000000..31359c6 --- /dev/null +++ b/src/nmreval/math/__init__.py @@ -0,0 +1,32 @@ +""" +=================================== +General maths (:mod:`nmreval.math`) +=================================== + +General maths functions and applications that are not confined to usage with NMR data + +.. currentmodule:: nmreval.math + +.. _apod_functions: + +Apodization functions +************************ + +List of apodization function to make spectra nicer. +All functions are defined in the time domain. + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + apodization.GaussWindow + apodization.ExpWindow + apodization.GaussExpWindow + apodization.Traficante + apodization.Trapezoid + apodization.Trapezoid + apodization.SineBell + apodization.Box + apodization.Hamming + apodization.Hann +""" diff --git a/nmreval/math/apodization.py b/src/nmreval/math/apodization.py similarity index 78% rename from nmreval/math/apodization.py rename to src/nmreval/math/apodization.py index 5bd3901..534da61 100644 --- a/nmreval/math/apodization.py +++ b/src/nmreval/math/apodization.py @@ -1,24 +1,64 @@ +""" +====================== +Apodization functions +====================== +""" + + import numpy as np from scipy.signal.windows import general_hamming class GaussWindow: + r""" + Gaussian function + + .. math:: + y = \exp\Biggl[-\Biggl(\frac{\pi x GB}{4\sqrt{\ln2}}\Biggr)^2\Biggr] + + """ name = 'Gaussian' equation = r'exp(-(\pi GB x/[2*sqrt(ln2)])^{2})' params = ['GB/Hz'] @staticmethod def apod(x, gb): + r""" + Gaussian function + + .. math:: + y = \exp\Biggl[-\Biggl(\frac{\pi x gb}{4\sqrt{\ln2}}\Biggr)^2\Biggr] + + Args: + x (array-like): Input values + gb (float): FWHM (in the frequency domain) + """ return np.exp(-(x*gb*np.pi/4./np.sqrt(np.log(2)))**2) class ExpWindow: + r""" + Exponential function + + .. math:: + y = \exp(-\pi x LB) + """ name = 'Exponential' equation = r'exp(-\pi LB x)' params = ['LB/Hz'] @staticmethod def apod(x, lb): + r""" + Exponential function + + .. math:: + y = \exp(-\pi x lb) + + Args: + x (array-like): Input values + lb (float): FWHM (in the frequency domain) + """ return np.exp(-np.pi*x*lb) diff --git a/nmreval/math/interpol.py b/src/nmreval/math/interpol.py similarity index 100% rename from nmreval/math/interpol.py rename to src/nmreval/math/interpol.py diff --git a/nmreval/math/kww.py b/src/nmreval/math/kww.py similarity index 100% rename from nmreval/math/kww.py rename to src/nmreval/math/kww.py diff --git a/nmreval/math/logfourier.py b/src/nmreval/math/logfourier.py similarity index 100% rename from nmreval/math/logfourier.py rename to src/nmreval/math/logfourier.py diff --git a/nmreval/math/mittagleffler.py b/src/nmreval/math/mittagleffler.py similarity index 98% rename from nmreval/math/mittagleffler.py rename to src/nmreval/math/mittagleffler.py index 874382d..64af143 100644 --- a/nmreval/math/mittagleffler.py +++ b/src/nmreval/math/mittagleffler.py @@ -1,5 +1,7 @@ +from __future__ import annotations + from numbers import Number -from typing import TypeVar, Union +from typing import TypeVar import numpy as np from math import sqrt, log, exp, ceil @@ -39,7 +41,7 @@ def mlf(z: T, a: float, b: float = 1, g: float = 1) -> T: return ret_val.reshape(z.shape) -def _mlf_single(z: Union[int, float, complex], a: float, b: float, g: float): +def _mlf_single(z: int | float | complex, a: float, b: float, g: float): if abs(z) < 1.0e-15: ret_val = 1 / gamma(b) else: diff --git a/nmreval/math/orientations.py b/src/nmreval/math/orientations.py similarity index 100% rename from nmreval/math/orientations.py rename to src/nmreval/math/orientations.py diff --git a/nmreval/math/pca.py b/src/nmreval/math/pca.py similarity index 100% rename from nmreval/math/pca.py rename to src/nmreval/math/pca.py diff --git a/nmreval/math/smooth.py b/src/nmreval/math/smooth.py similarity index 100% rename from nmreval/math/smooth.py rename to src/nmreval/math/smooth.py diff --git a/nmreval/models/__init__.py b/src/nmreval/models/__init__.py similarity index 100% rename from nmreval/models/__init__.py rename to src/nmreval/models/__init__.py diff --git a/nmreval/models/basic.py b/src/nmreval/models/basic.py similarity index 100% rename from nmreval/models/basic.py rename to src/nmreval/models/basic.py diff --git a/nmreval/models/bds.py b/src/nmreval/models/bds.py similarity index 100% rename from nmreval/models/bds.py rename to src/nmreval/models/bds.py diff --git a/nmreval/models/correlationfuncs.py b/src/nmreval/models/correlationfuncs.py similarity index 100% rename from nmreval/models/correlationfuncs.py rename to src/nmreval/models/correlationfuncs.py diff --git a/nmreval/models/diffusion.py b/src/nmreval/models/diffusion.py similarity index 100% rename from nmreval/models/diffusion.py rename to src/nmreval/models/diffusion.py diff --git a/nmreval/models/fieldcycling.py b/src/nmreval/models/fieldcycling.py similarity index 100% rename from nmreval/models/fieldcycling.py rename to src/nmreval/models/fieldcycling.py diff --git a/nmreval/models/relaxation.py b/src/nmreval/models/relaxation.py similarity index 100% rename from nmreval/models/relaxation.py rename to src/nmreval/models/relaxation.py diff --git a/nmreval/models/spectrum.py b/src/nmreval/models/spectrum.py similarity index 97% rename from nmreval/models/spectrum.py rename to src/nmreval/models/spectrum.py index 2a7627f..229cf66 100644 --- a/nmreval/models/spectrum.py +++ b/src/nmreval/models/spectrum.py @@ -1,10 +1,8 @@ -from typing import Union - import numpy as np -__all__ = ['Gaussian', 'Lorentzian', 'PseudoVoigt'] +from ..lib.utils import ArrayLike -ArrayLike = Union[float, np.ndarray] +__all__ = ['Gaussian', 'Lorentzian', 'PseudoVoigt'] class Gaussian: diff --git a/nmreval/models/stimecho.py b/src/nmreval/models/stimecho.py similarity index 100% rename from nmreval/models/stimecho.py rename to src/nmreval/models/stimecho.py index 6c80b7f..26cb111 100644 --- a/nmreval/models/stimecho.py +++ b/src/nmreval/models/stimecho.py @@ -2,8 +2,8 @@ from itertools import product import numpy as np -from ..math.mittagleffler import mlf from .correlationfuncs import GammaCD +from ..math.mittagleffler import mlf class StimEcho: diff --git a/nmreval/models/temperature.py b/src/nmreval/models/temperature.py similarity index 94% rename from nmreval/models/temperature.py rename to src/nmreval/models/temperature.py index cc43777..ff2a12d 100644 --- a/nmreval/models/temperature.py +++ b/src/nmreval/models/temperature.py @@ -3,7 +3,7 @@ import numpy as np from ..utils.constants import kB -class _MAScalibration(object): +class _MAScalibration: type = 'Other' name = 'MAS temperature' equation = '' @@ -15,7 +15,7 @@ class _MAScalibration(object): return 1250 - 3.81194e-6 * np.sqrt(1.47663e17 - 1.32344e14 * realt) -class VFT(object): +class VFT: r""" Calculates Vogel-Fulcher-Tammann @@ -36,7 +36,7 @@ class VFT(object): elif invt == 'invt1000': x = 1000. / x - return t0 * np.exp(b / (x-t0)) + return tau0 * np.exp(b / (x-t0)) class Arrhenius: @@ -57,7 +57,7 @@ class Arrhenius: return tau0 * np.exp(ea / (kB*x)) -class Ecoop(object): +class Ecoop: name = 'Roessler-Ding' type = 'Temperature' equation = r'\tau_{\infty}exp[E_{\infty}/T(1+exp(-\mu((T-T_{A})/E_{\infty})))]' diff --git a/nmreval/models/transitions.py b/src/nmreval/models/transitions.py similarity index 100% rename from nmreval/models/transitions.py rename to src/nmreval/models/transitions.py diff --git a/nmreval/models/usermodels.py b/src/nmreval/models/usermodels.py similarity index 100% rename from nmreval/models/usermodels.py rename to src/nmreval/models/usermodels.py diff --git a/nmreval/models/wideline.py b/src/nmreval/models/wideline.py similarity index 100% rename from nmreval/models/wideline.py rename to src/nmreval/models/wideline.py diff --git a/nmreval/nmr/__init__.py b/src/nmreval/nmr/__init__.py similarity index 100% rename from nmreval/nmr/__init__.py rename to src/nmreval/nmr/__init__.py diff --git a/nmreval/nmr/coupling.py b/src/nmreval/nmr/coupling.py similarity index 100% rename from nmreval/nmr/coupling.py rename to src/nmreval/nmr/coupling.py diff --git a/nmreval/nmr/fc_eval.py b/src/nmreval/nmr/fc_eval.py similarity index 100% rename from nmreval/nmr/fc_eval.py rename to src/nmreval/nmr/fc_eval.py diff --git a/nmreval/nmr/relaxation.py b/src/nmreval/nmr/relaxation.py similarity index 99% rename from nmreval/nmr/relaxation.py rename to src/nmreval/nmr/relaxation.py index fba9ecb..7381316 100755 --- a/nmreval/nmr/relaxation.py +++ b/src/nmreval/nmr/relaxation.py @@ -6,8 +6,7 @@ Classes to calculate spin-lattice and spin-spin relaxation, as well as to evalua """ from __future__ import annotations -from pathlib import Path -from typing import Any, Tuple, Type +from typing import Any, Type from warnings import warn import numpy as np @@ -664,9 +663,9 @@ class RelaxationEvaluation(Relaxation): def calculate_t1_min( self, interpolate: int = None, - trange: Tuple[float, float] = None, + trange: tuple[float, float] = None, use_log: bool = False, - ) -> Tuple[Tuple[float, float], Tuple[np.ndarray, np.ndarray] | None]: + ) -> tuple[tuple[float, float], tuple[np.ndarray, np.ndarray] | None]: """ Determine a minimum position for given T1 data @@ -742,7 +741,7 @@ class RelaxationEvaluation(Relaxation): prefactor: float = None, coupling_param: list = None, coupling_kwargs: dict = None, - ) -> Tuple[np.ndarray, dict]: + ) -> tuple[np.ndarray, dict]: """ Calculate correlation times from set T1 data. Optional arguments overwrite previousliy set parameter. diff --git a/nmreval/utils/__init__.py b/src/nmreval/utils/__init__.py similarity index 100% rename from nmreval/utils/__init__.py rename to src/nmreval/utils/__init__.py diff --git a/nmreval/utils/constants.py b/src/nmreval/utils/constants.py similarity index 100% rename from nmreval/utils/constants.py rename to src/nmreval/utils/constants.py diff --git a/nmreval/utils/exception.py b/src/nmreval/utils/exception.py similarity index 100% rename from nmreval/utils/exception.py rename to src/nmreval/utils/exception.py diff --git a/nmreval/utils/pca_demo_pcs.py b/src/nmreval/utils/pca_demo_pcs.py similarity index 100% rename from nmreval/utils/pca_demo_pcs.py rename to src/nmreval/utils/pca_demo_pcs.py diff --git a/nmreval/utils/pokemon.json b/src/nmreval/utils/pokemon.json similarity index 100% rename from nmreval/utils/pokemon.json rename to src/nmreval/utils/pokemon.json diff --git a/nmreval/utils/text.py b/src/nmreval/utils/text.py similarity index 100% rename from nmreval/utils/text.py rename to src/nmreval/utils/text.py diff --git a/nmreval/utils/utils.py b/src/nmreval/utils/utils.py similarity index 100% rename from nmreval/utils/utils.py rename to src/nmreval/utils/utils.py diff --git a/nmreval/version.py b/src/nmreval/version.py similarity index 100% rename from nmreval/version.py rename to src/nmreval/version.py diff --git a/resources/Default.agr b/src/resources/Default.agr similarity index 100% rename from resources/Default.agr rename to src/resources/Default.agr diff --git a/resources/nmr/__init__.py b/src/resources/__init__.py similarity index 100% rename from resources/nmr/__init__.py rename to src/resources/__init__.py diff --git a/resources/_rc/axes.png b/src/resources/_rc/axes.png similarity index 100% rename from resources/_rc/axes.png rename to src/resources/_rc/axes.png diff --git a/resources/_rc/blackwhite.png b/src/resources/_rc/blackwhite.png similarity index 100% rename from resources/_rc/blackwhite.png rename to src/resources/_rc/blackwhite.png diff --git a/resources/_rc/blackwhite.svg b/src/resources/_rc/blackwhite.svg similarity index 100% rename from resources/_rc/blackwhite.svg rename to src/resources/_rc/blackwhite.svg diff --git a/resources/_rc/cat.png b/src/resources/_rc/cat.png similarity index 100% rename from resources/_rc/cat.png rename to src/resources/_rc/cat.png diff --git a/resources/_rc/colors.png b/src/resources/_rc/colors.png similarity index 100% rename from resources/_rc/colors.png rename to src/resources/_rc/colors.png diff --git a/resources/_rc/colors.svg b/src/resources/_rc/colors.svg similarity index 100% rename from resources/_rc/colors.svg rename to src/resources/_rc/colors.svg diff --git a/resources/_rc/cut_region.png b/src/resources/_rc/cut_region.png similarity index 100% rename from resources/_rc/cut_region.png rename to src/resources/_rc/cut_region.png diff --git a/resources/_rc/eval_button.png b/src/resources/_rc/eval_button.png similarity index 100% rename from resources/_rc/eval_button.png rename to src/resources/_rc/eval_button.png diff --git a/resources/_rc/fit_preview.png b/src/resources/_rc/fit_preview.png similarity index 100% rename from resources/_rc/fit_preview.png rename to src/resources/_rc/fit_preview.png diff --git a/resources/_rc/fit_region.png b/src/resources/_rc/fit_region.png similarity index 100% rename from resources/_rc/fit_region.png rename to src/resources/_rc/fit_region.png diff --git a/resources/_rc/grid.png b/src/resources/_rc/grid.png similarity index 100% rename from resources/_rc/grid.png rename to src/resources/_rc/grid.png diff --git a/resources/_rc/grid.svg b/src/resources/_rc/grid.svg similarity index 100% rename from resources/_rc/grid.svg rename to src/resources/_rc/grid.svg diff --git a/resources/_rc/imag.png b/src/resources/_rc/imag.png similarity index 100% rename from resources/_rc/imag.png rename to src/resources/_rc/imag.png diff --git a/resources/_rc/imag.svg b/src/resources/_rc/imag.svg similarity index 100% rename from resources/_rc/imag.svg rename to src/resources/_rc/imag.svg diff --git a/resources/_rc/images.qrc b/src/resources/_rc/images.qrc similarity index 100% rename from resources/_rc/images.qrc rename to src/resources/_rc/images.qrc diff --git a/resources/_rc/left.png b/src/resources/_rc/left.png similarity index 100% rename from resources/_rc/left.png rename to src/resources/_rc/left.png diff --git a/resources/_rc/logo.png b/src/resources/_rc/logo.png similarity index 100% rename from resources/_rc/logo.png rename to src/resources/_rc/logo.png diff --git a/resources/_rc/mean.png b/src/resources/_rc/mean.png similarity index 100% rename from resources/_rc/mean.png rename to src/resources/_rc/mean.png diff --git a/resources/_rc/mouse.png b/src/resources/_rc/mouse.png similarity index 100% rename from resources/_rc/mouse.png rename to src/resources/_rc/mouse.png diff --git a/resources/_rc/open_session.png b/src/resources/_rc/open_session.png similarity index 100% rename from resources/_rc/open_session.png rename to src/resources/_rc/open_session.png diff --git a/resources/_rc/path48-3-5-6-2.png b/src/resources/_rc/path48-3-5-6-2.png similarity index 100% rename from resources/_rc/path48-3-5-6-2.png rename to src/resources/_rc/path48-3-5-6-2.png diff --git a/resources/_rc/properties.png b/src/resources/_rc/properties.png similarity index 100% rename from resources/_rc/properties.png rename to src/resources/_rc/properties.png diff --git a/resources/_rc/punktdings.png b/src/resources/_rc/punktdings.png similarity index 100% rename from resources/_rc/punktdings.png rename to src/resources/_rc/punktdings.png diff --git a/resources/_rc/real.png b/src/resources/_rc/real.png similarity index 100% rename from resources/_rc/real.png rename to src/resources/_rc/real.png diff --git a/resources/_rc/real.svg b/src/resources/_rc/real.svg similarity index 100% rename from resources/_rc/real.svg rename to src/resources/_rc/real.svg diff --git a/resources/_rc/right.png b/src/resources/_rc/right.png similarity index 100% rename from resources/_rc/right.png rename to src/resources/_rc/right.png diff --git a/resources/_rc/sort.png b/src/resources/_rc/sort.png similarity index 100% rename from resources/_rc/sort.png rename to src/resources/_rc/sort.png diff --git a/resources/_rc/xlog.png b/src/resources/_rc/xlog.png similarity index 100% rename from resources/_rc/xlog.png rename to src/resources/_rc/xlog.png diff --git a/resources/_rc/xlog.svg b/src/resources/_rc/xlog.svg similarity index 100% rename from resources/_rc/xlog.svg rename to src/resources/_rc/xlog.svg diff --git a/resources/_rc/ylog.png b/src/resources/_rc/ylog.png similarity index 100% rename from resources/_rc/ylog.png rename to src/resources/_rc/ylog.png diff --git a/resources/_rc/ylog.svg b/src/resources/_rc/ylog.svg similarity index 100% rename from resources/_rc/ylog.svg rename to src/resources/_rc/ylog.svg diff --git a/resources/_ui/agroptiondialog.ui b/src/resources/_ui/agroptiondialog.ui similarity index 100% rename from resources/_ui/agroptiondialog.ui rename to src/resources/_ui/agroptiondialog.ui diff --git a/resources/_ui/apod_dialog.ui b/src/resources/_ui/apod_dialog.ui similarity index 100% rename from resources/_ui/apod_dialog.ui rename to src/resources/_ui/apod_dialog.ui diff --git a/resources/_ui/asciidialog.ui b/src/resources/_ui/asciidialog.ui similarity index 100% rename from resources/_ui/asciidialog.ui rename to src/resources/_ui/asciidialog.ui diff --git a/resources/_ui/axisConfigTemplate.ui b/src/resources/_ui/axisConfigTemplate.ui similarity index 100% rename from resources/_ui/axisConfigTemplate.ui rename to src/resources/_ui/axisConfigTemplate.ui diff --git a/resources/_ui/baseline_dialog.ui b/src/resources/_ui/baseline_dialog.ui similarity index 100% rename from resources/_ui/baseline_dialog.ui rename to src/resources/_ui/baseline_dialog.ui diff --git a/resources/_ui/basewindow.ui b/src/resources/_ui/basewindow.ui similarity index 100% rename from resources/_ui/basewindow.ui rename to src/resources/_ui/basewindow.ui diff --git a/resources/_ui/bdsdialog.ui b/src/resources/_ui/bdsdialog.ui similarity index 100% rename from resources/_ui/bdsdialog.ui rename to src/resources/_ui/bdsdialog.ui diff --git a/resources/_ui/color_palette.ui b/src/resources/_ui/color_palette.ui similarity index 100% rename from resources/_ui/color_palette.ui rename to src/resources/_ui/color_palette.ui diff --git a/resources/_ui/coupling_calculator.ui b/src/resources/_ui/coupling_calculator.ui similarity index 100% rename from resources/_ui/coupling_calculator.ui rename to src/resources/_ui/coupling_calculator.ui diff --git a/resources/_ui/coupling_t1_from_tau.ui b/src/resources/_ui/coupling_t1_from_tau.ui similarity index 100% rename from resources/_ui/coupling_t1_from_tau.ui rename to src/resources/_ui/coupling_t1_from_tau.ui diff --git a/resources/_ui/datawidget.ui b/src/resources/_ui/datawidget.ui similarity index 100% rename from resources/_ui/datawidget.ui rename to src/resources/_ui/datawidget.ui diff --git a/resources/_ui/dscfile_dialog.ui b/src/resources/_ui/dscfile_dialog.ui similarity index 100% rename from resources/_ui/dscfile_dialog.ui rename to src/resources/_ui/dscfile_dialog.ui diff --git a/resources/_ui/editsignalwidget.ui b/src/resources/_ui/editsignalwidget.ui similarity index 100% rename from resources/_ui/editsignalwidget.ui rename to src/resources/_ui/editsignalwidget.ui diff --git a/resources/_ui/eval_expr_dialog.ui b/src/resources/_ui/eval_expr_dialog.ui similarity index 100% rename from resources/_ui/eval_expr_dialog.ui rename to src/resources/_ui/eval_expr_dialog.ui diff --git a/resources/_ui/evalexpression.ui b/src/resources/_ui/evalexpression.ui similarity index 100% rename from resources/_ui/evalexpression.ui rename to src/resources/_ui/evalexpression.ui diff --git a/resources/_ui/expandablewidget.ui b/src/resources/_ui/expandablewidget.ui similarity index 100% rename from resources/_ui/expandablewidget.ui rename to src/resources/_ui/expandablewidget.ui diff --git a/resources/_ui/exportConfigTemplate.ui b/src/resources/_ui/exportConfigTemplate.ui similarity index 100% rename from resources/_ui/exportConfigTemplate.ui rename to src/resources/_ui/exportConfigTemplate.ui diff --git a/resources/_ui/fcreader.ui b/src/resources/_ui/fcreader.ui similarity index 100% rename from resources/_ui/fcreader.ui rename to src/resources/_ui/fcreader.ui diff --git a/resources/_ui/filedialog.ui b/src/resources/_ui/filedialog.ui similarity index 100% rename from resources/_ui/filedialog.ui rename to src/resources/_ui/filedialog.ui diff --git a/src/resources/_ui/fitcreationdialog.ui b/src/resources/_ui/fitcreationdialog.ui new file mode 100644 index 0000000..f6893a3 --- /dev/null +++ b/src/resources/_ui/fitcreationdialog.ui @@ -0,0 +1,150 @@ + + + Dialog + + + + 0 + 0 + 773 + 633 + + + + + 0 + 0 + + + + Create fit function + + + + + + Qt::Vertical + + + + 0 + + + + Description + + + + 0 + + + 3 + + + 3 + + + 3 + + + 3 + + + + + + Variables + + + + 0 + + + 3 + + + 3 + + + 3 + + + 3 + + + + + + Multiple choice + + + + + + Available Functions + + + + + + + true + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + CodeEditor + QPlainTextEdit +
..lib.codeeditor
+
+
+ + + + buttonBox + accepted() + Dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +
diff --git a/resources/_ui/fitdialog.ui b/src/resources/_ui/fitdialog.ui similarity index 100% rename from resources/_ui/fitdialog.ui rename to src/resources/_ui/fitdialog.ui diff --git a/resources/_ui/fitdialog_window.ui b/src/resources/_ui/fitdialog_window.ui similarity index 100% rename from resources/_ui/fitdialog_window.ui rename to src/resources/_ui/fitdialog_window.ui diff --git a/resources/_ui/fitfunctionwidget.ui b/src/resources/_ui/fitfunctionwidget.ui similarity index 100% rename from resources/_ui/fitfunctionwidget.ui rename to src/resources/_ui/fitfunctionwidget.ui diff --git a/resources/_ui/fitfuncwidget.ui b/src/resources/_ui/fitfuncwidget.ui similarity index 100% rename from resources/_ui/fitfuncwidget.ui rename to src/resources/_ui/fitfuncwidget.ui diff --git a/resources/_ui/fitfuncwidget_old.ui b/src/resources/_ui/fitfuncwidget_old.ui similarity index 100% rename from resources/_ui/fitfuncwidget_old.ui rename to src/resources/_ui/fitfuncwidget_old.ui diff --git a/resources/_ui/fitmodelfixwidget.ui b/src/resources/_ui/fitmodelfixwidget.ui similarity index 100% rename from resources/_ui/fitmodelfixwidget.ui rename to src/resources/_ui/fitmodelfixwidget.ui diff --git a/resources/_ui/fitmodelwidget.ui b/src/resources/_ui/fitmodelwidget.ui similarity index 100% rename from resources/_ui/fitmodelwidget.ui rename to src/resources/_ui/fitmodelwidget.ui diff --git a/resources/_ui/fitparametertable.ui b/src/resources/_ui/fitparametertable.ui similarity index 100% rename from resources/_ui/fitparametertable.ui rename to src/resources/_ui/fitparametertable.ui diff --git a/resources/_ui/fitparameterwidget.ui b/src/resources/_ui/fitparameterwidget.ui similarity index 100% rename from resources/_ui/fitparameterwidget.ui rename to src/resources/_ui/fitparameterwidget.ui diff --git a/resources/_ui/fitresult.ui b/src/resources/_ui/fitresult.ui similarity index 100% rename from resources/_ui/fitresult.ui rename to src/resources/_ui/fitresult.ui diff --git a/resources/_ui/ftdialog.ui b/src/resources/_ui/ftdialog.ui similarity index 100% rename from resources/_ui/ftdialog.ui rename to src/resources/_ui/ftdialog.ui diff --git a/resources/_ui/function_tree_widget.ui b/src/resources/_ui/function_tree_widget.ui similarity index 100% rename from resources/_ui/function_tree_widget.ui rename to src/resources/_ui/function_tree_widget.ui diff --git a/resources/_ui/gol.ui b/src/resources/_ui/gol.ui similarity index 100% rename from resources/_ui/gol.ui rename to src/resources/_ui/gol.ui diff --git a/resources/_ui/gracemsgdialog.ui b/src/resources/_ui/gracemsgdialog.ui similarity index 100% rename from resources/_ui/gracemsgdialog.ui rename to src/resources/_ui/gracemsgdialog.ui diff --git a/resources/_ui/gracereader.ui b/src/resources/_ui/gracereader.ui similarity index 100% rename from resources/_ui/gracereader.ui rename to src/resources/_ui/gracereader.ui diff --git a/resources/_ui/graph.ui b/src/resources/_ui/graph.ui similarity index 100% rename from resources/_ui/graph.ui rename to src/resources/_ui/graph.ui diff --git a/resources/_ui/guidelinewidget.ui b/src/resources/_ui/guidelinewidget.ui similarity index 100% rename from resources/_ui/guidelinewidget.ui rename to src/resources/_ui/guidelinewidget.ui diff --git a/resources/_ui/hdftree.ui b/src/resources/_ui/hdftree.ui similarity index 100% rename from resources/_ui/hdftree.ui rename to src/resources/_ui/hdftree.ui diff --git a/resources/_ui/integral_widget.ui b/src/resources/_ui/integral_widget.ui similarity index 100% rename from resources/_ui/integral_widget.ui rename to src/resources/_ui/integral_widget.ui diff --git a/resources/_ui/integratederive_dialog.ui b/src/resources/_ui/integratederive_dialog.ui similarity index 100% rename from resources/_ui/integratederive_dialog.ui rename to src/resources/_ui/integratederive_dialog.ui diff --git a/resources/_ui/interpol_dialog.ui b/src/resources/_ui/interpol_dialog.ui similarity index 100% rename from resources/_ui/interpol_dialog.ui rename to src/resources/_ui/interpol_dialog.ui diff --git a/resources/_ui/lineedit_dialog.ui b/src/resources/_ui/lineedit_dialog.ui similarity index 100% rename from resources/_ui/lineedit_dialog.ui rename to src/resources/_ui/lineedit_dialog.ui diff --git a/resources/_ui/mean_form.ui b/src/resources/_ui/mean_form.ui similarity index 100% rename from resources/_ui/mean_form.ui rename to src/resources/_ui/mean_form.ui diff --git a/resources/_ui/meandialog.ui b/src/resources/_ui/meandialog.ui similarity index 100% rename from resources/_ui/meandialog.ui rename to src/resources/_ui/meandialog.ui diff --git a/resources/_ui/modelwidget.ui b/src/resources/_ui/modelwidget.ui similarity index 100% rename from resources/_ui/modelwidget.ui rename to src/resources/_ui/modelwidget.ui diff --git a/resources/_ui/move_dialog.ui b/src/resources/_ui/move_dialog.ui similarity index 100% rename from resources/_ui/move_dialog.ui rename to src/resources/_ui/move_dialog.ui diff --git a/resources/_ui/namespace_widget.ui b/src/resources/_ui/namespace_widget.ui similarity index 100% rename from resources/_ui/namespace_widget.ui rename to src/resources/_ui/namespace_widget.ui diff --git a/resources/_ui/option_selection.ui b/src/resources/_ui/option_selection.ui similarity index 100% rename from resources/_ui/option_selection.ui rename to src/resources/_ui/option_selection.ui diff --git a/resources/_ui/parameterform.ui b/src/resources/_ui/parameterform.ui similarity index 100% rename from resources/_ui/parameterform.ui rename to src/resources/_ui/parameterform.ui diff --git a/resources/_ui/phase_corr_dialog.ui b/src/resources/_ui/phase_corr_dialog.ui similarity index 100% rename from resources/_ui/phase_corr_dialog.ui rename to src/resources/_ui/phase_corr_dialog.ui diff --git a/resources/_ui/plotConfigTemplate.ui b/src/resources/_ui/plotConfigTemplate.ui similarity index 100% rename from resources/_ui/plotConfigTemplate.ui rename to src/resources/_ui/plotConfigTemplate.ui diff --git a/resources/_ui/pokemon.ui b/src/resources/_ui/pokemon.ui similarity index 100% rename from resources/_ui/pokemon.ui rename to src/resources/_ui/pokemon.ui diff --git a/resources/_ui/propwidget.ui b/src/resources/_ui/propwidget.ui similarity index 100% rename from resources/_ui/propwidget.ui rename to src/resources/_ui/propwidget.ui diff --git a/resources/_ui/ptstab.ui b/src/resources/_ui/ptstab.ui similarity index 100% rename from resources/_ui/ptstab.ui rename to src/resources/_ui/ptstab.ui diff --git a/resources/_ui/qfiledialog.ui b/src/resources/_ui/qfiledialog.ui similarity index 100% rename from resources/_ui/qfiledialog.ui rename to src/resources/_ui/qfiledialog.ui diff --git a/resources/_ui/save_fit_parameter.ui b/src/resources/_ui/save_fit_parameter.ui similarity index 100% rename from resources/_ui/save_fit_parameter.ui rename to src/resources/_ui/save_fit_parameter.ui diff --git a/resources/_ui/save_fitmodel_dialog.ui b/src/resources/_ui/save_fitmodel_dialog.ui similarity index 100% rename from resources/_ui/save_fitmodel_dialog.ui rename to src/resources/_ui/save_fitmodel_dialog.ui diff --git a/resources/_ui/save_options.ui b/src/resources/_ui/save_options.ui similarity index 100% rename from resources/_ui/save_options.ui rename to src/resources/_ui/save_options.ui diff --git a/resources/_ui/saveoptions.ui b/src/resources/_ui/saveoptions.ui similarity index 100% rename from resources/_ui/saveoptions.ui rename to src/resources/_ui/saveoptions.ui diff --git a/resources/_ui/sdmodelwidget.ui b/src/resources/_ui/sdmodelwidget.ui similarity index 100% rename from resources/_ui/sdmodelwidget.ui rename to src/resources/_ui/sdmodelwidget.ui diff --git a/resources/_ui/selection_widget.ui b/src/resources/_ui/selection_widget.ui similarity index 100% rename from resources/_ui/selection_widget.ui rename to src/resources/_ui/selection_widget.ui diff --git a/resources/_ui/setbyfunction_dialog.ui b/src/resources/_ui/setbyfunction_dialog.ui similarity index 100% rename from resources/_ui/setbyfunction_dialog.ui rename to src/resources/_ui/setbyfunction_dialog.ui diff --git a/resources/_ui/shift_scale_dialog.ui b/src/resources/_ui/shift_scale_dialog.ui similarity index 99% rename from resources/_ui/shift_scale_dialog.ui rename to src/resources/_ui/shift_scale_dialog.ui index a3ac3a8..6f7939b 100644 --- a/resources/_ui/shift_scale_dialog.ui +++ b/src/resources/_ui/shift_scale_dialog.ui @@ -510,7 +510,7 @@ SciSpinBox QDoubleSpinBox -
..lib.utils
+
..lib.spinboxes
diff --git a/resources/_ui/skipdialog.ui b/src/resources/_ui/skipdialog.ui similarity index 100% rename from resources/_ui/skipdialog.ui rename to src/resources/_ui/skipdialog.ui diff --git a/resources/_ui/smoothdialog.ui b/src/resources/_ui/smoothdialog.ui similarity index 100% rename from resources/_ui/smoothdialog.ui rename to src/resources/_ui/smoothdialog.ui diff --git a/resources/_ui/t1_calc_dialog.ui b/src/resources/_ui/t1_calc_dialog.ui similarity index 100% rename from resources/_ui/t1_calc_dialog.ui rename to src/resources/_ui/t1_calc_dialog.ui diff --git a/resources/_ui/t1_dock.ui b/src/resources/_ui/t1_dock.ui similarity index 100% rename from resources/_ui/t1_dock.ui rename to src/resources/_ui/t1_dock.ui diff --git a/resources/_ui/t1_tau_calculation.ui b/src/resources/_ui/t1_tau_calculation.ui similarity index 100% rename from resources/_ui/t1_tau_calculation.ui rename to src/resources/_ui/t1_tau_calculation.ui diff --git a/resources/_ui/t1dialog.ui b/src/resources/_ui/t1dialog.ui similarity index 100% rename from resources/_ui/t1dialog.ui rename to src/resources/_ui/t1dialog.ui diff --git a/resources/_ui/tntdialog.ui b/src/resources/_ui/tntdialog.ui similarity index 100% rename from resources/_ui/tntdialog.ui rename to src/resources/_ui/tntdialog.ui diff --git a/resources/_ui/typeconversion.ui b/src/resources/_ui/typeconversion.ui similarity index 100% rename from resources/_ui/typeconversion.ui rename to src/resources/_ui/typeconversion.ui diff --git a/resources/_ui/untitled.ui b/src/resources/_ui/untitled.ui similarity index 100% rename from resources/_ui/untitled.ui rename to src/resources/_ui/untitled.ui diff --git a/resources/_ui/userfitassist.ui b/src/resources/_ui/userfitassist.ui similarity index 100% rename from resources/_ui/userfitassist.ui rename to src/resources/_ui/userfitassist.ui diff --git a/resources/_ui/usermodeleditor.ui b/src/resources/_ui/usermodeleditor.ui similarity index 100% rename from resources/_ui/usermodeleditor.ui rename to src/resources/_ui/usermodeleditor.ui diff --git a/resources/_ui/valueeditor.ui b/src/resources/_ui/valueeditor.ui similarity index 100% rename from resources/_ui/valueeditor.ui rename to src/resources/_ui/valueeditor.ui diff --git a/src/resources/icons/__init__.py b/src/resources/icons/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/resources/icons/icons.json b/src/resources/icons/icons.json similarity index 100% rename from resources/icons/icons.json rename to src/resources/icons/icons.json diff --git a/resources/icons/logo.png b/src/resources/icons/logo.png similarity index 100% rename from resources/icons/logo.png rename to src/resources/icons/logo.png diff --git a/resources/icons/normal_light/__init__.py b/src/resources/icons/normal_light/__init__.py similarity index 100% rename from resources/icons/normal_light/__init__.py rename to src/resources/icons/normal_light/__init__.py diff --git a/resources/icons/normal_light/blackwhite.png b/src/resources/icons/normal_light/blackwhite.png similarity index 100% rename from resources/icons/normal_light/blackwhite.png rename to src/resources/icons/normal_light/blackwhite.png diff --git a/resources/icons/normal_light/colors.png b/src/resources/icons/normal_light/colors.png similarity index 100% rename from resources/icons/normal_light/colors.png rename to src/resources/icons/normal_light/colors.png diff --git a/resources/icons/normal_light/concat.png b/src/resources/icons/normal_light/concat.png similarity index 100% rename from resources/icons/normal_light/concat.png rename to src/resources/icons/normal_light/concat.png diff --git a/resources/icons/normal_light/errors.png b/src/resources/icons/normal_light/errors.png similarity index 100% rename from resources/icons/normal_light/errors.png rename to src/resources/icons/normal_light/errors.png diff --git a/resources/icons/normal_light/eval_expression.png b/src/resources/icons/normal_light/eval_expression.png similarity index 100% rename from resources/icons/normal_light/eval_expression.png rename to src/resources/icons/normal_light/eval_expression.png diff --git a/resources/icons/normal_light/fit.png b/src/resources/icons/normal_light/fit.png similarity index 100% rename from resources/icons/normal_light/fit.png rename to src/resources/icons/normal_light/fit.png diff --git a/resources/icons/normal_light/fit_region.png b/src/resources/icons/normal_light/fit_region.png similarity index 100% rename from resources/icons/normal_light/fit_region.png rename to src/resources/icons/normal_light/fit_region.png diff --git a/resources/icons/normal_light/geteilt_icon.png b/src/resources/icons/normal_light/geteilt_icon.png similarity index 100% rename from resources/icons/normal_light/geteilt_icon.png rename to src/resources/icons/normal_light/geteilt_icon.png diff --git a/resources/icons/normal_light/grid.png b/src/resources/icons/normal_light/grid.png similarity index 100% rename from resources/icons/normal_light/grid.png rename to src/resources/icons/normal_light/grid.png diff --git a/resources/icons/normal_light/imag.png b/src/resources/icons/normal_light/imag.png similarity index 100% rename from resources/icons/normal_light/imag.png rename to src/resources/icons/normal_light/imag.png diff --git a/resources/icons/normal_light/left.png b/src/resources/icons/normal_light/left.png similarity index 100% rename from resources/icons/normal_light/left.png rename to src/resources/icons/normal_light/left.png diff --git a/resources/icons/normal_light/legend.png b/src/resources/icons/normal_light/legend.png similarity index 100% rename from resources/icons/normal_light/legend.png rename to src/resources/icons/normal_light/legend.png diff --git a/resources/icons/normal_light/mal_icon.png b/src/resources/icons/normal_light/mal_icon.png similarity index 100% rename from resources/icons/normal_light/mal_icon.png rename to src/resources/icons/normal_light/mal_icon.png diff --git a/resources/icons/normal_light/mean.png b/src/resources/icons/normal_light/mean.png similarity index 100% rename from resources/icons/normal_light/mean.png rename to src/resources/icons/normal_light/mean.png diff --git a/resources/icons/normal_light/messdings.png b/src/resources/icons/normal_light/messdings.png similarity index 100% rename from resources/icons/normal_light/messdings.png rename to src/resources/icons/normal_light/messdings.png diff --git a/resources/icons/normal_light/minus_icon.png b/src/resources/icons/normal_light/minus_icon.png similarity index 100% rename from resources/icons/normal_light/minus_icon.png rename to src/resources/icons/normal_light/minus_icon.png diff --git a/resources/icons/normal_light/mouse.png b/src/resources/icons/normal_light/mouse.png similarity index 100% rename from resources/icons/normal_light/mouse.png rename to src/resources/icons/normal_light/mouse.png diff --git a/resources/icons/normal_light/new.png b/src/resources/icons/normal_light/new.png similarity index 100% rename from resources/icons/normal_light/new.png rename to src/resources/icons/normal_light/new.png diff --git a/resources/icons/normal_light/normal.png b/src/resources/icons/normal_light/normal.png similarity index 100% rename from resources/icons/normal_light/normal.png rename to src/resources/icons/normal_light/normal.png diff --git a/resources/icons/normal_light/open.png b/src/resources/icons/normal_light/open.png similarity index 100% rename from resources/icons/normal_light/open.png rename to src/resources/icons/normal_light/open.png diff --git a/resources/icons/normal_light/plus.png b/src/resources/icons/normal_light/plus.png similarity index 100% rename from resources/icons/normal_light/plus.png rename to src/resources/icons/normal_light/plus.png diff --git a/resources/icons/normal_light/plus_icon.png b/src/resources/icons/normal_light/plus_icon.png similarity index 100% rename from resources/icons/normal_light/plus_icon.png rename to src/resources/icons/normal_light/plus_icon.png diff --git a/resources/icons/normal_light/points_pick.png b/src/resources/icons/normal_light/points_pick.png similarity index 100% rename from resources/icons/normal_light/points_pick.png rename to src/resources/icons/normal_light/points_pick.png diff --git a/resources/icons/normal_light/real.png b/src/resources/icons/normal_light/real.png similarity index 100% rename from resources/icons/normal_light/real.png rename to src/resources/icons/normal_light/real.png diff --git a/resources/icons/normal_light/right.png b/src/resources/icons/normal_light/right.png similarity index 100% rename from resources/icons/normal_light/right.png rename to src/resources/icons/normal_light/right.png diff --git a/resources/icons/normal_light/save.png b/src/resources/icons/normal_light/save.png similarity index 100% rename from resources/icons/normal_light/save.png rename to src/resources/icons/normal_light/save.png diff --git a/resources/icons/normal_light/save_session.png b/src/resources/icons/normal_light/save_session.png similarity index 100% rename from resources/icons/normal_light/save_session.png rename to src/resources/icons/normal_light/save_session.png diff --git a/resources/icons/normal_light/scaling.png b/src/resources/icons/normal_light/scaling.png similarity index 100% rename from resources/icons/normal_light/scaling.png rename to src/resources/icons/normal_light/scaling.png diff --git a/resources/icons/normal_light/sort.png b/src/resources/icons/normal_light/sort.png similarity index 100% rename from resources/icons/normal_light/sort.png rename to src/resources/icons/normal_light/sort.png diff --git a/resources/icons/normal_light/t1_from_tau.png b/src/resources/icons/normal_light/t1_from_tau.png similarity index 100% rename from resources/icons/normal_light/t1_from_tau.png rename to src/resources/icons/normal_light/t1_from_tau.png diff --git a/resources/icons/normal_light/tau_from_t1.png b/src/resources/icons/normal_light/tau_from_t1.png similarity index 100% rename from resources/icons/normal_light/tau_from_t1.png rename to src/resources/icons/normal_light/tau_from_t1.png diff --git a/resources/icons/normal_light/values.png b/src/resources/icons/normal_light/values.png similarity index 100% rename from resources/icons/normal_light/values.png rename to src/resources/icons/normal_light/values.png diff --git a/resources/icons/normal_light/xlog.png b/src/resources/icons/normal_light/xlog.png similarity index 100% rename from resources/icons/normal_light/xlog.png rename to src/resources/icons/normal_light/xlog.png diff --git a/resources/icons/normal_light/ylog.png b/src/resources/icons/normal_light/ylog.png similarity index 100% rename from resources/icons/normal_light/ylog.png rename to src/resources/icons/normal_light/ylog.png diff --git a/resources/icons/pokemon_light/__init__.py b/src/resources/icons/pokemon_light/__init__.py similarity index 100% rename from resources/icons/pokemon_light/__init__.py rename to src/resources/icons/pokemon_light/__init__.py diff --git a/resources/icons/pokemon_light/blackwhite.png b/src/resources/icons/pokemon_light/blackwhite.png similarity index 100% rename from resources/icons/pokemon_light/blackwhite.png rename to src/resources/icons/pokemon_light/blackwhite.png diff --git a/resources/icons/pokemon_light/colors.png b/src/resources/icons/pokemon_light/colors.png similarity index 100% rename from resources/icons/pokemon_light/colors.png rename to src/resources/icons/pokemon_light/colors.png diff --git a/resources/icons/pokemon_light/concat.png b/src/resources/icons/pokemon_light/concat.png similarity index 100% rename from resources/icons/pokemon_light/concat.png rename to src/resources/icons/pokemon_light/concat.png diff --git a/resources/icons/pokemon_light/errors.png b/src/resources/icons/pokemon_light/errors.png similarity index 100% rename from resources/icons/pokemon_light/errors.png rename to src/resources/icons/pokemon_light/errors.png diff --git a/resources/icons/pokemon_light/eval_expression.png b/src/resources/icons/pokemon_light/eval_expression.png similarity index 100% rename from resources/icons/pokemon_light/eval_expression.png rename to src/resources/icons/pokemon_light/eval_expression.png diff --git a/resources/icons/pokemon_light/fit.png b/src/resources/icons/pokemon_light/fit.png similarity index 100% rename from resources/icons/pokemon_light/fit.png rename to src/resources/icons/pokemon_light/fit.png diff --git a/resources/icons/pokemon_light/fit_region.png b/src/resources/icons/pokemon_light/fit_region.png similarity index 100% rename from resources/icons/pokemon_light/fit_region.png rename to src/resources/icons/pokemon_light/fit_region.png diff --git a/resources/icons/pokemon_light/geteilt_icon.png b/src/resources/icons/pokemon_light/geteilt_icon.png similarity index 100% rename from resources/icons/pokemon_light/geteilt_icon.png rename to src/resources/icons/pokemon_light/geteilt_icon.png diff --git a/resources/icons/pokemon_light/grid.png b/src/resources/icons/pokemon_light/grid.png similarity index 100% rename from resources/icons/pokemon_light/grid.png rename to src/resources/icons/pokemon_light/grid.png diff --git a/resources/icons/pokemon_light/imag.png b/src/resources/icons/pokemon_light/imag.png similarity index 100% rename from resources/icons/pokemon_light/imag.png rename to src/resources/icons/pokemon_light/imag.png diff --git a/resources/icons/pokemon_light/left.png b/src/resources/icons/pokemon_light/left.png similarity index 100% rename from resources/icons/pokemon_light/left.png rename to src/resources/icons/pokemon_light/left.png diff --git a/resources/icons/pokemon_light/legend.png b/src/resources/icons/pokemon_light/legend.png similarity index 100% rename from resources/icons/pokemon_light/legend.png rename to src/resources/icons/pokemon_light/legend.png diff --git a/resources/icons/pokemon_light/mal_icon.png b/src/resources/icons/pokemon_light/mal_icon.png similarity index 100% rename from resources/icons/pokemon_light/mal_icon.png rename to src/resources/icons/pokemon_light/mal_icon.png diff --git a/resources/icons/pokemon_light/mean.png b/src/resources/icons/pokemon_light/mean.png similarity index 100% rename from resources/icons/pokemon_light/mean.png rename to src/resources/icons/pokemon_light/mean.png diff --git a/resources/icons/pokemon_light/messdings.png b/src/resources/icons/pokemon_light/messdings.png similarity index 100% rename from resources/icons/pokemon_light/messdings.png rename to src/resources/icons/pokemon_light/messdings.png diff --git a/resources/icons/pokemon_light/minus_icon.png b/src/resources/icons/pokemon_light/minus_icon.png similarity index 100% rename from resources/icons/pokemon_light/minus_icon.png rename to src/resources/icons/pokemon_light/minus_icon.png diff --git a/resources/icons/pokemon_light/mouse.png b/src/resources/icons/pokemon_light/mouse.png similarity index 100% rename from resources/icons/pokemon_light/mouse.png rename to src/resources/icons/pokemon_light/mouse.png diff --git a/resources/icons/pokemon_light/new.png b/src/resources/icons/pokemon_light/new.png similarity index 100% rename from resources/icons/pokemon_light/new.png rename to src/resources/icons/pokemon_light/new.png diff --git a/resources/icons/pokemon_light/normal.png b/src/resources/icons/pokemon_light/normal.png similarity index 100% rename from resources/icons/pokemon_light/normal.png rename to src/resources/icons/pokemon_light/normal.png diff --git a/resources/icons/pokemon_light/open.png b/src/resources/icons/pokemon_light/open.png similarity index 100% rename from resources/icons/pokemon_light/open.png rename to src/resources/icons/pokemon_light/open.png diff --git a/resources/icons/pokemon_light/plus.png b/src/resources/icons/pokemon_light/plus.png similarity index 100% rename from resources/icons/pokemon_light/plus.png rename to src/resources/icons/pokemon_light/plus.png diff --git a/resources/icons/pokemon_light/plus_icon.png b/src/resources/icons/pokemon_light/plus_icon.png similarity index 100% rename from resources/icons/pokemon_light/plus_icon.png rename to src/resources/icons/pokemon_light/plus_icon.png diff --git a/resources/icons/pokemon_light/points_pick.png b/src/resources/icons/pokemon_light/points_pick.png similarity index 100% rename from resources/icons/pokemon_light/points_pick.png rename to src/resources/icons/pokemon_light/points_pick.png diff --git a/resources/icons/pokemon_light/real.png b/src/resources/icons/pokemon_light/real.png similarity index 100% rename from resources/icons/pokemon_light/real.png rename to src/resources/icons/pokemon_light/real.png diff --git a/resources/icons/pokemon_light/right.png b/src/resources/icons/pokemon_light/right.png similarity index 100% rename from resources/icons/pokemon_light/right.png rename to src/resources/icons/pokemon_light/right.png diff --git a/resources/icons/pokemon_light/save.png b/src/resources/icons/pokemon_light/save.png similarity index 100% rename from resources/icons/pokemon_light/save.png rename to src/resources/icons/pokemon_light/save.png diff --git a/resources/icons/pokemon_light/save_session.png b/src/resources/icons/pokemon_light/save_session.png similarity index 100% rename from resources/icons/pokemon_light/save_session.png rename to src/resources/icons/pokemon_light/save_session.png diff --git a/resources/icons/pokemon_light/scaling.png b/src/resources/icons/pokemon_light/scaling.png similarity index 100% rename from resources/icons/pokemon_light/scaling.png rename to src/resources/icons/pokemon_light/scaling.png diff --git a/resources/icons/pokemon_light/sort.png b/src/resources/icons/pokemon_light/sort.png similarity index 100% rename from resources/icons/pokemon_light/sort.png rename to src/resources/icons/pokemon_light/sort.png diff --git a/resources/icons/pokemon_light/t1_from_tau.png b/src/resources/icons/pokemon_light/t1_from_tau.png similarity index 100% rename from resources/icons/pokemon_light/t1_from_tau.png rename to src/resources/icons/pokemon_light/t1_from_tau.png diff --git a/resources/icons/pokemon_light/tau_from_t1.png b/src/resources/icons/pokemon_light/tau_from_t1.png similarity index 100% rename from resources/icons/pokemon_light/tau_from_t1.png rename to src/resources/icons/pokemon_light/tau_from_t1.png diff --git a/resources/icons/pokemon_light/values.png b/src/resources/icons/pokemon_light/values.png similarity index 100% rename from resources/icons/pokemon_light/values.png rename to src/resources/icons/pokemon_light/values.png diff --git a/resources/icons/pokemon_light/xlog.png b/src/resources/icons/pokemon_light/xlog.png similarity index 100% rename from resources/icons/pokemon_light/xlog.png rename to src/resources/icons/pokemon_light/xlog.png diff --git a/resources/icons/pokemon_light/ylog.png b/src/resources/icons/pokemon_light/ylog.png similarity index 100% rename from resources/icons/pokemon_light/ylog.png rename to src/resources/icons/pokemon_light/ylog.png diff --git a/resources/icons/style.qss b/src/resources/icons/style.qss similarity index 100% rename from resources/icons/style.qss rename to src/resources/icons/style.qss diff --git a/resources/logo.png b/src/resources/logo.png similarity index 100% rename from resources/logo.png rename to src/resources/logo.png diff --git a/resources/nmr/Cole-Cole_min.dat b/src/resources/nmr/Cole-Cole_min.dat similarity index 100% rename from resources/nmr/Cole-Cole_min.dat rename to src/resources/nmr/Cole-Cole_min.dat diff --git a/resources/nmr/Cole-Davidson_min.dat b/src/resources/nmr/Cole-Davidson_min.dat similarity index 100% rename from resources/nmr/Cole-Davidson_min.dat rename to src/resources/nmr/Cole-Davidson_min.dat diff --git a/resources/nmr/KWW_min.dat b/src/resources/nmr/KWW_min.dat similarity index 100% rename from resources/nmr/KWW_min.dat rename to src/resources/nmr/KWW_min.dat diff --git a/resources/nmr/Log-Gaussian_min.dat b/src/resources/nmr/Log-Gaussian_min.dat similarity index 100% rename from resources/nmr/Log-Gaussian_min.dat rename to src/resources/nmr/Log-Gaussian_min.dat diff --git a/resources/nmr/T1_min.npz b/src/resources/nmr/T1_min.npz similarity index 100% rename from resources/nmr/T1_min.npz rename to src/resources/nmr/T1_min.npz diff --git a/src/resources/nmr/__init__.py b/src/resources/nmr/__init__.py new file mode 100644 index 0000000..e69de29