def plotFreq(): data = readJson("out.json") fig, ax = plt.subplots() Q = data['Q'] freqDelta = 10 freqCenter = 1000 count = 201 (freqArr, Fmath) = sm.arrayFreq(Q, freqCenter-freqDelta, freqCenter+freqDelta, sm.STEP, count) fmax = sm.findFreqMax(freqArr, Fmath) print("fmax=", fmax) ax.plot (freqArr, Fmath, color='blue') plt.show()
def scanFreq(): freq = getFreq() IArray = [] QArray = [] FIarray = [] fsin = [] for f in freq: print("f=", f) (ISampes, QSampes) = getSamplesByFreq(f) I = sqrMean(ISampes) Q = sqrMean(QSampes) print("getSqrByFreq=", I, Q) IArray.append(I) QArray.append(Q) # freqDelta = 1 # freqCenter = 1000 freqDelta = 0.5 freqCenter = 999.6 count = 101 (freqArr, Fmath) = sm.arrayFreq(QSampes, freqCenter - freqDelta, freqCenter + freqDelta, sm.STEP, count) fmax = sm.findFreqMax(freqArr, Fmath) fsin.append(fmax) (Ic0, Isin, Icos) = sm.calcSinCosMatrix(ISampes, fmax, sm.STEP) (Qc0, Qsin, Qcos) = sm.calcSinCosMatrix(QSampes, fmax, sm.STEP) (Iamplitude, Ifi) = sm.calcFi(Isin, Icos) (Qamplitude, Qfi) = sm.calcFi(Qsin, Qcos) FIarray.append(Ifi - Qfi) print("fmax=", fmax, "fi=", Ifi - Qfi) pass jout = {} jout["freq"] = freq jout["I"] = IArray jout["Q"] = QArray jout["fsin"] = fsin jout["fi"] = FIarray f = open("freq.json", "wt") f.write(json.dumps(jout)) f.close() pass