Calculate mW <-> dBm in Python

Overview

Calculation formula that can convert mW <-> dBm with python

Advance preparation

Only math is used, so if Python is included, nothing in particular

Source


#!/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

Calculate mW <-> dBm in Python
Calculate free-space path loss in Python
Try to calculate Trace in Python
Calculate the previous month in Python
Quadtree in Python --2
Python in optimization
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
SendKeys in Python
Meta-analysis in Python
Unittest in python
Epoch in Python
Discord in Python
Sudoku in Python
DCI in Python
quicksort in python
nCr in python
N-Gram in Python
Programming in python
Plink in Python
Constant in python
Lifegame in Python.
FizzBuzz in Python
Sqlite in python
StepAIC in Python
N-gram in python
LINE-Bot [0] in Python
Csv in python
Disassemble in Python
Reflection in Python
Constant in python
nCr in Python.
format in python
Scons in Python3
Puyo Puyo in python
python in virtualenv
PPAP in Python
Quad-tree in Python
Reflection in Python
Chemistry in Python
Hashable in python
DirectLiNGAM in Python
LiNGAM in Python
Flatten in python
flatten in python
Try to calculate a statistical problem in Python
Try to calculate RPN in Python (for beginners)
Sorted list in Python
Daily AtCoder # 36 in Python
Clustering text in Python
Daily AtCoder # 2 in Python
Implement Enigma in python
Daily AtCoder # 32 in Python
Daily AtCoder # 6 in Python
Daily AtCoder # 18 in Python
Edit fonts in Python
Singleton pattern in Python
File operations in Python
Read DXF in python