Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add generic frequency conversion class #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions labscript_utils/unitconversions/generic_frequency.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#####################################################################
# #
# generic_frequency.py #
# #
# Copyright 2022, Monash University and contributors #
# #
# This file is part of the labscript suite (see #
# http://labscriptsuite.org) and is licensed under the Simplified #
# BSD License. See the license.txt file in the root of the project #
# for the full license. #
# #
#####################################################################
"""Generic frequency conversion"""

from .UnitConversionBase import *

class FreqConversion(UnitConversion):
"""
A Generic frequency conversion class that covers standard SI prefixes from a base of Hz.
"""

base_unit = 'Hz' # must be defined here and match default hardware unit in BLACS tab

def __init__(self, calibration_parameters = None):
self.parameters = calibration_parameters
if hasattr(self, 'derived_units'):
self.derived_units += ['kHz', 'MHz', 'GHz']
else:
self.derived_units = ['kHz', 'MHz', 'GHz']
UnitConversion.__init__(self,self.parameters)

def kHz_to_base(self,kHz):
Hz = kHz*1e3
return Hz

def kHz_from_base(self,Hz):
kHz = Hz*1e-3
return kHz

def MHz_to_base(self,MHz):
Hz = MHz*1e6
return Hz

def MHz_from_base(self,Hz):
MHz = Hz*1e-6
return MHz

def GHz_to_base(self,GHz):
Hz = GHz*1e9
return Hz

def GHz_from_base(self,Hz):
GHz = Hz*1e-9
return GHz