diff --git a/qpms/qpms_p.py b/qpms/qpms_p.py index 6d3f937..f3d277f 100644 --- a/qpms/qpms_p.py +++ b/qpms/qpms_p.py @@ -740,3 +740,36 @@ def G0_sum_1_slow(source_cart, dest_cart, k, nmax): return G_Mie_scat_precalc_cart(source_cart, dest_cart, RH, RV, a=0.001, nmax=nmax, k_i=1, k_e=k, μ_i=1, μ_e=1, J_ext=1, J_scat=3) +def loadWfile(fileName, lMax = None): + ''' + Load the translation operator lattice sums generated by hexlattice_ewald.c + ''' + nparticles = 2 # TODO generalize + um = 1e-6 # micrometer in SI units + data = np.loadtxt(fileName) + nsamples = data.shape[0] + Wdata = data[:,5:] + if (lMax is None): + nelem = int((Wdata.shape[1]/nparticles**2)**.5/2) + lMax = nelem2lMax(nelem) + else: + nelem = lMax2nelem(lMax) + Ws = Wdata[:,::2] + 1j*Wdata[:,1::2] + # indices: destparticle, srcparticle, wavetype, desty, srcy + Ws.shape = (nsamples, nparticles, nparticles, 2, nelem, nelem) + # maybe TODO copy the following so the original data gets freed to save memory + freqs_weirdunits = data[:,0] + k0s = data[:,2] + ks = data[:,3:4] + freqs = freqs_weirdunits * c / um + return { + 'freqs' : freqs, + 'ks' : ks, + 'k0s' : k0s, + 'Ws' : Ws, + 'freqs_weirdunits' : freqs_weirdunits, + } + + + +