B
    îq\û  ã               @   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 : boolean
        specify whether data should be pre-centered
    fit_mean : boolean
        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ÚwZmuZyw© r   ú>lib/python3.7/site-packages/astropy/stats/lombscargle/utils.pyÚcompute_chi2_ref   s    r   c             C   s:  t  | ¡} ||f}x"|D ]}|tkrtd |¡ƒ‚qW ||krB| S d|krZ|dkrZtdƒ‚|dkrrd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S )ap  Convert power from one normalization to another.

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

    Parameters
    ----------
    Z : array_like
        the periodogram output
    N : integer
        the number of data points
    from_normalization, to_normalization : strings
        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 {0} 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 '{0}' to '{1}')	r   ZasarrayÚNORMALIZATIONSÚ
ValueErrorÚformatZexpr   Úconvert_normalizationÚNotImplementedError)ÚZÚNr   r   Zchi2_refZfrom_toZnormZ
Z_standardr   r   r   r   (   sD    



r   )NTT)N)Znumpyr   r   r   r   r   r   r   r   Ú<module>   s   
"