def getAFewParameters(): #From the measured gain, you can get a few results #If you just want to get a list with measured gains: print GainCalculations.getFileResults(10001, 25, 2) #You will find informations about: calculated gain, received RSSI, Noise power, transmitted power, date #if you just want the average gain: print GainCalculations.getAverageGain(10001, 25, 2) print "%.3f dB" %(10.00*math.log10(GainCalculations.getAverageGain(10001, 25, 2))) #if you just want to find info about the noise power GainCalculations.getAverageNoise(10001, 25, 2) GainCalculations.getMinMaxNoise(10001, 25, 2)
def bestResponseAsAfunctionOfCostAndPrx(): #plot best response variation as function of I+N and cost player = Player(10001, 25, 2, 1000.00, player_number=1, game_Type=0) #give the node id which cause interference to player tx2_node_id = 16 #I want to determine the maximum level of interference #average direct gain hii = GainCalculations.getAverageGain(player.coordinator_id, player.tx_node.node_id, player.rx_node.node_id, year=2013, month=8, day=23) #maximum cross gain hji = GainCalculations.getMinMaxGain(10001, tx2_node_id, player.rx_node.node_id, year=2013, month=8, day=24) #get average noise noise = GainCalculations.getAverageNoise(player.coordinator_id, player.tx_node.node_id, player.rx_node.node_id, year=2013, month=8, day=23) max_interference_and_noise = 0.001*hji[1] + noise max_interference_and_noise = 10.00*math.log10(max_interference_and_noise/0.001) interference_and_noise = numpy.arange(max_interference_and_noise, max_interference_and_noise-10, -2) cost = numpy.arange(100, 10000, 0.1) #now plot results plot.ioff() plot.clf() plot.grid() plot.title("B%d (c%d, I+N)" %(player.player_number, player.player_number)) plot.xlabel("c%d" %(player.player_number)) plot.ylabel("B%d [dBm]" %(player.player_number)) for i in interference_and_noise: tmp_list = [] tmp_cost = [] for c in cost: tmp_bi = getBi(c, math.pow(10.00, i/10.00)*0.001, 10.00*math.log10(hii)) if tmp_bi!=None: tmp_list.append(tmp_bi) tmp_cost.append(c) plot.plot(tmp_cost, tmp_list, label = "I+N=%.1f dBm" %i) plot.plot([],[],label = "h%d%d = %.3f dB" %(player.player_number, player.player_number, 10.00*math.log10(hii))) plot.axhspan(-55, 0, alpha = 0.1) plot.legend(bbox_to_anchor=(1.05, 1.05)) plot.show() #bestResponseAsAfunctionOfCostAndPrx() #bestResponseAsAFunctionOfDirectGain() #bestResponseAsAFunctionOfRx()