"""
Reflection
==========

The reflection module contains functions for calculating reflection factors and impedances.
"""
import numpy as np
import matplotlib.pyplot as plt
from scipy.special import erfc  # pylint: disable=no-name-in-module

SPECIFIC_HEAT_RATIO = 1.4
r"""Specific heat ratio of air :math:`\gamma`."""
POROSITY_DECREASE = 120.0
r"""Rate of exponential decrease of porosity with depth :math:`\alpha`."""
SOUNDSPEED = 343.0
"""Speed of sound in air :math:`c`."""
DENSITY = 1.296
r"""Density of air :math:`\rho`."""


class Boundary:
    """
    An object describing a boundary.
    """

    def __init__(  # pylint: disable=too-many-instance-attributes
            self,
            frequency,
            flow_resistivity,
            density=DENSITY,
            soundspeed=SOUNDSPEED,
            porosity_decrease=POROSITY_DECREASE,
            specific_heat_ratio=SPECIFIC_HEAT_RATIO,
            angle=None,
            distance=None,
            impedance_model='db',
            reflection_model='plane',
    ):

        self.frequency = frequency
        """
        Frequency. Single value or vector for a frequency range.
        """

        self.flow_resistivity = flow_resistivity
        r"""
        Flow resistivity :math:`\sigma`.
        """

        self.density = density
        r"""
        Density of air :math:`\rho`.

        .. note::

            This value is only required for when calculating the impedance according to Attenborough's model.
            See :func:`impedance_attenborough`.

        """

        self.soundspeed = soundspeed
        """
        Speed of sound in air :math:`c`.

        .. note::

            This value is required when calculating the impedance according to Attenborough's model or when
            calculating the spherical wave reflection factor. See respectively :func:`impedance_attenborough`
            and :func:`reflection_factor_spherical_wave`.

        """

        self.porosity_decrease = porosity_decrease
        r"""
        Rate of exponential decrease of porosity with depth :math:`\alpha`.

        .. note::

            This value is only required for when calculating the impedance according to Attenborough's model.
            See :func:`impedance_attenborough`.

        """

        self.specific_heat_ratio = specific_heat_ratio
        r"""
        Ratio of specific heats :math:`\gamma` for air.

        .. note::

            This value is only required for when calculating the impedance according to Attenborough's model.