# Path: PySpectrograph/Utilities/degreemath.py
# def cosd(x):
#     """Return the cos of x where x is in degrees"""
#     if isinstance(x, numpy.ndarray):
#         return numpy.cos(math.pi * x / 180.0)
#     return math.cos(math.radians(x))
# 
# def sind(x):
#     """Return the sin of x where x is in degrees"""
#     if isinstance(x, numpy.ndarray):
#         return numpy.sin(math.pi * x / 180.0)
#     return math.sin(math.radians(x))


from PySpectrograph.Utilities.degreemath import cosd, sind



def n_index():
    return 1.0000


def gratingequation(sigma, order, sign, alpha, beta, gamma=0, nd=n_index):
    """Apply the grating equation to determine the wavelength
       w = sigma/m cos (gamma) * n_ind *(sin alpha +- sin beta)

       returns wavelength in mm
    """
    angle = cosd(gamma) * nd() * (sind(alpha) + sign * sind(beta))
    return sigma / order * angle


def calc_angdisp(sigma, order, beta, gamma=0):
    """Calculate the angular dispersion according to m/sigma/cos beta

       returns angular dispersion in 1/mm
    """

# Path: PySpectrograph/Utilities/degreemath.py
# def cosd(x):
#     """Return the cos of x where x is in degrees"""
#     if isinstance(x, numpy.ndarray):
#         return numpy.cos(math.pi * x / 180.0)
#     return math.cos(math.radians(x))
# 
# def sind(x):
#     """Return the sin of x where x is in degrees"""
#     if isinstance(x, numpy.ndarray):
#         return numpy.sin(math.pi * x / 180.0)
#     return math.sin(math.radians(x))


# Path: PySpectrograph/Spectrograph/SpectrographEquations.py
from PySpectrograph.Utilities.degreemath import cosd, sind




def n_index():
    return 1.0000


def gratingequation(sigma, order, sign, alpha, beta, gamma=0, nd=n_index):
    """Apply the grating equation to determine the wavelength
       w = sigma/m cos (gamma) * n_ind *(sin alpha +- sin beta)

       returns wavelength in mm
    """
    angle = cosd(gamma) * nd() * (sind(alpha) + sign * sind(beta))
    return sigma / order * angle


def calc_angdisp(sigma, order, beta, gamma=0):
    """Calculate the angular dispersion according to m/sigma/cos beta

       returns angular dispersion in 1/mm
    """

    return order / sigma / cosd(beta) / cosd(gamma)