Compare commits

..

40 Commits
master ... dev

Author SHA1 Message Date
9c56171524 Merge branch 'master' into dev 2024-11-14 17:20:04 +00:00
Dominik Demuth
6980df1599 import future for type hints 2024-11-14 18:06:06 +01:00
Dominik Demuth
f6b7ebec07 selecting x value as label for point selection should work 2024-10-22 18:54:44 +02:00
Dominik Demuth
8d1ccd22fa change ptstab widgets 2024-10-21 19:52:23 +02:00
Dominik Demuth
0b52fef549 additional parameter for weight factor for increase or decrease 2024-10-16 17:32:20 +02:00
Dominik Demuth
b6b98d292a clicking outside axes no longer emits signal 2024-10-13 18:29:04 +02:00
Dominik Demuth
d90959c6b6 fix typo 2024-10-13 17:28:59 +02:00
Dominik Demuth
e459bd5e54 Merge branch 'master' into dev 2024-10-13 17:21:26 +02:00
24f20f8850 Merge branch 'master' into dev 2024-09-29 17:21:14 +00:00
Dominik Demuth
fc91bf83fe Merge branch 'script-editor' into dev 2024-09-29 19:19:15 +02:00
Dominik Demuth
86f285fba5 randomize 2024-09-29 19:13:26 +02:00
Dominik Demuth
fa84b0382e select type/generation and sorting enabled did not go well together 2024-09-29 16:03:13 +02:00
Dominik Demuth
4b75aa9267 add disclaimer 2024-09-29 15:50:50 +02:00
Dominik Demuth
f185b24967 fix problem with namespaces 2024-09-29 14:33:28 +02:00
Dominik Demuth
d07b85ae27 mvp for script runner 2024-09-26 18:39:55 +02:00
Dominik Demuth
7ad1e4b843 use of properties did not work properly 2024-09-25 18:09:10 +02:00
Dominik Demuth
ff2ff01da7 update internal fit infos after function removal 2024-09-25 17:21:46 +02:00
Dominik Demuth
d9f1c0b8c2 use correct attribute name 2024-09-25 17:20:20 +02:00
Dominik Demuth
9039c44ce7 Merge remote-tracking branch 'origin/dev' into dev 2024-09-23 16:41:19 +02:00
Dominik Demuth
ac6b734f81 only skip points if wanted 2024-09-23 16:38:28 +02:00
9babb73f3a Merge branch 'master' into dev 2024-09-11 15:32:53 +00:00
Dominik Demuth
4f0a7827ba Add standard deviation to averaging methods of pick points 2024-09-11 17:31:58 +02:00
Dominik Demuth
05862730a0 Merge branch 'gga_relaxation' into dev 2024-09-07 19:22:05 +02:00
Dominik Demuth
7fe89eff7f Merge remote-tracking branch 'origin/gga_relaxation' into gga_relaxation 2024-09-07 19:21:01 +02:00
Dominik Demuth
f94f78893c add basic Generalized Gamma for alpha relaxation 2024-09-07 19:20:32 +02:00
Dominik Demuth
fda3257424 plot sub-functions; fixes #282 2024-09-07 19:19:02 +02:00
Dominik Demuth
f30ff3b758 Merge remote-tracking branch 'origin/master' into gga_relaxation 2024-09-05 18:16:27 +02:00
7b61c1244d Merge branch 'master' into dev 2024-07-16 17:00:27 +00:00
Dominik Demuth
e0c287d8a9 plot sub-functions; fixes #282 2024-07-16 18:58:31 +02:00
Dominik Demuth
a8fcd658d9 set fit toolbar a name; fixes #281 2024-07-15 17:42:28 +02:00
Dominik Demuth
dd471ae294 Merge branch 'refs/heads/267-cut-y-range' into dev 2024-06-24 17:55:48 +02:00
Dominik Demuth
ab586ac39a Merge branch 'refs/heads/256-fc-persistence' into dev
# Conflicts:
#	src/gui_qt/main/mainwindow.py
2024-06-24 17:55:13 +02:00
Dominik Demuth
b355aab99d Merge remote-tracking branch 'refs/remotes/origin/255-persisitence-interpolation-dialog' into dev 2024-06-24 17:54:24 +02:00
Dominik Demuth
03cdc225ca add sinc function 2024-06-24 17:53:45 +02:00
Dominik Demuth
e87c6bf2c1 retain settings in interpolation dialog 2024-05-27 18:05:43 +02:00
Dominik Demuth
cc7572fe14 retain settings in FC reader dialog 2024-05-15 17:15:09 +02:00
Dominik Demuth
ef66cf584a increase precision 2024-05-06 18:52:20 +02:00
Dominik Demuth
f0448fac0f cut data at x and y 2024-05-06 18:46:27 +02:00
Dominik Demuth
749a78b550 add to clib 2024-01-13 16:21:19 +01:00
Dominik Demuth
50a811b7ec calculate t1 for generalized gamma 2024-01-09 14:20:20 +01:00
2 changed files with 43 additions and 81 deletions

View File

@ -542,9 +542,7 @@ class UpperManagement(QtCore.QObject):
elif fit_limits[0] == 'in':
inside = np.where((_x >= fit_limits[1][0]) & (_x <= fit_limits[1][1]))
else:
x_lim, _ = self.graphs[self.current_graph].ranges
inside_graph = (_x >= x_lim[0]) & (_x <= x_lim[1])
inside = np.where(((_x < fit_limits[1][0]) | (_x > fit_limits[1][1])) & inside_graph)
inside = np.where((_x < fit_limits[1][0]) | (_x > fit_limits[1][1]))
try:
if isinstance(we, str):

View File

@ -3,42 +3,11 @@ try:
from scipy.integrate import simpson
except ImportError:
from scipy.integrate import simps as simpson
from numpy import pi
from ..math.orientations import zcw_spherical as crystallites
__all__ = ['CSA', 'Pake', 'SecCentralLine']
def _make_broadening(x: np.ndarray, sigma: float, mode: str):
dx = x[1] - x[0]
_x = np.arange(len(x)) * dx
_x -= 0.5 * _x[-1]
if mode == 'l':
apd = 2 * sigma / (4*_x**2 + sigma**2) / np.pi
else:
ln2 = np.log(2)
apd = np.exp(-4*ln2 * (_x/sigma)**2) * 2 * np.sqrt(ln2/np.pi) / sigma
return apd
def _make_bins(x: np.ndarray) -> np.ndarray:
bins = 0.5 * (x[1:] + x[:-1])
return np.r_[0.5 * (-x[1] + 3 * x[0]), bins, 0.5 * (3 * x[-1] - x[-2])]
def _make_x(x: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
_x = x
dx = x[1:] - x[:-1]
dx = np.min(dx)
width = x[-1] - x[0]
_x = np.arange(width/dx - 1) * dx + x[0]
bins = (_x[1:] + _x[:-1]) / 2
bins = np.r_[_x[0]-dx/2, bins, _x[-1] + dx/2]
return _x, bins
class Pake:
type = 'Spectrum'
name = 'Pake'
@ -48,39 +17,38 @@ class Pake:
choices = [('Broadening', 'broad', {'Gaussian': 'g', 'Lorentzian': 'l'})]
@staticmethod
def func(
x: np.ndarray,
c: float,
delta: float,
eta: float,
sigma: float,
t_pulse: float,
broad: str = 'g',
) -> np.ndarray:
def func(x, c, delta, eta, sigma, t_pulse, broad='g'):
a, b, _ = crystallites(100000)
bins = 0.5 * (x[1:] + x[:-1])
bins = np.r_[0.5*(3*x[0]-x[1]), bins, 0.5*(3*x[-1]-x[-2])]
omega = delta * 0.5 * (3*np.cos(b)**2 - 1 - eta * np.sin(b)**2 * np.cos(2*a))
x_used, bins = _make_x(x)
s_left = np.histogram(omega, bins=bins)[0]
s_right = np.histogram(-omega, bins=bins)[0]
s = s_left + s_right
if sigma != 0:
apd = _make_broadening(x_used, sigma, broad)
_x = np.arange(len(x))*(x[1]-x[0])
_x -= 0.5*_x[-1]
if broad == 'l':
apd = 2 * sigma / (4 * _x**2 + sigma**2) / pi
else:
apd = np.exp(-4 * np.log(2) * (_x/sigma)**2) * 2 * np.sqrt(np.log(2) / pi) / sigma
ret_val = np.convolve(s, apd, mode='same')
else:
ret_val = s
omega_1 = np.pi/2/t_pulse
attn = omega_1 * np.sin(t_pulse*np.sqrt(omega_1**2 + 0.5*(2*np.pi*x_used)**2)) / np.sqrt(omega_1**2 + (np.pi*x_used)**2)
omega_1 = pi/2/t_pulse
attn = omega_1 * np.sin(t_pulse*np.sqrt(omega_1**2+0.5*(2*pi*x)**2)) / \
np.sqrt(omega_1**2+(np.pi*x)**2)
ret_val *= attn
ret_val /= simpson(y=ret_val, x=x_used)
if x_used.size == x.size:
return c * ret_val
else:
return c * np.interp(x=x, xp=x_used, fp=ret_val)
return c * ret_val / simpson(ret_val, x)
class CSA:
@ -92,29 +60,28 @@ class CSA:
choices = [('Broadening', 'broad', {'Gaussian': 'g', 'Lorentzian': 'l'})]
@staticmethod
def func(
x: np.ndarray,
c: float,
delta: float,
eta: float,
w_iso: float,
sigma: float,
broad: str = 'g',
) -> np.ndarray:
def func(x, c, delta, eta, w_iso, sigma, broad='g'):
a, b, _ = crystallites(100000)
bins = 0.5 * (x[1:] + x[:-1])
bins = np.r_[0.5*(-x[1] + 3*x[0]), bins, 0.5*(3*x[-1] - x[-2])]
omega = w_iso + delta * 0.5 * (3*np.cos(b)**2 - 1 - eta * np.sin(b)**2 * np.cos(2*a))
s = np.histogram(omega, bins=_make_bins(x))[0]
s_left = np.histogram(omega, bins=bins)[0]
s = s_left
if sigma != 0:
print(len(s))
apd = _make_broadening(x, sigma, broad)
_x = np.arange(len(x)) * (x[1] - x[0])
_x -= 0.5 * _x[-1]
if broad == 'l':
apd = 2 * sigma / (4*_x**2 + sigma**2) / pi
else:
apd = np.exp(-4 * np.log(2) * (_x / sigma) ** 2) * 2 * np.sqrt(np.log(2) / pi) / sigma
ret_val = np.convolve(s, apd, mode='same')
else:
ret_val = s
return c * ret_val / simpson(y=ret_val, x=x)
return c * ret_val / simpson(ret_val, x)
class SecCentralLine:
@ -127,18 +94,10 @@ class SecCentralLine:
('Broadening', 'broad', {'Gaussian': 'g', 'Lorentzian': 'l'})]
@staticmethod
def func(
x: np.ndarray,
c: float,
cq: float,
eta: float,
f_iso: float,
gb: float,
f_l: float,
spin: float = 2.5,
broad: str = 'g',
) -> np.ndarray:
def func(x, c, cq, eta, f_iso, gb, f_l, spin=2.5, broad='g'):
a, b, _ = crystallites(200000)
bins = 0.5 * (x[1:] + x[:-1])
bins = np.r_[0.5*(-x[1] + 3*x[0]), bins, 0.5*(3*x[-1] - x[-2])]
# coupling constant
omega_q = 2 * np.pi * cq / (2*spin*(2*spin-1))
@ -157,12 +116,17 @@ class SecCentralLine:
orient += prefactor_c
omega = 2*np.pi*f_iso + coupling * orient
s = np.histogram(omega / (2*np.pi), bins=_make_bins(x))[0]
s = np.histogram(omega / (2*np.pi), bins=bins)[0]
if gb != 0:
apd = _make_broadening(x, gb, broad)
_x = np.arange(len(x)) * (x[1]-x[0])
_x -= 0.5*_x[-1]
if broad == 'l':
apd = 2*gb / (4*_x**2 + gb**2) / np.pi
else:
apd = np.exp(-4*np.log(2) * (_x/gb)**2) * 2 * np.sqrt(np.log(2)/np.pi) / gb
ret_val = np.convolve(s, apd, mode='same')
else:
ret_val = s
return c * ret_val / simpson(y=ret_val, x=x)
return c * ret_val / simpson(ret_val, x)