import math import sys from typing import Literal from fn_gen import DG2052 N_CYCLES = 500 # Cycles AMPLIFICATION = 13/2 # dB V_STEPS = 10 # steps F_STEPS = 30 # steps FREQ_START = 10 # Hz FREQ_STOP = 1000 # Hz STEP_DURATION = 10 # sec def abs(x) -> float: """ Gets the absolute value of the input. """ return math.sqrt(x * x) def close_output(fg: DG2052, channel: Literal[1, 2]): """ Closes the output channel of the function generator. """ fg.set_output(channel, False) fg.close() sys.exit(0) def get_preamplified(amplification: float, post: float) -> float: """ Calculates the pre amplification value from the amplification and the post amplification value. """ return post / (10 ** (amplification / 20)) def get_postamplified(amplification: float, pre: float) -> float: """ Calculates the pre amplification value from the amplification and the post amplification value. """ return pre * (10 ** (amplification / 20))