
    IR-eg                         d dl ZddZddZdS )    NT   c                    t          j        |           } t          j        |          }| j        dk    rt          d          |j        dk    rt          d          |dk    r|st          d          |rt          j        |           g}ng }t          d|dz             D ]|}|                    t          j        dt           j        z  |z  |z  | z                       |                    t          j	        dt           j        z  |z  |z  | z                       }t          j
        |          }|||z  }t          j        |          S )a  Compute the Lomb-Scargle design matrix at the given frequency.

    This is the matrix X such that the periodic model at the given frequency
    can be expressed :math:`\hat{y} = X \theta`.

    Parameters
    ----------
    t : array-like, shape=(n_times,)
        times at which to compute the design matrix
    frequency : float
        frequency for the design matrix
    dy : float or array-like, optional
        data uncertainties: should be broadcastable with `t`
    bias : bool (default=True)
        If true, include a bias column in the matrix
    nterms : int (default=1)
        Number of Fourier terms to include in the model

    Returns
    -------
    X : ndarray, shape=(n_times, n_parameters)
        The design matrix, where n_parameters = bool(bias) + 2 * nterms
    r   zt should be one dimensionalr   zfrequency must be a scalarz cannot have nterms=0 and no bias   )npasarrayndim
ValueError	ones_likerangeappendsinpicosvstack	transpose)t	frequencydybiasntermscolsiXTs           _lib/python3.11/site-packages/astropy/timeseries/periodograms/lombscargle/implementations/mle.pydesign_matrixr      s<   0 	
1A
9%%Iv{{6777~5666{{4{;<<< Q 1fqj!! ; ;BF1ru9q=94q899:::BF1ru9q=94q899::::	4B	~
b<    c                    t          t          j        | ||f          \  } }}|t          j        |          }nt          j        |          }t          j        |          }| j        dk    rt          d          |j        dk    rt          d          |j        dk    rt          d          |r5|dz  }t          j        ||          |                                z  }	||	z
  }nd}	t          | ||||          }
t          j	        
                    t          j        |
j        |
          t          j        |
j        ||z                      }t          ||||	          }|	t          j        ||          z   S )
a  Compute the Lomb-Scargle model fit at a given frequency.

    Parameters
    ----------
    t, y, dy : float or array-like
        The times, observations, and uncertainties to fit
    frequency : float
        The frequency at which to compute the model
    t_fit : float or array-like
        The times at which the fit should be computed
    center_data : bool (default=True)
        If True, center the input data before applying the fit
    fit_mean : bool (default=True)
        If True, include the bias as part of the model
    nterms : int (default=1)
        The number of Fourier terms to include in the fit

    Returns
    -------
    y_fit : ndarray
        The model fit evaluated at each value of t_fit
    Nr   z"t, y, dy should be one dimensionalzt_fit should be one dimensionalr   zfrequency should be a scalarg       )r   r   r   )r   r   )mapr   r   r
   r   r	   dotsumr   linalgsolveT)r   yr   r   t_fitcenter_datafit_meanr   wy_meanX	theta_MLEX_fits                r   periodic_fitr-   7   sW   . "*q!Y&788OAq)	z\!__Z^^JuEv{{=>>>zQ:;;;~7888 H1'JarHHHA	qsAqsAF0C0CDDI%&IIIEBF5),,,,r   )NTr   )TTr   )numpyr   r   r-    r   r   <module>r0      sD       0 0 0 0f2- 2- 2- 2- 2- 2-r   