From 75a7df6c3a4f4b8a570e3bc186d2d7b305e4df25 Mon Sep 17 00:00:00 2001 From: David Meyer Date: Wed, 9 Feb 2022 12:27:17 -0500 Subject: [PATCH] Add generic frequency conversion class that goes between standard SI prefixes from a base of Hz. --- .../unitconversions/generic_frequency.py | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 labscript_utils/unitconversions/generic_frequency.py diff --git a/labscript_utils/unitconversions/generic_frequency.py b/labscript_utils/unitconversions/generic_frequency.py new file mode 100644 index 0000000..9e7c4d6 --- /dev/null +++ b/labscript_utils/unitconversions/generic_frequency.py @@ -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 \ No newline at end of file pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy