Skip to content

Commit a88582d

Browse files
authored
Merge pull request #84 from dihm/generic_freq_conv
Add generic frequency conversion class
2 parents 66c68ab + 75a7df6 commit a88582d

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#####################################################################
2+
# #
3+
# generic_frequency.py #
4+
# #
5+
# Copyright 2022, Monash University and contributors #
6+
# #
7+
# This file is part of the labscript suite (see #
8+
# http://labscriptsuite.org) and is licensed under the Simplified #
9+
# BSD License. See the license.txt file in the root of the project #
10+
# for the full license. #
11+
# #
12+
#####################################################################
13+
"""Generic frequency conversion"""
14+
15+
from .UnitConversionBase import *
16+
17+
class FreqConversion(UnitConversion):
18+
"""
19+
A Generic frequency conversion class that covers standard SI prefixes from a base of Hz.
20+
"""
21+
22+
base_unit = 'Hz' # must be defined here and match default hardware unit in BLACS tab
23+
24+
def __init__(self, calibration_parameters = None):
25+
self.parameters = calibration_parameters
26+
if hasattr(self, 'derived_units'):
27+
self.derived_units += ['kHz', 'MHz', 'GHz']
28+
else:
29+
self.derived_units = ['kHz', 'MHz', 'GHz']
30+
UnitConversion.__init__(self,self.parameters)
31+
32+
def kHz_to_base(self,kHz):
33+
Hz = kHz*1e3
34+
return Hz
35+
36+
def kHz_from_base(self,Hz):
37+
kHz = Hz*1e-3
38+
return kHz
39+
40+
def MHz_to_base(self,MHz):
41+
Hz = MHz*1e6
42+
return Hz
43+
44+
def MHz_from_base(self,Hz):
45+
MHz = Hz*1e-6
46+
return MHz
47+
48+
def GHz_to_base(self,GHz):
49+
Hz = GHz*1e9
50+
return Hz
51+
52+
def GHz_from_base(self,Hz):
53+
GHz = Hz*1e-9
54+
return GHz

0 commit comments

Comments
 (0)