From 408685c6064aad4af37a0b4d91b1f8876d7ae3bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Tue, 9 Oct 2018 10:13:38 +0300 Subject: [PATCH] Enable processing one-line (single K) Wfiles; plots for hexlaser supplementary Former-commit-id: 0f4027ecc7bcb7780c04fdd13bd7144eb7a1d3e9 --- qpms/qpms_p.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/qpms/qpms_p.py b/qpms/qpms_p.py index 3237c08..6abb789 100644 --- a/qpms/qpms_p.py +++ b/qpms/qpms_p.py @@ -805,15 +805,18 @@ def processWfiles_sameKs(freqfilenames, destfilename, lMax = None, f='npz'): #Check the first file to get the "constants" set filename = freqfilenames[0] data = np.loadtxt(filename) + if len(data.shape) == 1: + data = np.reshape(data, (1,) + data.shape) nk_muster = data.shape[0] - Wdata = data[:,5:] + Wdata = data[...,5:] + if (lMax is None): nelem = int((Wdata.shape[1]/nparticles**2)**.5/2) lMax = nelem2lMax(nelem) else: nelem = lMax2nelem(lMax) - ks_muster = np.array(data[:,3:5], copy=True) - + ks_muster = np.array(data[...,3:5], copy=True) + if f == 'npz': allWs = np.empty((nfiles, nk_muster, nparticles, nparticles, 2, nelem, nelem,), dtype=complex) elif f == 'd': @@ -832,13 +835,15 @@ def processWfiles_sameKs(freqfilenames, destfilename, lMax = None, f='npz'): for filename in freqfilenames: data = np.loadtxt(filename) + if len(data.shape) == 1: + data = np.reshape(data, (1,) + data.shape) if data.shape[0] != nk_muster: raise ValueError("%s contains different number of lines than %s"%(filename, freqfilenames[0])) ks_current = np.array(data[:,3:5]) if not np.all(ks_current == ks_muster): raise ValueError("%s contains different k-vectors than %s"%(filename, freqfilenames[0])) - curWdata = data[:,5:] - curWs = curWdata[:,::2] + 1j*curWdata[:,1::2] + curWdata = data[...,5:] + curWs = curWdata[...,::2] + 1j*curWdata[...,1::2] curWs.shape = (nk_muster, nparticles, nparticles, 2, nelem, nelem) allWs[succread] = curWs cur_freqs_weirdunits = np.array(data[:,0])