Commit 66bd011a authored by Zolnierczuk, Piotr's avatar Zolnierczuk, Piotr
Browse files

include resources in the distribution

parent 5a4a62b6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ PySEN revision module
"""
import sys
__version__  = "2.1"
__release__  = "b2"
__release__  = "b3"
__date__     = "Mar 31, 2025"

def version(full=False):
+30 −27
Original line number Diff line number Diff line
@@ -3,7 +3,8 @@ Main GUI window module.
"""
import numpy as np
#
from qtpy import QtWidgets, QtCore, QtGui
from qtpy import QtGui
#
from numpy import pi, exp, log10
#
from matplotlib.figure import Figure
@@ -36,21 +37,26 @@ class EchoSimWidget(Ui_EchoSimWidget):
        self.lmin  = self.lmax - wavelength_bandwidth(pos=self.pos)
        self.ntbin = kwargs.pop('ntbin', 42)  # number of TOF bins
        self.tmin, self.tmax = 1e-3, 1e+3
        #print(self.pos, self.lmax, self.lmin, self.ntbin)

        #
        self.setupUi(parent)
        self.lave  = None
        self.dlam  = None
        self.flux  = None
        self.dj    = None
        self.dj2   = None
        self.xt    = None
        self.lines = {}
        #
        self.initUi(parent)

    def setupUi(self, parent=None):
    def initUi(self, parent):
        "init user interface"
        super().setupUi(parent)
        #
        dynamic_canvas = FigureCanvas(Figure(figsize=(5, 3)))
        self.verticalLayout.addWidget(dynamic_canvas)

        #
        self._ax = dynamic_canvas.figure.subplots(1,2)
        self._init_canvas()

        #
        #
        self.inpTauCoh.setValidator(QtGui.QDoubleValidator(1e-6, 1e6, 3))
        self.inpTauInc.setValidator(QtGui.QDoubleValidator(1e-6, 1e6, 3))
@@ -87,25 +93,25 @@ class EchoSimWidget(Ui_EchoSimWidget):
        "tau echo slider handler"
        tau = 10**(value/1000.0)
        self.inpTauCoh.setText(f"{tau:.4g}")
        self.update()
        self.update_canvas()

    def handleTauIncSlider(self, value):
        "tau echo slider handler"
        tau = 10**(value/1000.0)
        self.inpTauInc.setText(f"{tau:.4g}")
        self.update()
        self.update_canvas()


    def handleTauEchoSlider(self, value):
        "tau echo slider handler"
        tau = 10**(value/1000.0)
        self.inpTauEcho.setText(f"{tau:.4g}")
        self.update()
        self.update_canvas()


    def handleInpTauCoh(self):
        "input tau coh handler"
        text   = self.echo.inpTauCoh.text()
        text   = self.inpTauCoh.text()
        slider = int(log10(float(text))*1000)
        self.hSliderTauCoh.setValue(slider)
        self.update_canvas()
@@ -126,7 +132,7 @@ class EchoSimWidget(Ui_EchoSimWidget):

    def handleIntensity(self, _value):
        "intensity changed handler"
        self.update()
        self.update_canvas()


    def _init_canvas(self):
@@ -147,7 +153,7 @@ class EchoSimWidget(Ui_EchoSimWidget):
        self.lines['coh'], = ax.plot(xt, np.zeros_like(xt), 'g--', lw=1, label=r'$f_{coh}$')
        self.lines['inc'], = ax.plot(xt, np.zeros_like(xt), 'b-.', lw=1, label=r'$f_{inc}$')
        self.lines['tau']  = ax.axvline(0,          lw=1.0, ls='-', color='k')
        #self.lines['1/e']  = ax.axhline(exp(-1), lw=0.5, ls='--', color='k')
        self.lines['1/e']  = ax.axhline(exp(-1), lw=0.5, ls='--', color='k')
        ax.set_xscale('log')
        ax.set_xlim(min(xt), max(xt))
        ax.set_xlabel(r'$\tau$ [ns]')
@@ -166,7 +172,7 @@ class EchoSimWidget(Ui_EchoSimWidget):
        ax.grid(True)


    def update(self):
    def update_canvas(self):
        "draw all figures"
        #pylint: disable=too-many-statements
        #FIXME: refactor
@@ -199,7 +205,7 @@ class EchoSimWidget(Ui_EchoSimWidget):
        ax.set_title(rf'FR={fratio:.3g} (U={up:.0f}/D={dn:.0f})')

        ave = (up+dn)/2
        amp = (up-dn)/2*sqt(techo,coh,tcoh,inc,tinc,bgr)/(up-dn)
        amp = (up-dn)/2*sqt(techo,coh,tcoh,inc,tinc,bgr)/abs(up-dn)

        dj   = self.dj
        lave = self.lave
@@ -217,9 +223,9 @@ class EchoSimWidget(Ui_EchoSimWidget):
        self.lines['dn'].set_data(dj/MICRO,dn*np.ones_like(dj))
        self.lines['ave'].set_data(dj/MICRO,ave*np.ones_like(dj))

        bot = min(np.amin(yecho), up, dn)*0.8
        top = max(np.amax(yecho), up, dn)*1.1
        ax.set_ylim(bottom=bot, top=top)
        #bot = min(np.amin(yecho), up, dn)*0.67
        #top = max(np.amax(yecho), up, dn)*1.2
        ax.set_ylim(bottom=None, top=None)

        ysqt = sqt(xt, coh, tcoh, inc, tinc)/(up-dn)
        ycoh = f_exp(xt, tcoh)
@@ -244,12 +250,9 @@ class EchoSimWidget(Ui_EchoSimWidget):
        self.dblSpinBoxCoh.setValue(104)
        self.dblSpinBoxInc.setValue(12)
        self.dblSpinBoxBgr.setValue(0)
        #self.inpTauCoh.setText("100.000")
        #self.inpTauInc.setText("0.010")
        #self.inpTauEcho.setText("1.00")
        self.hSliderTauCoh.setValue( 2000)
        self.hSliderTauInc.setValue(-3000)
        self.hSliderTauEcho.setValue(1)
        #
        self.update()
        self.update_canvas()
#EOF
+14 −1
Original line number Diff line number Diff line
"""
Main GUI window module.
"""
from qtpy import QtWidgets
import os

from qtpy import QtWidgets, QtGui
from matplotlib.backends.backend_qtagg import FigureCanvas #pylint: disable=no-name-in-module
from matplotlib.figure import Figure

@@ -11,6 +13,12 @@ from .EchoSimWidget import EchoSimWidget
#
from ..plot.nseplotlib import plot as default_plot

def get_resource_path(resname):
    "get resource filename"
    path = os.path.join(os.path.dirname(__file__),'resources')
    path = os.path.normpath(path)
    return os.path.join(path, resname)

class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
    """
    Main  for viewing and deleting available groups.
@@ -21,12 +29,17 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
        super().__init__(parent)
        self.kernel_manager = None
        self.initUI()
        QtWidgets.qApp.setWindowIcon(self.icon)


    def initUI(self):
        "setup ui"
        self.setupUi(self)
        self.menuBar.setNativeMenuBar(False)

        self.icon = QtGui.QIcon(get_resource_path("pysen.png"))
        self.setWindowIcon(self.icon)

        # File menu actions
        self.actionOpen.triggered.connect(self.file_open)
        self.actionExit.triggered.connect(self.file_exit)
+1 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@
   </rect>
  </property>
  <property name="windowTitle">
   <string>NSEMainWindow</string>
   <string>NSEPlot</string>
  </property>
  <widget class="QWidget" name="centralWidget">
   <property name="sizePolicy">
+1 −1
Original line number Diff line number Diff line
@@ -24,8 +24,8 @@ def main():

    app = QtWidgets.QApplication([])
    app.setApplicationName('SNS NSE Control')

    main_window = MainWindow()
    app.setWindowIcon(main_window.icon)

    main_window.show()
    app.exec_()
Loading