a
    a                     @   s   d Z ddlZdd ZdS )z9Tools for spectral analysis of unequally sampled signals.    Nc                 C   s  | j |j krtdt|}t| }t| }t|j d D ]}d}d}d}	d}
d}t|| |  |dd< t|| |  |dd< t| j d D ]h}||| ||  7 }||| ||  7 }|	|| ||  7 }	|
|| ||  7 }
||| ||  7 }q|| dkrt td| |	|
 d||   }t|| | }t|| | }|| }|| }d| | }d|| ||  d ||	 ||  ||
   || ||  d ||
 ||  ||	     ||< q@|S )a"  
    _lombscargle(x, y, freqs)

    Computes the Lomb-Scargle periodogram.

    Parameters
    ----------
    x : array_like
        Sample times.
    y : array_like
        Measurement values (must be registered so the mean is zero).
    freqs : array_like
        Angular frequencies for output periodogram.

    Returns
    -------
    pgram : array_like
        Lomb-Scargle periodogram.

    Raises
    ------
    ValueError
        If the input arrays `x` and `y` do not have the same shape.

    See also
    --------
    lombscargle

    z'Input arrays do not have the same size.r   g        N   g      ?)	shape
ValueErrornpZ
empty_likerangecossinZeroDivisionErrorZarctan2)xyZfreqsZpgramcsiZxcxsccsscsjtauZc_tauZs_tauZc_tau2Zs_tau2Zcs_tau r   f/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/site-packages/scipy/signal/_spectral.py_lombscargle	   sF     


 r   )__doc__Znumpyr   r   r   r   r   r   <module>   s   