U
    d»{j
  ã                   @   s,   d dl ZddddgZddd„Zdd	d
„ZdS )é    NÚstandardÚpsdÚmodelÚlogTc                 C   s^   |dkrd}t  | |¡\} }|d }|s,|rBt  || ¡| ¡  }nd}| | | }t  ||¡S )a  Compute the reference chi-square for a particular dataset.

    Note: this is not valid center_data=False and fit_mean=False.

    Parameters
    ----------
    y : array-like
        data values
    dy : float, array, or None, optional
        data uncertainties
    center_data : bool
        specify whether data should be pre-centered
    fit_mean : bool
        specify whether model should fit the mean of the data

    Returns
    -------
    chi2_ref : float
        The reference chi-square for the periodogram of this data
    Né   g       Àr   )ÚnpZbroadcast_arraysÚdotÚsum)ÚyZdyZcenter_dataZfit_meanÚwÚmuZyw© r   úp/var/www/html/bwave/python/venv/lib/python3.8/site-packages/astropy/timeseries/periodograms/lombscargle/utils.pyÚcompute_chi2_ref   s    r   c                 C   s<  t  | ¡} ||f}|D ]}|tkrt|› d�ƒ‚q||kr>| S d|krV|dkrVtdƒ‚|dkrndt  |  ¡ S |dkr†t  d|  ¡ S |dkrœt  | ¡d S |d	kr²t  | d ¡S |d
krÆ| d|   S |dkrÚ| d|   S |dk� rütd| |  |d|d�S |dk�r"t| ||dd�}d| | S td|› d|› d�ƒ‚dS )ah  Convert power from one normalization to another.

    This currently only works for standard & floating-mean models.

    Parameters
    ----------
    Z : array-like
        the periodogram output
    N : int
        the number of data points
    from_normalization, to_normalization : str
        the normalization to convert from and to. Options are
        ['standard', 'model', 'log', 'psd']
    chi2_ref : float
        The reference chi-square, required for converting to or from the
        psd normalization.

    Returns
    -------
    Z_out : ndarray
        The periodogram in the new normalization
    z is not a valid normalizationr   NzHmust supply reference chi^2 when converting to or from psd normalization)r   r   r   )r   r   )r   r   )r   r   )r   r   )r   r   é   r   )Úfrom_normalizationÚto_normalizationg      à?zconversion from 'z' to 'ú')r   ZasarrayÚNORMALIZATIONSÚ
ValueErrorÚexpr   Úconvert_normalizationÚNotImplementedError)ÚZÚNr   r   Zchi2_refZfrom_toZnormZ
Z_standardr   r   r   r   '   sR    
ÿ

ü
   ÿÿr   )NTT)N)Únumpyr   r   r   r   r   r   r   r   Ú<module>   s   
!