123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- from scattnlay import scattcoeffs
- import numpy as np
- import example
- size = np.arange(0.25, 100.25, 0.25)
- x = np.ones((len(size), 5), dtype = np.float64)
- x[:, 0] = 0.1**(1.0/3.0)*size
- x[:, 1] = 0.36**(1.0/3.0)*size
- x[:, 2] = 0.404**(1.0/3.0)*size
- x[:, 3] = 0.7706**(1.0/3.0)*size
- x[:, 4] = size
- m = np.ones((len(size), 5), dtype = np.complex128)
- m[:, 0] *= 1.8 + 1.7j
- m[:, 1] *= 0.8 + 0.7j
- m[:, 2] *= 1.2 + 0.09j
- m[:, 3] *= 2.8 + 0.2j
- m[:, 4] *= 1.5 + 0.4j
- terms, an, bn = scattcoeffs(x, m, 105)
- terms1, an1, bn1 = example.scattcoeffs(x[0,:], m[0,:], nmax=10)
- print(an1[:3], bn1[:3])
- print(terms1)
- result = np.vstack((x[:, 4], an[:, 0].real, an[:, 0].imag, an[:, 1].real, an[:, 1].imag, an[:, 2].real, an[:, 2].imag,
- bn[:, 0].real, bn[:, 0].imag, bn[:, 1].real, bn[:, 1].imag, bn[:, 2].real, bn[:, 2].imag)).transpose()
- try:
- import matplotlib.pyplot as plt
- plt.figure(1)
- for i in range(3):
- plt.subplot(310 + i + 1)
- plt.plot(x[:, 4], an[:, i].real, label = "Re(a$_%i$)" % (i + 1))
- plt.plot(x[:, 4], bn[:, i].real, label = "Re(b$_%i$)" % (i + 1))
- plt.plot(x[:, 4], an[:, i].imag, label = "Im(a$_%i$)" % (i + 1))
- plt.plot(x[:, 4], bn[:, i].imag, label = "Im(b$_%i$)" % (i + 1))
- plt.ylabel('n = %i' % (i + 1))
- plt.legend()
- plt.xlabel('X')
-
- plt.show()
- finally:
- np.savetxt("scattcoeffs.txt", result, fmt = "%.5f")
- print( result[0,:])
|