slaclab / pysmurf

Other
2 stars 9 forks source link

Add option to scale rfIQ data to match setup_notches response data. #761

Open swh76 opened 1 year ago

swh76 commented 1 year ago

Describe the problem

Apparently rfIQ data taken like this ;

nsamp=2**23
i,q,sync = S.take_debug_data(band=0,channel=0,rf_iq=True, nsamp=nsamp)

has a different I/Q convention than the response data returned by setup_notches. This is confusing and annoying. We should add an option to take_debug_data to scale the returned rfIQ data to match the setup_notches convention so folks don't have to know/think about this.

I worked out the difference by taking fixed tone rfIQ data at the same set of frequencies as a setup_notches sweep like this;

power=12
nsamp=2**23

ii=[]
qq=[]
ss=[]
for f in S.freq_resp[0]['resonances'][0]['freq_eta_scan'][::4]:
    band,chan=S.set_fixed_tone(f,power)

    i,q,sync = S.take_debug_data(band=band,channel=chan,rf_iq=True, nsamp=nsamp)
    ii.append(i)
    qq.append(q)

    S.channel_off(band,chan)

qmean=[np.mean(qqq) for qqq in qq]
imean=[np.mean(iii) for iii in ii]

For a superconducting resonator in the SLAC cryostat chosen at random, I can convert the setup_notches data to the rfIQ data using this transformation:

plt.plot(imean,qmean,label='rfIQ')
plt.plot(1.2*np.real(S.freq_resp[0]['resonances'][0]['resp_eta_scan'][::4]),-1.2*np.imag(S.freq_resp[0]['resonances'][0]['resp_eta_scan']),label='setup_notches')
plt.legend()
plt.axes().set_aspect('equal')

so if you take rfIQ data like this:

i,q,sync = S.take_debug_data(band=0,channel=0,rf_iq=True, nsamp=nsamp)

you can scale setup_notches data into it like this

1.2*np.real(S.freq_resp[0]['resonances'][0]['resp_eta_scan']),-1.2*np.imag(S.freq_resp[0]['resonances'][0]['resp_eta_scan']

the 1.2 is almost certainly the PFB subband half width, 1.2 MHz.