def transmission_factor(fd=None, F=None):
    """Calculates either transmission factor from Darcy friction factor,
    or Darcy friction factor from the transmission factor. Raises an exception
    if neither input is given.
    
    Transmission factor is a term used in compressible gas flow in pipelines.

    .. math::
        F = \\frac{2}{\\sqrt{f_d}}

    .. math::
        f_d = \\frac{4}{F^2}

    Parameters
    ----------
    fd : float, optional
        Darcy friction factor, [-]
    F : float, optional
        Transmission factor, [-]

    Returns
    -------
    fd or F : float
        Darcy friction factor or transmission factor [-]

    Examples
    --------
    >>> transmission_factor(fd=0.0185)
    14.704292441876154

    >>> transmission_factor(F=20)
    0.01
    
    References
    ----------
    .. [1] Menon, E. Shashi. Gas Pipeline Hydraulics. 1st edition. Boca Raton, 
       FL: CRC Press, 2005.
    """
    if fd:
        return 2.0 / fd ** 0.5
    elif F:
        return 4.0 / (F * F)
    else:
        raise Exception(
            'Either Darcy friction factor or transmission factor is needed')
