def char_cwsweep_trackdata(): ifluxbias = request.args.get('ifluxbias') ixyfreq = request.args.get('ixyfreq') ixypowa = request.args.get('ixypowa') # list data position in file: try: data_location = {} data_location['fluxbias'] = gotocdata([ session['c_cwsweep_structure'][0] - 1, int(ifluxbias), 0, 0, 0, 0, 0, 0 ], session['c_cwsweep_structure']) data_location['xyfreq'] = gotocdata([ session['c_cwsweep_structure'][0] - 1, session['c_cwsweep_structure'][1] - 1, int(ixyfreq), 0, 0, 0, 0, 0 ], session['c_cwsweep_structure']) data_location['xypowa'] = gotocdata([ session['c_cwsweep_structure'][0] - 1, session['c_cwsweep_structure'][1] - 1, session['c_cwsweep_structure'][0] - 1, int(ixypowa), 0, 0, 0, 0 ], session['c_cwsweep_structure']) except (ValueError): print(Back.RED + Fore.WHITE + "All parameters must be FIXED!") pass return jsonify(data_location=data_location)
def assembler_xyfreq_fluxbias(args): (y, x) = args I, Q = 0, 0 for i_prepeat in range(powa_repeat): r_powa = int( ipowa ) * powa_repeat + i_prepeat # from the beginning position of repeating power I += selectedata[gotocdata([ int(irepeat), x, y, int(ixypowa), int(isparam), int(iifb), int(ifreq), 2 * r_powa ], c_cwsweep_structure)] Q += selectedata[gotocdata([ int(irepeat), x, y, int(ixypowa), int(isparam), int(iifb), int(ifreq), 2 * r_powa + 1 ], c_cwsweep_structure)] I /= powa_repeat Q /= powa_repeat Amp, P = IQAP(I, Q) return I, Q, Amp, P
def f(args): # (x,y) = args I = A[gotocdata([args[0], 0, 0, 0, 2 * args[1]], [10000, 1, 1, 1, 1000 * 2])] Q = A[gotocdata([args[0], 0, 0, 0, 2 * args[1] + 1], [10000, 1, 1, 1, 1000 * 2])] Amp, P = IQAP(I, Q) return I, Q, Amp, P
def assembler_freq_powa(args): (y, x) = args I = selectedata[gotocdata( [int(ifluxbias), int(isparam), int(iifb), x, 2 * y], c_fresp_structure)] Q = selectedata[gotocdata( [int(ifluxbias), int(isparam), int(iifb), x, 2 * y + 1], c_fresp_structure)] Amp, P = IQAP(I, Q) return I, Q, Amp, P
def g(a): A = list(range(200000000)) B = [ A[gotocdata([x, 0, 0, 0, a], [20000, 1, 1, 1, 10000])] for x in range(20000) ] return B
caddress = '[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,t]' #bare # caddress = '[0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,t]' #dressed # replacing x-variable: caddress = caddress[:2 * CStructure.index(X[X_option]) + 1] + 'i' + caddress[2 * CStructure.index(X[X_option]) + 2:] # replacing c-constant: caddress = caddress[:2 * CStructure.index(C[C_option]) + 1] + C_index + caddress[2 * CStructure.index(C[C_option]) + 2:] print("C-Address: %s" % (caddress)) # Sweep first curve to decide: IQdata = array([ alldata[gotocdata([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, x], cstructure)] for x in timesweep ]) I, Q, Amp, Pha = IQAParray(IQdata) A = [sqrt(i**2 + q**2) for (i, q) in zip(I, Q)] # slower iteration # select which range you need from the curve: curve(range(len(I)), I, 'Pick the start-end point:', '#', 'A(V)') curve(range(len(Q)), Q, 'Pick the start-end point:', '#', 'A(V)') curve(range(len(A)), A, 'Pick the start-end point:', '#', 'A(V)') # assemble the analytics startpoint = int(input("Reading the measured pulse from: ")) endpoint = int(input("Reading the measured pulse until: ")) firstpoint = int(input('Total %s points, plot from: ' % len(xdata))) lastpoint = int(input('Total %s points, plot until: ' % len(xdata))) # Start post-averaging:
def assembler(args): (y,x) = args selected_caddress = [s for s in cselect.values()] # Sweep-command: if k == 'repeat': selected_sweep = cmd_repeat[session['user_name']] else: selected_sweep = M_sqepulse[session['user_name']].corder[k] # Adjusting c-parameters range for data analysis based on progress: parent_address = selected_caddress[:CParameters['SQE_Pulse'].index(k)] # address's part before x if [int(s) for s in parent_address] < session['c_sqepulse_progress'][0:len(parent_address)]: print(Fore.YELLOW + "selection is well within progress") sweepables = session['c_sqepulse_structure'][CParameters['SQE_Pulse'].index(k)] else: sweepables = session['c_sqepulse_progress'][CParameters['SQE_Pulse'].index(k)]+1 # Special treatment on the last 'buffer' parameter to factor out the data-density first: if CParameters['SQE_Pulse'].index(k) == len(CParameters['SQE_Pulse'])-1 : isweep = range(sweepables//M_sqepulse[session['user_name']].datadensity) else: isweep = range(sweepables) # flexible access until progress resume-point print(Back.WHITE + Fore.BLACK + "Sweeping %s points" %len(isweep)) Idata = zeros(len(isweep)) Qdata = zeros(len(isweep)) for i in isweep: selected_caddress[CParameters['SQE_Pulse'].index(k)] = i # register x-th position if [c for c in cselect.values()][-1] == "s": # sampling mode currently limited to time-range (last 'basic' parameter) only srange = request.args.get('srange').split("-") # sample range if [int(srange[1]) , int(srange[0])] > [session['c_sqepulse_structure'][-1]//M_sqepulse[session['user_name']].datadensity] * 2: print(Back.WHITE + Fore.RED + "Out of range") else: # FASTEST PARALLEL VECTORIZATION OF BIG DATA BY NUMPY: slength = int(srange[1]) - int(srange[0]) + 1 # Assemble stacks of selected c-address for this sample range: selected_caddress_I = array([[int(s) for s in selected_caddress[:-1]] + [0]] * slength) selected_caddress_Q = array([[int(s) for s in selected_caddress[:-1]] + [0]] * slength) # sort-out interleaved IQ: selected_caddress_I[:,-1] = 2 * array(range(int(srange[0]),int(srange[1])+1)) selected_caddress_Q[:,-1] = 2 * array(range(int(srange[0]),int(srange[1])+1)) + ones(slength) # Compressing I & Q of this sample range: selectedata = array(selectedata) Idata[i] = mean(selectedata[gotocdata(selected_caddress_I, session['c_sqepulse_structure'])]-0) Qdata[i] = mean(selectedata[gotocdata(selected_caddress_Q, session['c_sqepulse_structure'])]-0) else: # Ground level Pulse shape response: selected_caddress = [int(s) for s in selected_caddress] Basic = selected_caddress[-1] # Extracting I & Q: Idata[i] = selectedata[gotocdata(selected_caddress[:-1]+[2*Basic], session['c_sqepulse_structure'])] Qdata[i] = selectedata[gotocdata(selected_caddress[:-1]+[2*Basic+1], session['c_sqepulse_structure'])] I, Q = 0, 0 for i_prepeat in range(powa_repeat): r_powa = int(ipowa) * powa_repeat + i_prepeat # from the beginning position of repeating power I += selectedata[gotocdata([x,y,int(ixyfreq),int(ixypowa),int(isparam),int(iifb),int(ifreq),2*r_powa],c_cwsweep_structure)] Q += selectedata[gotocdata([x,y,int(ixyfreq),int(ixypowa),int(isparam),int(iifb),int(ifreq),2*r_powa+1],c_cwsweep_structure)] I /= powa_repeat Q /= powa_repeat Amp,P = IQAP(I,Q) return I, Q, Amp, P
def char_cwsweep_1ddata(): print(Fore.GREEN + "User %s is plotting 1D-Data" % session['user_name']) M_cwsweep[session['user_name']].loadata() selectedata = M_cwsweep[session['user_name']].selectedata # load parameter indexes from json call: irepeat = request.args.get('irepeat') ifluxbias = request.args.get('ifluxbias') ixyfreq = request.args.get('ixyfreq') ixypowa = request.args.get('ixypowa') isparam = request.args.get('isparam') iifb = request.args.get('iifb') ifreq = request.args.get('ifreq') ipowa = request.args.get('ipowa') # pre-transform ipowa: xpowa = waveform(M_cwsweep[session['user_name']].corder['Power']) ipowa_repeat = xpowa.inner_repeat # selecting data: if "x" in ifluxbias: xtitle = "<b>Flux-Bias(V/A)</b>" selected_sweep = M_cwsweep[session['user_name']].corder['Flux-Bias'] if int(irepeat ) < session['c_cwsweep_address'][0]: # address's part before x # print("Well within Progress!") xsweep = range( session['c_cwsweep_structure'][1] ) # can access full-range if selection is well within progress resume-point else: xsweep = range(session['c_cwsweep_address'][1] + 1) # can only access until progress resume-point selected_Ir, selected_Qr = [], [] for i_prepeat in range(ipowa_repeat): r_powa = int( ipowa ) * ipowa_repeat + i_prepeat # from the beginning position of repeating power selected_Ir += [ selectedata[gotocdata([ int(irepeat), x, int(ixyfreq), int(ixypowa), int(isparam), int(iifb), int(ifreq), 2 * r_powa ], session['c_cwsweep_structure'])] for x in xsweep ] selected_Qr += [ selectedata[gotocdata([ int(irepeat), x, int(ixyfreq), int(ixypowa), int(isparam), int(iifb), int(ifreq), 2 * r_powa + 1 ], session['c_cwsweep_structure'])] for x in xsweep ] # AVERAGE up those power repeats: selected_I = list( mean(array(selected_Ir).reshape(ipowa_repeat, len(xsweep)), axis=0)) selected_Q = list( mean(array(selected_Qr).reshape(ipowa_repeat, len(xsweep)), axis=0)) elif "x" in ixyfreq: xtitle = "<b>XY-Frequency(GHz)</b>" selected_sweep = M_cwsweep[session['user_name']].corder['XY-Frequency'] if [int(irepeat), int(ifluxbias) ] < session['c_cwsweep_address'][0:2]: # address's part before x xsweep = range( session['c_cwsweep_structure'][2] ) # can access full-range if selection is well within progress resume-point else: xsweep = range(session['c_cwsweep_address'][2] + 1) # can only access until progress resume-point selected_Ir, selected_Qr = [], [] for i_prepeat in range(ipowa_repeat): r_powa = int( ipowa ) * ipowa_repeat + i_prepeat # from the beginning position of repeating power selected_Ir += [ selectedata[gotocdata([ int(irepeat), int(ifluxbias), x, int(ixypowa), int(isparam), int(iifb), int(ifreq), 2 * r_powa ], session['c_cwsweep_structure'])] for x in xsweep ] selected_Qr += [ selectedata[gotocdata([ int(irepeat), int(ifluxbias), x, int(ixypowa), int(isparam), int(iifb), int(ifreq), 2 * r_powa + 1 ], session['c_cwsweep_structure'])] for x in xsweep ] # AVERAGE up those power repeats: selected_I = list( mean(array(selected_Ir).reshape(ipowa_repeat, len(xsweep)), axis=0)) selected_Q = list( mean(array(selected_Qr).reshape(ipowa_repeat, len(xsweep)), axis=0)) elif "x" in ixypowa: xtitle = "<b>XY-Power(dBm)</b>" selected_sweep = M_cwsweep[session['user_name']].corder['XY-Power'] if [int(irepeat), int(ifluxbias), int(ixyfreq) ] < session['c_cwsweep_address'][0:3]: # address's part before x xsweep = range( session['c_cwsweep_structure'][3] ) # can access full-range if selection is well within progress resume-point else: xsweep = range(session['c_cwsweep_address'][3] + 1) # can only access until progress resume-point selected_Ir, selected_Qr = [], [] for i_prepeat in range(ipowa_repeat): r_powa = int( ipowa ) * ipowa_repeat + i_prepeat # from the beginning position of repeating power selected_Ir += [ selectedata[gotocdata([ int(irepeat), int(ifluxbias), int(ixyfreq), x, int(isparam), int(iifb), int(ifreq), 2 * r_powa ], session['c_cwsweep_structure'])] for x in xsweep ] selected_Qr += [ selectedata[gotocdata([ int(irepeat), int(ifluxbias), int(ixyfreq), x, int(isparam), int(iifb), int(ifreq), 2 * r_powa + 1 ], session['c_cwsweep_structure'])] for x in xsweep ] # AVERAGE up those power repeats: selected_I = list( mean(array(selected_Ir).reshape(ipowa_repeat, len(xsweep)), axis=0)) selected_Q = list( mean(array(selected_Qr).reshape(ipowa_repeat, len(xsweep)), axis=0)) elif "x" in isparam: pass elif "x" in iifb: pass elif "x" in ifreq: xtitle = "<b>frequency(GHz)</b>" selected_sweep = M_cwsweep[session['user_name']].corder['Frequency'] if [ int(irepeat), int(ifluxbias), int(ixyfreq), int(ixypowa), int(isparam), int(iifb) ] < session['c_cwsweep_address'][0:6]: # address's part before x xsweep = range( session['c_cwsweep_structure'][6] ) # can access full-range if selection is well within progress resume-point else: xsweep = range(session['c_cwsweep_address'][6] + 1) # can only access until progress resume-point selected_Ir, selected_Qr = [], [] for i_prepeat in range(ipowa_repeat): r_powa = int( ipowa ) * ipowa_repeat + i_prepeat # from the beginning position of repeating power selected_Ir += [ selectedata[gotocdata([ int(irepeat), int(ifluxbias), int(ixyfreq), int(ixypowa), int(isparam), int(iifb), x, 2 * r_powa ], session['c_cwsweep_structure'])] for x in xsweep ] selected_Qr += [ selectedata[gotocdata([ int(irepeat), int(ifluxbias), int(ixyfreq), int(ixypowa), int(isparam), int(iifb), x, 2 * r_powa + 1 ], session['c_cwsweep_structure'])] for x in xsweep ] # AVERAGE up those power repeats: selected_I = list( mean(array(selected_Ir).reshape(ipowa_repeat, len(xsweep)), axis=0)) selected_Q = list( mean(array(selected_Qr).reshape(ipowa_repeat, len(xsweep)), axis=0)) elif "x" in ipowa: xtitle = "<b>Power(dBm)</b>" xpowa_repeat = ipowa_repeat if [ int(irepeat), int(ifluxbias), int(ixyfreq), int(ixypowa), int(isparam), int(iifb), int(ifreq) ] < session['c_cwsweep_address'][0:7]: # address's part before x xsweep = range( session['c_cwsweep_structure'][7] // 2 ) # can access full-range if selection is well within progress resume-point else: xsweep = range((session['c_cwsweep_address'][7] + 1) // 2) # can only access until progress resume-point selected_Ir = [ selectedata[gotocdata([ int(irepeat), int(ifluxbias), int(ixyfreq), int(ixypowa), int(isparam), int(iifb), int(ifreq), 2 * x ], session['c_cwsweep_structure'])] for x in xsweep ] selected_Qr = [ selectedata[gotocdata([ int(irepeat), int(ifluxbias), int(ixyfreq), int(ixypowa), int(isparam), int(iifb), int(ifreq), 2 * x + 1 ], session['c_cwsweep_structure'])] for x in xsweep ] # AVERAGE up those repeated IQ-pairs: selected_I = list( mean(array(selected_Ir).reshape( len(xsweep) // xpowa_repeat, xpowa_repeat), axis=1)) #--> selected_Q = list( mean(array(selected_Qr).reshape( len(xsweep) // xpowa_repeat, xpowa_repeat), axis=1)) #--> # preparing data: # assembly amplitude & phase: MagPha = [IQAP(x[0], x[1]) for x in zip(selected_I, selected_Q)] Amp, Pha = [], [] for i, j in MagPha: Amp.append(i) Pha.append(j) # x-range: if "x" in ipowa: selected_progress = xpowa.data[0:(len(xsweep) // xpowa_repeat)] else: selected_progress = waveform(selected_sweep).data[0:len(xsweep)] # to avoid exception when encountering recursive parameters: if "c" in ixyfreq + ixypowa + ifluxbias + isparam + iifb + ifreq + ipowa: selected_progress = list(range(len(selected_progress))) x1, y1, yup, yp = selected_progress, Amp, list( UnwraPhase(selected_progress, Pha)), Pha #list(unwrap(Pha)) global data_dict data_dict = { xtitle: x1, 'Amplitude': y1, 'UPhase': yup, 'I': selected_I, 'Q': selected_Q, "exported by": session['user_name'] } return jsonify(x1=x1, y1=y1, yup=yup, yp=yp, x1title=xtitle)
def char_fresp_1ddata(): print(Fore.GREEN + "User %s is plotting 1D-Data" % session['user_name']) M_fresp[session['user_name']].loadata() selectedata = M_fresp[session['user_name']].selectedata ifluxbias = request.args.get('ifluxbias') # if ifluxbias == "o": ifluxbias = '0' # for backward compatibility isparam = request.args.get('isparam') iifb = request.args.get('iifb') ipowa = request.args.get('ipowa') ifreq = request.args.get('ifreq') # selecting data if ifluxbias == "x": title = "<b>Flux-Bias(V)</b>" selected_sweep = M_fresp[session['user_name']].corder['Flux-Bias'] selected_progress = waveform( selected_sweep).data[0:session['c_fresp_address'][0] + 1] selected_I = [ selectedata[gotocdata( [x, int(isparam), int(iifb), int(ipowa), 2 * int(ifreq)], session['c_fresp_structure'])] for x in range(session['c_fresp_address'][0] + 1) ] selected_Q = [ selectedata[gotocdata( [x, int(isparam), int(iifb), int(ipowa), 2 * int(ifreq) + 1], session['c_fresp_structure'])] for x in range(session['c_fresp_address'][0] + 1) ] elif isparam == "x": pass elif iifb == "x": pass elif ipowa == "x": title = "<b>Power(dBm)</b>" selected_sweep = M_fresp[session['user_name']].corder['Power'] selected_progress = waveform( selected_sweep).data[0:session['c_fresp_address'][3] + 1] selected_I = [ selectedata[gotocdata( [int(ifluxbias), int(isparam), int(iifb), x, 2 * int(ifreq)], session['c_fresp_structure'])] for x in range(session['c_fresp_address'][3] + 1) ] selected_Q = [ selectedata[gotocdata([ int(ifluxbias), int(isparam), int(iifb), x, 2 * int(ifreq) + 1 ], session['c_fresp_structure'])] for x in range(session['c_fresp_address'][3] + 1) ] elif ifreq == "x": title = "<b>frequency(GHz)</b>" selected_sweep = M_fresp[session['user_name']].corder['Frequency'] selected_progress = waveform(selected_sweep).data # Full sweep selected_I = [ selectedata[gotocdata( [int(ifluxbias), int(isparam), int(iifb), int(ipowa), 2 * x], session['c_fresp_structure'])] for x in range(waveform(selected_sweep).count) ] selected_Q = [ selectedata[gotocdata([ int(ifluxbias), int(isparam), int(iifb), int(ipowa), 2 * x + 1 ], session['c_fresp_structure'])] for x in range(waveform(selected_sweep).count) ] # Preparing data: MagPha = [IQAP(x[0], x[1]) for x in zip(selected_I, selected_Q)] Amp, Pha = [], [] for i, j in MagPha: Amp.append(i) Pha.append(j) x1, y1, y2 = selected_progress, Amp, list( UnwraPhase(selected_progress, Pha)) #list(unwrap(Pha)) global data_dict data_dict = { title: x1, 'Amplitude': y1, 'UPhase': y2, 'I': selected_I, 'Q': selected_Q, "exported by": session['user_name'] } return jsonify(x1=x1, y1=y1, y2=y2, title=title)
case.loadata() selectedata = case.selectedata X = cxyfreq.data Y = cfluxbias.data[7:38] AMP, PHA = [], [] for i_flux in range(7, 38): print("retrieving Flux #%s/49" % (i_flux + 1)) # pre-transform ipowa: ipowa_repeat = waveform(case.corder['Power']).inner_repeat # print("repeating power at %s times" %ipowa_repeat) selected_Ir, selected_Qr = [], [] for i_repeat in range(ipowa_repeat): r_powa = 0 * ipowa_repeat + i_repeat # from the beginning position of repeating power selected_Ir += [ selectedata[gotocdata([i_flux, x, 0, 0, 0, 0, 2 * r_powa], c_cwsweep_structure)] for x in range(cxyfreq.count) ] selected_Qr += [ selectedata[gotocdata([i_flux, x, 0, 0, 0, 0, 2 * r_powa + 1], c_cwsweep_structure)] for x in range(cxyfreq.count) ] # AVERAGE up those power repeats: selected_I = list( mean(array(selected_Ir).reshape(ipowa_repeat, cxyfreq.count), axis=0)) selected_Q = list( mean(array(selected_Qr).reshape(ipowa_repeat, cxyfreq.count), axis=0)) # assembly amplitude & phase: MagPha = [IQAP(x[0], x[1]) for x in zip(selected_I, selected_Q)]