import logging


def basic_ionosphere_params(altitude=300.):
    """ Returns cyclotron frequency, debye length, and plasma frequency in
    ionosphere for a given altitude.

    *PARAMS*:
        [altitude]: In km. Must be in ionosphere for this model to work.
                    Default: 300 km.

    ANGULAR FREQUENCIES BTW

    *RETURNS*:
        omega_p: Plasma frequency (angular)
        omega_c: Cyclotron frequency (angular)
        l_d: Debye length

    Based on:
    https://smallsats.org/2013/03/25/debye-length-plasma-frequency-and-cyclotron-frequency/
    """

    if altitude > 400. or altitude < 200.:
        logging.error("Bad altitude parameter")
        return None

    # Assumed parameters:
    me   = 9.109E-31            #[kg]           Electron rest mass
    mp   = 1.673E-27            #[kg]           Proton rest mass
    eps0 = 8.8542E-12           #[A*s/(V*m)]    Permittivity
    e    = 1.602E-19            #[C]            Elementary charge
    Re   = 6.37E6               #[m]            Earth radius
    Md   = 8E15                 #[T*m3]         Earth magnetic dipole moment

    n   = 1E12                     #[m-3]  Electron density < HIGH >
    kTe = 0.1                      #[eV]   Thermal energy
    r   = Re + altitude*1000.      #[km]   Radial dist from Earth’s center
    omega_p  = ((e**2)*n/(eps0*me))**0.5  #[Hz]   Plasma frequency
    l_d  = (eps0*kTe/(n*e))**0.5     #[m]    Debye length
    B   = 2*Md/(r**3)                #[T]    Earth’s magnetic field
    omega_c  = e*B/(me)            #[Hz]   Cyclotron frequency

    return omega_c, omega_p, l_d