Skip to content

Units & Constants

Unit conversion utilities and physical constants used throughout OpenSatCom.

Unit Conversions

units

Unit conversion utilities for dB and power domains.

Provides symmetric conversion pairs for power ratios (10 log10), amplitude ratios (20 log10), and absolute power (watts / dBW).

lin_to_db10

lin_to_db10(x)

Convert a linear power ratio to decibels.

Parameters:

Name Type Description Default
x float

Linear power ratio (must be > 0).

required

Returns:

Type Description
float

Value in dB: 10 * log10(x).

Examples:

>>> lin_to_db10(100.0)
20.0
Source code in src/opensatcom/core/units.py
def lin_to_db10(x: float) -> float:
    """Convert a linear power ratio to decibels.

    Parameters
    ----------
    x : float
        Linear power ratio (must be > 0).

    Returns
    -------
    float
        Value in dB: ``10 * log10(x)``.

    Examples
    --------
    >>> lin_to_db10(100.0)
    20.0
    """
    return 10.0 * math.log10(x)

db10_to_lin

db10_to_lin(x_db)

Convert decibels to a linear power ratio.

Parameters:

Name Type Description Default
x_db float

Value in dB.

required

Returns:

Type Description
float

Linear power ratio: 10^(x_db / 10).

Examples:

>>> db10_to_lin(20.0)
100.0
Source code in src/opensatcom/core/units.py
def db10_to_lin(x_db: float) -> float:
    """Convert decibels to a linear power ratio.

    Parameters
    ----------
    x_db : float
        Value in dB.

    Returns
    -------
    float
        Linear power ratio: ``10^(x_db / 10)``.

    Examples
    --------
    >>> db10_to_lin(20.0)
    100.0
    """
    return float(10.0 ** (x_db / 10.0))

lin_to_db20

lin_to_db20(x)

Convert a linear amplitude ratio to decibels.

Parameters:

Name Type Description Default
x float

Linear amplitude ratio (must be > 0).

required

Returns:

Type Description
float

Value in dB: 20 * log10(x).

Examples:

>>> lin_to_db20(10.0)
20.0
Source code in src/opensatcom/core/units.py
def lin_to_db20(x: float) -> float:
    """Convert a linear amplitude ratio to decibels.

    Parameters
    ----------
    x : float
        Linear amplitude ratio (must be > 0).

    Returns
    -------
    float
        Value in dB: ``20 * log10(x)``.

    Examples
    --------
    >>> lin_to_db20(10.0)
    20.0
    """
    return 20.0 * math.log10(x)

db20_to_lin

db20_to_lin(x_db)

Convert decibels to a linear amplitude ratio.

Parameters:

Name Type Description Default
x_db float

Value in dB.

required

Returns:

Type Description
float

Linear amplitude ratio: 10^(x_db / 20).

Examples:

>>> db20_to_lin(20.0)
10.0
Source code in src/opensatcom/core/units.py
def db20_to_lin(x_db: float) -> float:
    """Convert decibels to a linear amplitude ratio.

    Parameters
    ----------
    x_db : float
        Value in dB.

    Returns
    -------
    float
        Linear amplitude ratio: ``10^(x_db / 20)``.

    Examples
    --------
    >>> db20_to_lin(20.0)
    10.0
    """
    return float(10.0 ** (x_db / 20.0))

w_to_dbw

w_to_dbw(w)

Convert watts to dBW.

Parameters:

Name Type Description Default
w float

Power in watts (must be > 0).

required

Returns:

Type Description
float

Power in dBW: 10 * log10(w).

Examples:

>>> w_to_dbw(100.0)
20.0
Source code in src/opensatcom/core/units.py
def w_to_dbw(w: float) -> float:
    """Convert watts to dBW.

    Parameters
    ----------
    w : float
        Power in watts (must be > 0).

    Returns
    -------
    float
        Power in dBW: ``10 * log10(w)``.

    Examples
    --------
    >>> w_to_dbw(100.0)
    20.0
    """
    return 10.0 * math.log10(w)

dbw_to_w

dbw_to_w(dbw)

Convert dBW to watts.

Parameters:

Name Type Description Default
dbw float

Power in dBW.

required

Returns:

Type Description
float

Power in watts: 10^(dbw / 10).

Examples:

>>> dbw_to_w(20.0)
100.0
Source code in src/opensatcom/core/units.py
def dbw_to_w(dbw: float) -> float:
    """Convert dBW to watts.

    Parameters
    ----------
    dbw : float
        Power in dBW.

    Returns
    -------
    float
        Power in watts: ``10^(dbw / 10)``.

    Examples
    --------
    >>> dbw_to_w(20.0)
    100.0
    """
    return float(10.0 ** (dbw / 10.0))

Physical Constants

constants

Physical constants used throughout OpenSatCom.

All constants are in SI units.

.. list-table:: Constants :header-rows: 1

    • Name
    • Value
    • Unit
    • SPEED_OF_LIGHT_MPS
    • 299 792 458
    • m/s
    • BOLTZMANN_DBW_PER_K_HZ
    • -228.6
    • dBW/(K Hz)
    • EARTH_RADIUS_M
    • 6 371 000
    • m

SPEED_OF_LIGHT_MPS module-attribute

SPEED_OF_LIGHT_MPS = 299792458.0

Speed of light in vacuum (m/s).

BOLTZMANN_DBW_PER_K_HZ module-attribute

BOLTZMANN_DBW_PER_K_HZ = -228.6

Boltzmann constant in dBW/(K*Hz).

EARTH_RADIUS_M module-attribute

EARTH_RADIUS_M = 6371000.0

Mean Earth radius (m).