11 from numpy.fft import *;
14 myport = random.randint(1025,65535);
15 filename = "output.dat";
18 #msdd_host = "10.45.4.43"
19 msdd_host = "10.45.4.45"
23 my_udp_addr = ('',10001);
24 my_udp_addr = ('10.45.1.229 ',10001);
26 UDPSock = socket(AF_INET,SOCK_DGRAM);
27 UDPSock.bind(my_udp_addr);
34 window = 3; #0=rect, 1=hanning, 2=hamming, 3=blackman
38 #samples = samples*4; #bytes of data we are requesting
43 decim = decim+16; # +16 to use 16bit floats instead of 32 bit floats
44 mode = 0; #0=IQ, 1=MAG, 2=MAGDB
49 request_len = 6*size_int; # 6 int items not including the 8 bytes for opcode and length fields
50 print "request len = %d"%(request_len);
52 raw_data = struct.pack("<IIIIIIII", 0x01, request_len, f_mhz, f_hz, gain, samples, decim, sets);
56 UDPSock.sendto(data, (msdd_host, msdd_port));
78 IQ_bytes = 4 * numtocap;
80 #numbytes = 65536*100;
90 while(num_rx < numbytes):
91 data = UDPSock.recv(65536);
92 num_rx = num_rx + len(data);
98 #halt_data = struct.pack("<II", 0x04, 0x00);
99 #UDPSock.sendto(halt_data, (msdd_host, msdd_port));
101 # perform timing analysis
102 print "recieved %d bytes in %f sec"%(numbytes, end-start);
103 bytes_per_sec = numbytes / (end-start);
104 samples_per_sec = bytes_per_sec / 4;
105 MSPS = samples_per_sec / 1000000.0;
107 print "Got %f MSPS"%(MSPS);
108 print "Expected %f MSPS"%(102.4/math.pow(2,(decim-16)));
115 print "Repacking data..."
117 for p in range(0, len(li)/4):
118 [i,q] = struct.unpack_from("<hh", li, p);
120 mag_arr.append(abs(val));
124 print "Calculating Time Domain Power..."
127 tpwr.append( (i*conj(i)).real );
129 print "Calculating PSD..."
130 freqz = fft(val_arr);
134 #for i in range(0, floor(len(val_arr)/2048)):
135 # tmp = val_arr(range(i,i+2048));
136 # if len(freqz) == 0:
140 psd = (freqz * conj(freqz)).real;