|
@@ -1,78 +1,74 @@
|
|
|
|
|
|
|
|
|
-from functools import lru_cache
|
|
|
-from matplotlib import markers, pyplot as plt
|
|
|
-from scipy.optimize import curve_fit
|
|
|
+from matplotlib import pyplot as plt
|
|
|
import numpy as np
|
|
|
import cma
|
|
|
-
|
|
|
-from numba import njit, float64
|
|
|
-from eval_spectra import spectra
|
|
|
-
|
|
|
-from mealpy.physics_based.EO import AdaptiveEO
|
|
|
-
|
|
|
+from eval_spectra import spectra, params_count as pc
|
|
|
|
|
|
from_disk = np.loadtxt('rs4-d_perp_interpolated.txt')
|
|
|
step = 5
|
|
|
omega_ratio = np.copy(from_disk[0, ::step])
|
|
|
d_rs4 = from_disk[1, ::step] + 1j*from_disk[2, ::step]
|
|
|
|
|
|
-d_rms = d_rs4
|
|
|
-
|
|
|
|
|
|
def rms(x0):
|
|
|
d_fit = spectra(omega_ratio, x0)
|
|
|
diff_re = np.real(d_rms - d_fit)
|
|
|
- rms = np.sqrt(np.sum(np.abs(diff_re)**2))
|
|
|
diff_im = np.imag(d_rms - d_fit)
|
|
|
- rms += np.sqrt(np.sum(np.abs(diff_im)**2))
|
|
|
+
|
|
|
+
|
|
|
+ rms = (np.sum(np.abs(diff_re)**2))
|
|
|
+ rms += (np.sum(np.abs(diff_im)**2))
|
|
|
return rms
|
|
|
|
|
|
|
|
|
-poles = 1
|
|
|
-dim = poles*4
|
|
|
-x0 = np.random.random(dim)
|
|
|
+x0 = np.random.random(pc)
|
|
|
d_rms = d_rs4
|
|
|
-
|
|
|
-x = np.array([0.13421489, 0.82250415, -0.50359304, -0.0591722])
|
|
|
-x1 = x
|
|
|
+x, es = cma.fmin2(rms, x0, sigma0=0.2)
|
|
|
+
|
|
|
+
|
|
|
+x1 = np.copy(x)
|
|
|
+
|
|
|
|
|
|
-x0 = np.random.random(dim)
|
|
|
+x0 = np.random.random(pc)
|
|
|
d_rms = d_rs4 - spectra(omega_ratio, x1)
|
|
|
x, es = cma.fmin2(rms, x0, sigma0=2)
|
|
|
-
|
|
|
-
|
|
|
-x2 = x
|
|
|
+
|
|
|
+
|
|
|
+x2 = np.copy(x)
|
|
|
+
|
|
|
+
|
|
|
+x0 = np.hstack((x1, x2))
|
|
|
+d_rms = d_rs4
|
|
|
+x, es = cma.fmin2(rms, x0, sigma0=0.02)
|
|
|
+
|
|
|
+
|
|
|
+x12 = x
|
|
|
+
|
|
|
+
|
|
|
+x0 = np.random.random(pc)
|
|
|
+d_rms = d_rs4 - spectra(omega_ratio, x12)
|
|
|
+x, es = cma.fmin2(rms, x0, sigma0=0.2)
|
|
|
+
|
|
|
+
|
|
|
+x3 = np.copy(x)
|
|
|
|
|
|
-d_fit = spectra(omega_ratio, x)
|
|
|
|
|
|
+x0 = np.hstack((x1, x2, x3))
|
|
|
+d_rms = d_rs4
|
|
|
+x, es = cma.fmin2(rms, x0, sigma0=0.02)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+x123 = x
|
|
|
+
|
|
|
+
|
|
|
+d_fit = spectra(omega_ratio, x)
|
|
|
plt.figure('rs4')
|
|
|
-
|
|
|
plt.plot(omega_ratio, np.real(d_rms), label='re d')
|
|
|
plt.plot(omega_ratio, np.imag(d_rms), label='im d')
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
plt.plot(omega_ratio, np.real(d_fit), label='re d fit', alpha=0.2, lw=3)
|
|
|
plt.plot(omega_ratio, np.imag(d_fit), label='im d fit', alpha=0.2, lw=3)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+plt.axhline(y=0.0, color='black', linestyle='-', lw=1)
|
|
|
plt.legend()
|
|
|
plt.show()
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|