def GetFr(sweepdata_folder, sweepdata_file, IQCalibrationfile, IQReffolder, IQReffilename): ### Read IQ Sweep data freq, I, Q = reader.ReadSweep(sweepdata_folder, sweepdata_file) ### Get IQ Mixer calibration data for sweep data frequency paras = IQ.IQ_GetPara(IQCalibrationfile, int(round(freq[len(freq)/2]/1e6))) ### Calibrate IQ Sweep data I_mixercalibrated, Q_mixercalibrated = IQ.IQ_CorrtBarends(paras,I,Q) ### Normalize calibrated IQ Sweep data to IQ reference data ### Get complex IQ IQ_normalized = IQ.IQ_Normalize_Sweep(freq, I_mixercalibrated, Q_mixercalibrated, IQReffolder, IQReffilename) x_c, x_c_err, y_c, y_c_err, radius, radius_err, circle_fit_report, theta0, theta0_err, fr, fr_err, Qr, Qr_err, Qc, Qc_err, Qi, Qi_err, fit_report_phase = Fit_IQ_Sweep(freq, IQ_normalized) return int(round(fr))
meastime = len(number) / float(fsample) # Get IQ Mixer calibration parameter resfreqinMHz = int(round(sweepfreq[len(sweepfreq) / 2] / 1e6)) paras = IQ.IQ_GetPara(IQCalibrationfile, resfreqinMHz) # Calibrate IQ data I_mixercalibrated, Q_mixercalibrated = IQ.IQ_CorrtBarends( paras, sweepI, sweepQ) noiseI_mixercalibrated, noiseQ_mixercalibrated = IQ.IQ_CorrtBarends( paras, noiseI, noiseQ) # Normalize calibrated IQ Sweep data to IQ reference data # Get complex IQ sweepIQ_normalized = IQ.IQ_Normalize_Sweep(sweepfreq, I_mixercalibrated, Q_mixercalibrated, IQReffolder, IQReffilename) noiseIQ_normalized = IQ.IQ_Normalize_Noise(resfreq, noiseI_mixercalibrated, noiseQ_mixercalibrated, IQReffolder, IQReffilename) # Fit circle and phase x_c, x_c_err, y_c, y_c_err, radius, radius_err, circle_fit_report, theta0, theta0_err, fr, fr_err, Qr, Qr_err, Qc, Qc_err, Qi, Qi_err, fit_report_phase = FitSingle.Fit_IQ_Sweep( sweepfreq, sweepIQ_normalized) # Move sweep center to origin sweepIQcenter = sweepIQ_normalized - (x_c + 1j * y_c) noiseIQcenter = noiseIQ_normalized - (x_c + 1j * y_c) # Find cloest data point to fitted resonance frequency and calculate angle idx = FitSingle.find_nearest(sweepfreq, fr)