diff --git a/Scripts/Miscellaneous/PhaseTest/README.md b/Scripts/Miscellaneous/PhaseTest/README.md new file mode 100644 index 0000000..1cab6ee --- /dev/null +++ b/Scripts/Miscellaneous/PhaseTest/README.md @@ -0,0 +1,7 @@ +Phase Test +========== +This script helps in testing the correct function of the phase programming +of RF sources. It measures a first and second, albeit phase shifted, +interval and calculatets the dot product of these to intervals. +The result should be a smooth full period of a cosine. + diff --git a/Scripts/Miscellaneous/PhaseTest/phase_exp.py b/Scripts/Miscellaneous/PhaseTest/phase_exp.py new file mode 100755 index 0000000..c5b5e92 --- /dev/null +++ b/Scripts/Miscellaneous/PhaseTest/phase_exp.py @@ -0,0 +1,25 @@ +import numpy as N +# connect PTS RF source to ADC card, set to generate a few MHz +# result should be a fulle period of sine/cosine +def experiment(): + #step = 0.36 # for PTS 500 + step = 0.225 # for PTS 310 + for i in list(xrange(1)): # number of periods + samples = 2048 + print samples + for phase in N.arange(0,360,step): + #phase=ph + e=Experiment() + #e.set_frequency(1e6,0) + e.wait(20e-6) + e.set_description("phase", phase) + e.set_description("i", i) + e.set_phase(0.0) + #e.loop_start(1) + e.wait(20e-6) + e.record(samples, 20e6,sensitivity=10) + e.set_phase(phase) + e.wait(20e-6) + #e.loop_end() + e.record(samples, 20e6,sensitivity=10) + yield e diff --git a/Scripts/Miscellaneous/PhaseTest/phase_res.py b/Scripts/Miscellaneous/PhaseTest/phase_res.py new file mode 100755 index 0000000..960cd75 --- /dev/null +++ b/Scripts/Miscellaneous/PhaseTest/phase_res.py @@ -0,0 +1,23 @@ +import numpy + +def result(): + o=MeasurementResult("overview") + for r in results: + if r is None: continue + #print r + data["single scan"]=r + phase = r.get_description("phase") + i = int(r.get_description("i")) + r1=numpy.array(r.get_result_by_index(0).y[0], dtype="Float64") + r2=numpy.array(r.get_result_by_index(1).y[0], dtype="Float64") + #print r1 + r1-=r1.mean() + r1/=r1.std() + r2-=r2.mean() + r2/=r2.std() + + c = numpy.dot(r1, r2) + print c + o[phase+360*i]=AccumulatedValue(c) + + data["overview"]=o \ No newline at end of file