Skip to content

Unit Conversion

rfsoc_rfdc.dsp.unit_convt

Functions

dB2Amp(atten_db)

Convert dB to amplitude. Output shall be a positive number between 0.0 and 1.0

Source code in rfsoc_rfdc/dsp/unit_convt.py
4
5
6
7
8
def dB2Amp(atten_db):
    """Convert dB to amplitude. Output shall be a positive number between 0.0 and 1.0"""
    if atten_db < 0:
        raise Exception(f"Attenuation in dB: {atten_db} cannot be negative")
    return 1 / (10**(atten_db / 20))

amp2dB(amp)

Convert amplitude to dB

Source code in rfsoc_rfdc/dsp/unit_convt.py
def amp2dB(amp):
    """Convert amplitude to dB"""
    return 20 * np.log10(np.abs(amp))