add comments for my understanding
This commit is contained in:
parent
575cb5e8f6
commit
4b6820af18
@ -503,11 +503,25 @@ class UpperManagement(QtCore.QObject):
|
|||||||
we = we_option
|
we = we_option
|
||||||
|
|
||||||
if m_complex is None or m_complex == 1:
|
if m_complex is None or m_complex == 1:
|
||||||
|
# model is not complex: m_complex = None
|
||||||
|
# model is complex, fit real part: m_complex = 1
|
||||||
_y = data_i.y.real
|
_y = data_i.y.real
|
||||||
elif m_complex == 2 and np.iscomplexobj(data_i.y):
|
data_complex = 1
|
||||||
_y = data_i.y.imag
|
elif m_complex == 2:
|
||||||
|
# model is complex, fit imag part: m_complex = 2
|
||||||
|
if np.iscomplexobj(data_i.y):
|
||||||
|
# data is complex, use imag part
|
||||||
|
_y = data_i.y.imag
|
||||||
|
data_complex = 2
|
||||||
|
else:
|
||||||
|
# data is real
|
||||||
|
_y = data_i.y
|
||||||
|
data_complex = 1
|
||||||
else:
|
else:
|
||||||
|
# model is complex, fit complex: m_complex = 0
|
||||||
|
# use data as given (complex or not)
|
||||||
_y = data_i.y
|
_y = data_i.y
|
||||||
|
data_complex = 0
|
||||||
|
|
||||||
_x = data_i.x
|
_x = data_i.x
|
||||||
|
|
||||||
@ -521,9 +535,9 @@ class UpperManagement(QtCore.QObject):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if isinstance(we, str):
|
if isinstance(we, str):
|
||||||
d = fit_d.Data(_x[inside], _y[inside], we=we, idx=set_id)
|
d = fit_d.Data(_x[inside], _y[inside], we=we, idx=set_id, complex_type=data_complex)
|
||||||
else:
|
else:
|
||||||
d = fit_d.Data(_x[inside], _y[inside], we=we[inside], idx=set_id)
|
d = fit_d.Data(_x[inside], _y[inside], we=we[inside], idx=set_id, complex_type=data_complex)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise Exception(f'Setting data failed for {set_id}')
|
raise Exception(f'Setting data failed for {set_id}')
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ from .model import Model
|
|||||||
from .parameter import Parameters, Parameter
|
from .parameter import Parameters, Parameter
|
||||||
|
|
||||||
|
|
||||||
class Data(object):
|
class Data:
|
||||||
def __init__(self, x, y, we=None, idx=None):
|
def __init__(self, x, y, we=None, idx=None, complex_type: int = 0):
|
||||||
self.x = np.asarray(x)
|
self.x = np.asarray(x)
|
||||||
self.y = np.asarray(y)
|
self.y = np.asarray(y)
|
||||||
if self.y.shape[0] != self.x.shape[0]:
|
if self.y.shape[0] != self.x.shape[0]:
|
||||||
@ -20,6 +20,7 @@ class Data(object):
|
|||||||
self.parameter = Parameters()
|
self.parameter = Parameters()
|
||||||
self.para_keys: list = []
|
self.para_keys: list = []
|
||||||
self.fun_kwargs = {}
|
self.fun_kwargs = {}
|
||||||
|
self.complex_type = complex_type
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return self.y.shape[0]
|
return self.y.shape[0]
|
||||||
|
@ -54,6 +54,7 @@ class FitResultCreator:
|
|||||||
nvar: int,
|
nvar: int,
|
||||||
corr: np.ndarray,
|
corr: np.ndarray,
|
||||||
pcorr: np.ndarray,
|
pcorr: np.ndarray,
|
||||||
|
data_mode: int = 1,
|
||||||
) -> FitResult:
|
) -> FitResult:
|
||||||
if np.all(x_orig > 0) and (np.max(x_orig) > 100 * np.min(x_orig)):
|
if np.all(x_orig > 0) and (np.max(x_orig) > 100 * np.min(x_orig)):
|
||||||
islog = True
|
islog = True
|
||||||
@ -87,9 +88,12 @@ class FitResultCreator:
|
|||||||
|
|
||||||
if not actual_mode < 0:
|
if not actual_mode < 0:
|
||||||
if actual_mode == 1:
|
if actual_mode == 1:
|
||||||
_y.imag = 0
|
_Y = _y.real
|
||||||
|
# _y.imag = 0
|
||||||
elif actual_mode == 2:
|
elif actual_mode == 2:
|
||||||
_y.real = 0
|
# if data_mode ==
|
||||||
|
_y = _y.imag
|
||||||
|
# _y.real = 0
|
||||||
|
|
||||||
fun_kwargs['complex_mode'] = actual_mode
|
fun_kwargs['complex_mode'] = actual_mode
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user