# Path: vip_hci/var/coords.py
# def frame_center(array, verbose=False):
#     """
#     Return the coordinates y,x of the frame(s) center.
#     If odd: dim/2-0.5
#     If even: dim/2
# 
#     Parameters
#     ----------
#     array : 2d/3d/4d numpy ndarray
#         Frame or cube.
#     verbose : bool optional
#         If True the center coordinates are printed out.
# 
#     Returns
#     -------
#     cy, cx : int
#         Coordinates of the center.
# 
#     """
#     if array.ndim == 2:
#         shape = array.shape
#     elif array.ndim == 3:
#         shape = array[0].shape
#     elif array.ndim == 4:
#         shape = array[0, 0].shape
#     else:
#         raise ValueError('`array` is not a 2d, 3d or 4d array')
# 
#     cy = shape[0] / 2
#     cx = shape[1] / 2
# 
#     if shape[0]%2:
#         cy-=0.5
#     if shape[1]%2:
#         cx-=0.5        
# 
#     if verbose:
#         print('Center px coordinates at x,y = ({}, {})'.format(cx, cy))  
#     
#     return int(cy), int(cx)
# 
# Path: vip_hci/config/utils_conf.py
# def frame_or_shape(data):
#     """
#     Sanitize ``data``, always return a 2d frame.
# 
#     If ``data`` is a 2d frame, it is returned unchanged. If it is a shaped,
#     return an empty array of that shape.
# 
#     Parameters
#     ----------
#     data : 2d ndarray or shape tuple
# 
#     Returns
#     -------
#     array : 2d ndarray
# 
#     """
#     if isinstance(data, np.ndarray):
#         array = data
#         if array.ndim != 2:
#             raise TypeError('`data` is not a frame or 2d array')
#     elif isinstance(data, tuple):
#         array = np.zeros(data)
#     else:
#         raise TypeError('`data` must be a tuple (shape) or a 2d array')
# 
#     return array


import numpy as np
from skimage.draw import polygon
from skimage.draw import disk
from sklearn.preprocessing import scale
from .coords import frame_center
from ..config.utils_conf import frame_or_shape
    a : float
        Semi-major axis.
    b : float
        Semi-minor axis.
    pa : deg, float
        The PA of the semi-major axis in degrees.
    cy, cx : int or None, optional
        Coordinates of the circle center. If ``None``, the center is determined
        by the ``frame_center`` function.
    mode : {'ind', 'val', 'mask', 'bool'}, optional
        Controls what is returned: indices of selected pixels, values of
        selected pixels, or a boolean mask.

    Returns
    -------
    indices : tuple(y, x)
        [mode='ind'] Coordinates of the inner elliptical region.
    values : 1d ndarray
        [mode='val'] Values of the pixels in the inner elliptical region.
    masked : 2d ndarray
        [mode='mask'] Input image where the outer region is masked with ``0``.
    bool_mask : 2d boolean ndarray
        [mode='bool'] A boolean mask where ``True`` is the inner region.

    """

    def distance(yc, xc, y1, x1):
        return np.sqrt((yc - y1) ** 2 + (xc - x1) ** 2)
    # --------------------------------------------------------------------------


# Path: vip_hci/var/coords.py
# def frame_center(array, verbose=False):
#     """
#     Return the coordinates y,x of the frame(s) center.
#     If odd: dim/2-0.5
#     If even: dim/2
# 
#     Parameters
#     ----------
#     array : 2d/3d/4d numpy ndarray
#         Frame or cube.
#     verbose : bool optional
#         If True the center coordinates are printed out.
# 
#     Returns
#     -------
#     cy, cx : int
#         Coordinates of the center.
# 
#     """
#     if array.ndim == 2:
#         shape = array.shape
#     elif array.ndim == 3:
#         shape = array[0].shape
#     elif array.ndim == 4:
#         shape = array[0, 0].shape
#     else:
#         raise ValueError('`array` is not a 2d, 3d or 4d array')
# 
#     cy = shape[0] / 2
#     cx = shape[1] / 2
# 
#     if shape[0]%2:
#         cy-=0.5
#     if shape[1]%2:
#         cx-=0.5        
# 
#     if verbose:
#         print('Center px coordinates at x,y = ({}, {})'.format(cx, cy))  
#     
#     return int(cy), int(cx)
# 
# Path: vip_hci/config/utils_conf.py
# def frame_or_shape(data):
#     """
#     Sanitize ``data``, always return a 2d frame.
# 
#     If ``data`` is a 2d frame, it is returned unchanged. If it is a shaped,
#     return an empty array of that shape.
# 
#     Parameters
#     ----------
#     data : 2d ndarray or shape tuple
# 
#     Returns
#     -------
#     array : 2d ndarray
# 
#     """
#     if isinstance(data, np.ndarray):
#         array = data
#         if array.ndim != 2:
#             raise TypeError('`data` is not a frame or 2d array')
#     elif isinstance(data, tuple):
#         array = np.zeros(data)
#     else:
#         raise TypeError('`data` must be a tuple (shape) or a 2d array')
# 
#     return array


# Path: vip_hci/var/shapes.py
import numpy as np
from skimage.draw import polygon
from skimage.draw import disk
from sklearn.preprocessing import scale
from .coords import frame_center
from ..config.utils_conf import frame_or_shape

    a : float
        Semi-major axis.
    b : float
        Semi-minor axis.
    pa : deg, float
        The PA of the semi-major axis in degrees.
    cy, cx : int or None, optional
        Coordinates of the circle center. If ``None``, the center is determined
        by the ``frame_center`` function.
    mode : {'ind', 'val', 'mask', 'bool'}, optional
        Controls what is returned: indices of selected pixels, values of
        selected pixels, or a boolean mask.

    Returns
    -------
    indices : tuple(y, x)
        [mode='ind'] Coordinates of the inner elliptical region.
    values : 1d ndarray
        [mode='val'] Values of the pixels in the inner elliptical region.
    masked : 2d ndarray
        [mode='mask'] Input image where the outer region is masked with ``0``.
    bool_mask : 2d boolean ndarray
        [mode='bool'] A boolean mask where ``True`` is the inner region.

    """

    def distance(yc, xc, y1, x1):
        return np.sqrt((yc - y1) ** 2 + (xc - x1) ** 2)
    # --------------------------------------------------------------------------


    array = frame_or_shape(data)