BOSWatch/includes/converter.py

30 lines
593 B
Python
Raw Normal View History

2015-06-25 21:19:41 +02:00
#!/usr/bin/python
# -*- coding: UTF-8 -*-
2015-06-25 21:19:41 +02:00
#
"""
convert frequency to Hz
@author: Bastian Schroll
"""
import logging
def freqToHz(freq):
"""
gets a frequency and resolve it in Hz
2015-07-02 09:02:49 +02:00
2015-06-25 21:19:41 +02:00
@type freq: string
@param freq: frequency of the SDR Stick
2015-07-02 09:02:49 +02:00
2015-06-25 21:19:41 +02:00
@return: frequency in Hz
@exception: Exception if Error by recalc
"""
try:
freq = freq.replace("k","e3").replace("M","e6")
# freq has to be interpreted as float first...
# otherwise you will get the error: an invalid literal for int() with base 10
return int(float(freq))
except:
2015-07-02 09:02:49 +02:00
logging.exception("Error in freqToHz()")