Calculation formula that can convert mW <-> dBm with python
Only math is used, so if Python is included, nothing in particular
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import math
#mW ->Convert to dBm
def mw_to_dbm(value):
return 10 * math.log10(value)
#dBm ->Convert to mW
def dbm_to_mw(value):
return math.pow(10, value/10)
# test_code
test_mw = 50 #mw
print str(mw_to_dbm(test_mw)) # => 16.9897000434
test_dbm = 16.9897000434 #mw
print str(dbm_to_mw(test_dbm)) # => 50.0000000005
Recommended Posts