LoginSignup
0
0

More than 5 years have passed since last update.

PythonでmW <-> dBmを計算する

Posted at

概要

python でmW <-> dBm変換が出来る計算式

事前準備

使用するのはmathのみなので、Pythonが入っていれば、特になし

ソース


#!/usr/bin/env python
#-*- coding: utf-8 -*-
import math

#mW -> dBmへ変換
def mw_to_dbm(value):
    return 10 * math.log10(value)

#dBm -> 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


0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0