Changeset 357
- Timestamp:
- 07/21/09 12:23:22 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
vtcross/branches/sriram/receive_path.py
r354 r357 35 35 import copy 36 36 import sys 37 37 from numpy import random 38 38 # from current dir 39 39 from pick_bitrate import pick_rx_bitrate 40 40 import usrp_options 41 import random 41 42 42 43 # ///////////////////////////////////////////////////////////////////////////// … … 341 342 print "Rx Frequency: %s" % (eng_notation.num_to_str(self._rx_freq)) 342 343 343 def get_avg_power(self,trials): 344 #Getting spectrum information 345 #Arguments... threshold - Minimum power equivalent available in spectrum 346 # trials - Fft frames...should be 1 347 # exceed count - Number of times threshold is exceeded...useless 348 349 def get_spec_stats(self,threshold,trials): 344 350 power_sum = 0 #sum of powers(each power value is determined by adding the 'fft square' points..these fft square points are essentially points from the PSD curve...and adding them gives us the power contained in the spectrum) 345 351 counter = 0 346 347 while counter < 10 : 348 349 # Get the next message sent from the C++ code (blocking call). 352 #exceed = 0 353 while counter < trials: 354 # Get the next message sent from the C++ code (blocking call). 350 355 # It contains the center frequency and the mag squared of the fft 351 356 m = parse_msg(self.msgq.delete_head()) 352 357 #print "printing mag sq of fft ",sum(m.data),"\n" 353 #if sum(m.data) > 1e12:354 358 power_sum = power_sum + sum(m.data) 355 print sum(m.data),"\n" 359 #if sum(m.data) > threshold 360 # exceed+=1 361 #print sum(m.data),"\n" 356 362 # Print center freq so we know that something is happening... 357 363 #print m.center_freq 358 364 counter +=1 359 365 # FIXME do something useful with the data... 366 360 367 361 368 # m.data are the mag_squared of the fft output (they are in the … … 364 371 # m.raw_data is a string that contains the binary floats. 365 372 # You could write this as binary to a file. 366 367 avg_power = power_sum/counter 368 print "printing average power ",avg_power,"\n" 373 print "here" 374 avg_power = power_sum/trials 375 #ch = int(random.choice('17')) 376 if avg_power >= threshold: 377 return True 378 #return 1,ch 379 else: 380 return False 381 #return 0,"no" 382 #print "printing average power ",avg_power,"\n" 383 #if exceed >= exceed_count: 384 # return avg_power,True 385 # return avg_power,True #True = primary user is present at this frequency 386 #else 387 # return avg_power,False 388 # return avg_power,False #False = primary user is NOT present at this frequency 369 389 370 390 def add_freq_option(parser):