initial check-in
This commit is contained in:
39
Scripts/Miscellaneous/op_gs_exp.py
Normal file
39
Scripts/Miscellaneous/op_gs_exp.py
Normal file
@ -0,0 +1,39 @@
|
||||
# -*- coding: iso-8859-1 -*-
|
||||
|
||||
def experiment(): # 'go setup' routine
|
||||
|
||||
pars = {}
|
||||
pars['P90'] = 2.5e-6 # 90-degree pulse length (s)
|
||||
pars['RD'] = 1 # delay between scans (s)
|
||||
pars['SW'] = 100e3 # spectrum window (Hz)
|
||||
pars['SI'] = 1*1024 # number of acquisition points
|
||||
pars['DEAD1'] = 10e-6 # receiver dead time (s)
|
||||
|
||||
while True:
|
||||
yield gs_experiment(pars)
|
||||
|
||||
|
||||
def gs_experiment(pars):
|
||||
e=Experiment()
|
||||
|
||||
# read in variables:
|
||||
P90 = pars['P90']
|
||||
RD = pars['RD']
|
||||
SI = pars['SI']
|
||||
SW = pars['SW']
|
||||
DEAD1 = pars['DEAD1']
|
||||
|
||||
if P90 > 20e-6:
|
||||
raise Exception("Pulse too long!!!")
|
||||
|
||||
e.ttl_pulse(2e-6, value=1) # unblank RF amplifier
|
||||
e.ttl_pulse(P90, value=3) # apply 90-degree pulse
|
||||
e.wait(DEAD1) # wait for receiver dead time
|
||||
e.record(SI, SW, sensitivity=2) # acquire signal
|
||||
e.wait(RD) # wait for next scan
|
||||
|
||||
# write experiment parameters:
|
||||
for key in pars.keys():
|
||||
e.set_description(key, pars[key])
|
||||
|
||||
return e
|
54
Scripts/Miscellaneous/op_gs_res.py
Normal file
54
Scripts/Miscellaneous/op_gs_res.py
Normal file
@ -0,0 +1,54 @@
|
||||
# -*- coding: iso-8859-1 -*-
|
||||
|
||||
from numpy import *
|
||||
|
||||
def result():
|
||||
|
||||
# loop over the incoming results:
|
||||
for timesignal in results:
|
||||
if not isinstance(timesignal,ADC_Result):
|
||||
continue
|
||||
|
||||
# get list of parameters:
|
||||
pars = timesignal.get_description_dictionary()
|
||||
|
||||
# make a copy of timesignal:
|
||||
fid = timesignal + 0
|
||||
|
||||
# correct for the baseline offset:
|
||||
fid.baseline()
|
||||
|
||||
# compute the initial phase:
|
||||
phi0 = arctan2(fid.y[1][0], fid.y[0][0]) * 180 / pi
|
||||
|
||||
# do FFT:
|
||||
fid.exp_window(line_broadening=10)
|
||||
spectrum = fid.fft(samples=2*pars['SI'])
|
||||
spectrum.baseline()
|
||||
spectrum.phase(-phi0)
|
||||
|
||||
# provide timesignal and spectrum to the display tab:
|
||||
data['Timesignal'] = timesignal
|
||||
data["Spectrum"] = spectrum
|
||||
|
||||
# ------------- optional measurements: --------------
|
||||
|
||||
# measure signal intensity:
|
||||
signal = (timesignal +0).phase(-phi0)
|
||||
signal_intensity = sum(signal.y[0:10])
|
||||
|
||||
# measure spectrum integral:
|
||||
#spectrum_integral = cumsum(spectrum.y[0])
|
||||
spectrum_magnitude = (spectrum+0).magnitude()
|
||||
spectrum_integral = cumsum(spectrum_magnitude.y[0])
|
||||
|
||||
# find the centre of gravity of the spectrum:
|
||||
cg = argwhere(spectrum_integral > 0.5*spectrum_integral[-1])[0]
|
||||
|
||||
print ''
|
||||
print '%s%.3e'%('FID intensity = ', signal_intensity)
|
||||
print '%s%.3e'%('Spectrum integral = ', spectrum_integral[-1])
|
||||
print '%s%g%s'%("Spectrum middle frequency = ", spectrum.x[cg], ' Hz')
|
||||
print ''
|
||||
|
||||
pass
|
Reference in New Issue
Block a user