From bca248e6d5894144f0bb509b07d1ed6a3a317617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Thu, 7 Feb 2019 00:36:59 +0200 Subject: [PATCH] More variable choice of k in loaded W files Former-commit-id: a2f88f9346c23e22e5c1203416ce11a3a7db71a8 --- qpms/qpms_p.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/qpms/qpms_p.py b/qpms/qpms_p.py index 4fab6b9..56fb896 100644 --- a/qpms/qpms_p.py +++ b/qpms/qpms_p.py @@ -897,10 +897,12 @@ def loadWfile_info(fileName, lMax = None, midk_halfwidth = None, freqlimits = No slovnik['Ws'] = None return slovnik -def loadWfile_processed(fileName, lMax = None, fatForm = True, midk_halfwidth = None, freqlimits = None, iteratechunk = None): +def loadWfile_processed(fileName, lMax = None, fatForm = True, midk_halfwidth = None, midk_index = None, freqlimits = None, iteratechunk = None): """ midk_halfwidth: int if given, takes only the "middle" k-value by index nk//2 and midk_halfwidth values from both sides + midk_index: int + if given, midk_index is taken as the "middle" value instad of nk//2 freqlimit: pair of doubles; if given, only the values from the given frequency range (in Hz) are returned to save RAM N.B.: the frequencies in the processed file are expected to be sorted! @@ -931,13 +933,13 @@ def loadWfile_processed(fileName, lMax = None, fatForm = True, midk_halfwidth = EeVs_orig = data['EeVs_orig'] freqs_weirdunits = data['freqs_weirdunits'] if midk_halfwidth is not None: - k_mid_i = nk // 2 - if midk_halfwidth < k_mid_i: - maxk_i = k_mid_i + midk_halfwidth - mink_i = k_mid_i - midk_halfwidth - nk = 2*midk_halfwidth+1 - Ws = Ws[:,mink_i:(maxk_i+1)] - ks = ks[mink_i:(maxk_i+1)] + k_mid_i = nk // 2 if midk_index is None else midk_index + maxk_i = min(k_mid_i + midk_halfwidth, nk) + mink_i = max(0, k_mid_i - midk_halfwidth) + nk = maxk_i + 1 - mink_i + Ws = Ws[:,mink_i:(maxk_i+1)] + ks = ks[mink_i:(maxk_i+1)] + #k_mid_i_new = k_mid_i - mink_i if lMax is not None: nelem = lMax2nelem(lMax) Ws = Ws[...,:nelem,:nelem]