def make_sample(srs_num,
                signal_freq,
                sample_rate,
                nsamples,
                outfbase,
                store_int,
                v_pp):
    """
    Record a signal and save it to disk.
    """
    print 'Setting SRS', srs_num,
    print 'to output at', signal_freq/1e6, 'MHz.'
    DFEC.set_srs(srs_num, freq=signal_freq)
    time.sleep(5) # The generator has some delay.

    # record voltage samples.
    print 'Sampling...'
    samples = DFEC.sampler(nsamples,
                           sample_rate,
                           dual=False,
                           integer=store_int)

    # Save an npz file containing the data and a header
    filename = outfbase + '.npz'
    print 'Recording', nsamples, 'samples to', filename + '.'
    metadata = np.array([ ('SAMPRATE', sample_rate)
                        , ('SIGFREQ', signal_freq)
                        , ('VOLTPP', v_pp)
                        ], dtype=object)
    np.savez(filename, metadata, samples)
Example #2
0
def equal_frequency():
    f_signal = 10e3
    f_sample = 10e3

    yes_array = ["y", "Y"]

    DFEC.set_srs(1, freq=f_signal, vpp=1.0)
    go = raw_input("Check that LO 1 is outputting f=%s Hz\n" % f_signal)
    if go in yes_array:
        data = DFEC.sampler(nSamp=256, freqSamp=f_sample)
        np.savez("../data/1_1_2/f_10000Hz.npz", data)
Example #3
0
def slow_sample_rate():
    f_signal = 10e6
    f_sample = 7e3

    yes_array = ["y", "Y"]

    DFEC.set_srs(1, freq=f_signal, vpp=1.0)
    go = raw_input("Check that LO 1 is outputting f=%s Hz\n" % f_signal)
    if go in yes_array:
        data = DFEC.sampler(nSamp=256, freqSamp=f_sample)
        np.savez("../data/1_1_2/fast_signal.npz", data)
Example #4
0
def make_sample(srs_num, signal_freq, sample_rate, nsamples, outfbase,
                store_int, v_pp):
    """
    Record a signal and save it to disk.
    """
    print 'Setting SRS', srs_num,
    print 'to output at', signal_freq / 1e6, 'MHz.'
    DFEC.set_srs(srs_num, freq=signal_freq)
    time.sleep(5)  # The generator has some delay.

    # record voltage samples.
    print 'Sampling...'
    samples = DFEC.sampler(nsamples,
                           sample_rate,
                           dual=False,
                           integer=store_int)

    # Save an npz file containing the data and a header
    filename = outfbase + '.npz'
    print 'Recording', nsamples, 'samples to', filename + '.'
    metadata = np.array([('SAMPRATE', sample_rate), ('SIGFREQ', signal_freq),
                         ('VOLTPP', v_pp)],
                        dtype=object)
    np.savez(filename, metadata, samples)
Example #5
0
# disable DFEC for testing
def empty_func(*args, **kwargs):
    print args, kwargs
# DFEC.set_srs = empty_func
# DFEC.sampler = empty_func


# provide arguments on command line
# $ python 1_1_1.py 256 1e3

N, f_sample = sys.argv[1:]
N = int(N)
f_sample = float(f_sample)


yes_array = ["y", "Y"]
for x in np.arange(0.1, 1.0, 0.1):
    f_signal = x * f_sample
    go = raw_input("Safe to set srs?\n")
    if go not in yes_array:
        break
    DFEC.set_srs(1, freq=f_signal, vpp=1.0)
    go = raw_input("Check that LO 1 is outputting f=%s Hz\n" % f_signal)
    if go not in yes_array:
        break
    data = DFEC.sampler(nSamp=N, freqSamp=f_sample)

    array_savefile = "../data/1_1_1/fsig_%.1f.npz" % f_signal
    np.savez(array_savefile, data)
    print "Saved %s" % array_savefile
Example #6
0
import DFEC 
import pylab as py 
import numpy as np 
sampling = 1e7
N = 256

for i in np.arange(0.1,1.0,.1):
    freq_signal = sampling*i             
    DFEC.set_srs(1,freq=freq_signal,dbm=0,pha=180)
    DFEC.set_srs(2,freq=freq_signal,dbm=0,pha=180)
    data = DFEC.sampler(N,sampling)
    filename = "%svsample_10MHz.npz" % i
    np.savez(filename,data,sampling,N)
    raw_input("Press enter to continue sampling...")
    
    





Example #7
0
import DFEC
import pylab as plt
import numpy as np
sample = 100000.
N=256

x=np.arange(((10**6)*(1/sample)),((10**6)*((N+1)/sample)),((10**6)*(1/sample)))


#DFEC.set_srs(1,.2*sample,2)
y=DFEC.sampler(N,sample)

plt.subplot(121)
plt.plot(x,y)
plt.title(r'$\nu_{sig} =.9\nu_{sampl} (\nu_{sampl}=100kHz)$', fontsize=18)
plt.xlabel('Time($\mu$s)',fontsize = 16)
plt.ylabel("Voltage(V)", fontsize = 16)


fy=np.fft.fft(y)
py=np.abs(fy)**2
freq=np.fft.fftfreq(fy.size,(10**(3))*(1/sample))
plt.subplot(122)
plt.plot(freq,py)
plt.title('Fourier Transform', fontsize = 18)
plt.xlabel('Frequency(kHz)', fontsize = 16)
plt.ylabel('Power(W)', fontsize = 16)



plt.show()
            nfreqs = int(arg)
        elif opt == '-o':
            outfbase = os.path.abspath(arg)
            outdir = os.path.dirname(outfbase)
        elif opt == '-s':
            srs_num = int(arg)
        elif opt == '-v':
            v_pp = float(arg)
    if outdir == None:
        print 'ERROR: No output location specified.'
        usage(1)
    else:
        os.system('mkdir -pv ' + outdir)

    # Initialize the generator
    DFEC.set_srs(srs_num, dbm=0, off=0, pha=0)
    DFEC.set_srs(srs_num, vpp=v_pp)

    # Don't sample for longer than 1/10th of a second.
    sample_time = 0.1
    nsamples = min(262143, int(sample_rate * sample_time))

    # Get samples.
    if nfreqs != None:
        step = 0.1
        sig_freqs = np.linspace(step, nfreqs * step, nfreqs) * sample_rate

        # Record sample for each frequency in the list.
        for i in range(nfreqs):
            make_sample(srs_num,
                        sig_freqs[i],
Example #9
0
f_sample = 10e6  # 10 MHz

'''
f_lo = 800e3  # 800 kHz
f_signal_p = 840e3  # 210 kHz
f_signal_m = 760e3  # 190 kHz
'''

f_lo = 2e6  # 2 Mhz
f_signal_p = 2.1e6  # 2.1 Mhz
f_signal_m = 1.9e6  # 1.9 Mhz

N = 16384
yes_array = ["y", "Y"]

for f_sig in [f_signal_p, f_signal_m]:
    go = raw_input("Safe to set srs?\n")
    if go not in yes_array:
        break
    # DFEC.set_srs(1, freq=f_sig, dbm=1.0)
    # DFEC.set_srs(2, freq=f_lo, dbm=0.0)
    go = raw_input("Check that SRS1 is outputting f=%s Hz\n and SRS2 is outputting f=%s Hz\n" % (
        f_sig, f_lo))
    if go not in yes_array:
        break
    data = DFEC.sampler(nSamp=N, freqSamp=f_sample)

    array_savefile = "../data/2_1_1/thurs_sig_%.1f.npz" % f_sig
    np.savez(array_savefile, data)
    print "Saved %s" % array_savefile
Example #10
0
import DFEC
import pylab as plt
import numpy as np

fsample = 10000000
N = 2047
x=np.arange(((10**6)*(1/fsample)),((10**6)*((N+1)/fsample),((10**6)*(1/fsample))

DFEC.set_srs(1, 300000, 1)
DFEC.set_srs(2, 295000, 1)
x=np.arange(0*(1/200e6)*(1e6),2048*(1/200e6)*(1e6), (1/200e6))
#file is in goodroach1
#srs1 = 300kHz
#srs2 = 295kHz
plt.subplot(121)
plt.plot(x,roachd)
plt.title('Waveform of digital SSB Mixer', fontsize = 18)
plt.xlabel('Time($\mu$s)',fontsize = 16)
plt.ylabel('Amplitude(V)',fontsize = 16)

fy = np.fft.fft(roachd)
py = np.abs(fy)**2)*(1e-6)
freq = np.fft.fftfreq(fy.size, (1/(200*1e6))*(1e6))

plt.subplot(122)
plt.plot(freq, py)
plt.title('Mixed signal power spectrum Vsig=Vlo-dV', fontsize = 18)
plt.xlabel('Frequency(MHz)',fontsize = 16)
plt.ylabel('Power(MW)',fontsize = 16)
plt.show()
Example #11
0
            nfreqs = int(arg)
        elif opt == '-o':
            outfbase = os.path.abspath(arg)
            outdir = os.path.dirname(outfbase)
        elif opt == '-s':
            srs_num = int(arg)
        elif opt == '-v':
            v_pp = float(arg)
    if outdir == None:
        print 'ERROR: No output location specified.'
        usage(1)
    else:
        os.system('mkdir -pv ' + outdir)

    # Initialize the generator
    DFEC.set_srs(srs_num, dbm=0, off=0, pha=0)
    DFEC.set_srs(srs_num, vpp=v_pp)

    # Don't sample for longer than 1/10th of a second.
    sample_time = 0.1
    nsamples = min(262143, int(sample_rate * sample_time))

    # Get samples.
    if nfreqs != None:
        step = 0.1
        sig_freqs = np.linspace(step, nfreqs * step, nfreqs) * sample_rate

        # Record sample for each frequency in the list.
        for i in range(nfreqs):
            make_sample(srs_num, sig_freqs[i], sample_rate, nsamples,
                        outfbase + '-' + str(i + 1), store_int, v_pp)
Example #12
0
import DFEC
import numpy as np 
import pylab as py 

vlo = 2e6 
delv = .05*vlo
vsighigh = vlo + delv
vsiglow = vlo - delv
vsample = 20e6 
N = 2**14

for vsig in [vsiglow, vsighigh]: 
   # DFEC.set_srs(2, freq=vsig,dbm=1, pha=0)
   # DFEC.set_srs(1, freq=vlo, dbm=7, pha=0)
    print 'RF srs_2 = ' + str(vsig/1000000.0) + ' MHz  and dBm = 0'  
    print 'LO srs_1 = ' + str(vlo/1000000.0) + ' MHz and dBM = 0' 
    raw_input("Start data collection?")
    data = DFEC.sampler(N,vsample)
    filename = "vsig_%.1f.npz" % vsig
    np.savez(filename,data=data,vsample=vsample,vsig=vsig)
    print "Saved %s" % filename