<commit_before>#! /usr/bin/env python

"""
Implementation of the STIM map from [PAI19]

.. [PAI19]
   | Pairet et al, 2019
   | STIM map: detection map for exoplanets imaging beyond asymptotic Gaussian residual speckle noise**
   | *MNRAS, 487, 2262*
   | `doi:10.1093/mnras/stz1350 <http://doi.org/10.1093/mnras/stz1350>`_
"""
__author__ = '<NAME>'
__all__ = ['stim_map',
           'inverse_stim_map']

import numpy as np
from ..preproc import cube_derotate
from ..var import get_circle


def stim_map(cube_der):
    """ Computes the STIM detection map.

    Parameters
    ----------
    cube_der : 3d numpy ndarray
        Input de-rotated cube, e.g. ``residuals_cube_`` output from
        ``vip_hci.pca.pca``.

    Returns
    -------
    detection_map : 2d ndarray
        STIM detection map.
    """
    
    t, n, _ = cube_der.shape
    mu = np.mean(cube_der, axis=0)
    sigma = np.sqrt(np.var(cube_der, axis=0))
    detection_map = np.divide(mu, sigma, out=np.zeros_like(mu),
                              where=sigma != 0)
    return get_circle(detection_map, int(np.round(n/2.)))


def inverse_stim_map(cube, angle_list, **rot_options):
    """ Computes the inverse STIM detection map.

    Parameters
    ----------
    cube : 3d numpy ndarray
        Non de-rotated residuals from reduction algorithm, eg. output residuals
        from ``vip_hci.pca.pca``.
    angle_list : numpy ndarray, 1d
        Corresponding parallactic angle for each frame.  
    rot_options: dictionary, optional
        Dictionary with optional keyword values for "nproc", "imlib", 
        "interpolation, "border_mode", "mask_val",  "edge_blend", 
        "interp_zeros", "ker" (see documentation of 
        ``vip_hci.preproc.frame_rotate``)
        
    Returns
    -------
    inv_stim_map : 2d ndarray
        Inverse STIM detection map.
    """
    
    t, n, _ = cube.shape
    cube_inv_der = cube_derotate(cube, -angle_list, **rot_options)<commit_msg>Updated description of stim map routine<commit_after>#! /usr/bin/env python

"""
Implementation of the STIM map from [PAI19]

.. [PAI19]
   | Pairet et al, 2019
   | STIM map: detection map for exoplanets imaging beyond asymptotic Gaussian residual speckle noise**
   | *MNRAS, 487, 2262*
   | `doi:10.1093/mnras/stz1350 <http://doi.org/10.1093/mnras/stz1350>`_
"""
__author__ = '<NAME>'
__all__ = ['stim_map',
           'inverse_stim_map']

import numpy as np
from ..preproc import cube_derotate
from ..var import get_circle


def stim_map(cube_der):
    """ Computes the STIM detection map.

    Parameters
    ----------
    cube_der : 3d numpy ndarray
        Input de-rotated cube, e.g. ``residuals_cube_`` output from
        ``vip_hci.psfsub.pca``.

    Returns
    -------
    detection_map : 2d ndarray
        STIM detection map.
    """
    
    t, n, _ = cube_der.shape
    mu = np.mean(cube_der, axis=0)
    sigma = np.sqrt(np.var(cube_der, axis=0))
    detection_map = np.divide(mu, sigma, out=np.zeros_like(mu),
                              where=sigma != 0)
    return get_circle(detection_map, int(np.round(n/2.)))


def inverse_stim_map(cube, angle_list, **rot_options):
    """ Computes the inverse STIM detection map.

    Parameters
    ----------
    cube : 3d numpy ndarray
        Non de-rotated residuals from reduction algorithm, eg. 
        ``residuals_cube`` output from ``vip_hci.psfsub.pca``.
    angle_list : numpy ndarray, 1d
        Corresponding parallactic angle for each frame.  
    rot_options: dictionary, optional
        Dictionary with optional keyword values for "nproc", "imlib", 
        "interpolation, "border_mode", "mask_val",  "edge_blend", 
        "interp_zeros", "ker" (see documentation of 
        ``vip_hci.preproc.frame_rotate``)
        
    Returns
    -------
    inv_stim_map : 2d ndarray
        Inverse STIM detection map.
    """
    
    t, n, _ = cube.shape
    cube_inv_der = cube_derotate(cube, -angle_list, **rot_options)
{'fraction_non_alphanumeric': 0.12474645030425964, 'fraction_numerical': 0.02231237322515213, 'mean_word_length': 2.531781557743957, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5029799', 'n_tokens_mistral': 1445, 'n_tokens_neox': 1325, 'n_words': 338}