σ
ίΘ[c           @` sΓ   d  d l  m Z m Z m Z m Z d  d l Z d  d l m Z d d l	 m
 Z
 d d l m Z m Z d d l m Z d d	 l m Z m Z d d
 l m Z d g Z d Z d e
 f d     YZ d S(   i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   deepcopyi   (   t
   NDDataBase(   t   NDUncertaintyt   UnknownUncertaintyi   (   t   log(   t   Unitt   Quantity(   t   MetaDatau   NDDatau<   `dict`-like : Additional meta information about the dataset.t   NDDatac           B` sΏ   e  Z d  Z e d e d e  Z d d d d d e d  Z d   Z	 d   Z
 e d    Z e d    Z e j d    Z e d	    Z e d
    Z e d    Z e j d    Z RS(   uΩ  
    A container for `numpy.ndarray`-based datasets, using the
    `~astropy.nddata.NDDataBase` interface.

    The key distinction from raw `numpy.ndarray` is the presence of
    additional metadata such as uncertainty, mask, unit, a coordinate system
    and/or a dictionary containing further meta information. This class *only*
    provides a container for *storing* such datasets. For further functionality
    take a look at the ``See also`` section.

    Parameters
    -----------
    data : `numpy.ndarray`-like or `NDData`-like
        The dataset.

    uncertainty : any type, optional
        Uncertainty in the dataset.
        Should have an attribute ``uncertainty_type`` that defines what kind of
        uncertainty is stored, for example ``"std"`` for standard deviation or
        ``"var"`` for variance. A metaclass defining such an interface is
        `NDUncertainty` - but isn't mandatory. If the uncertainty has no such
        attribute the uncertainty is stored as `UnknownUncertainty`.
        Defaults to ``None``.

    mask : any type, optional
        Mask for the dataset. Masks should follow the ``numpy`` convention that
        **valid** data points are marked by ``False`` and **invalid** ones with
        ``True``.
        Defaults to ``None``.

    wcs : any type, optional
        World coordinate system (WCS) for the dataset.
        Default is ``None``.

    meta : `dict`-like object, optional
        Additional meta information about the dataset. If no meta is provided
        an empty `collections.OrderedDict` is created.
        Default is ``None``.

    unit : `~astropy.units.Unit`-like or str, optional
        Unit for the dataset. Strings that can be converted to a
        `~astropy.units.Unit` are allowed.
        Default is ``None``.

    copy : `bool`, optional
        Indicates whether to save the arguments as copy. ``True`` copies
        every attribute before saving it while ``False`` tries to save every
        parameter as reference.
        Note however that it is not always possible to save the input as
        reference.
        Default is ``False``.

        .. versionadded:: 1.2

    Raises
    ------
    TypeError
        In case ``data`` or ``meta`` don't meet the restrictions.

    Notes
    -----
    Each attribute can be accessed through the homonymous instance attribute:
    ``data`` in a `NDData` object can be accessed through the `data`
    attribute::

        >>> from astropy.nddata import NDData
        >>> nd = NDData([1,2,3])
        >>> nd.data
        array([1, 2, 3])

    Given a conflicting implicit and an explicit parameter during
    initialization, for example the ``data`` is a `~astropy.units.Quantity` and
    the unit parameter is not ``None``, then the implicit parameter is replaced
    (without conversion) by the explicit one and a warning is issued::

        >>> import numpy as np
        >>> import astropy.units as u
        >>> q = np.array([1,2,3,4]) * u.m
        >>> nd2 = NDData(q, unit=u.cm)
        INFO: overwriting Quantity's current unit with specified unit. [astropy.nddata.nddata]
        >>> nd2.data  # doctest: +FLOAT_CMP
        array([1., 2., 3., 4.])
        >>> nd2.unit
        Unit("cm")

    See also
    --------
    NDDataRef
    NDDataArray
    t   doct   copyc         C` sK  t  t |   j   t | t  r| d  k	 r\ | j d  k	 r\ | | j k r\ t j d  n | j d  k	 rw | j } n  | d  k	 r’ | j d  k	 r’ t j d  n | j d  k	 r½ | j } n  | d  k	 rθ | j	 d  k	 rθ t j d  n | j	 d  k	 r| j	 } n  | d  k	 r.| j
 d  k	 r.t j d  n | j
 d  k	 rI| j
 } n  | d  k	 rt| j d  k	 rtt j d  n | j d  k	 r| j } n  | j } n t | d  rκt | d  rκ| d  k	 rΥt j d  n	 | j	 } | j } n  t | t  r9| d  k	 r$| | j k r$t j d	  n	 | j } | j } n  t | d
  sit | d  sit | d  rt j | d t d t } n  | j d k r₯t d   n  | d  k	 rΐt |  } n  | rt |  } t |  } t |  } t |  } t |  } t |  } n  | |  _ | |  _	 | |  _ | |  _ | |  _ | |  _ d  S(   Nu6   overwriting NDData's current unit with specified unit.uD   overwriting NDData's current uncertainty with specified uncertainty.u6   overwriting NDData's current mask with specified mask.u4   overwriting NDData's current wcs with specified wcs.u6   overwriting NDData's current meta with specified meta.u   masku   datau>   overwriting Masked Objects's current mask with specified mask.u8   overwriting Quantity's current unit with specified unit.u   shapeu   __getitem__u	   __array__t   subokR   u   Ou&   could not convert data to numpy array.(   t   superR   t   __init__t
   isinstancet   Nonet   unitR   t   infot   uncertaintyt   maskt   wcst   metat   datat   hasattrR
   t   valuet   npt   arrayt   Truet   Falset   dtypet	   TypeErrorR	   R   t   _datat   _wcst   _unit(   t   selfR   R   R   R   R   R   R   (    (    s4   lib/python2.7/site-packages/astropy/nddata/nddata.pyR   u   sl    		 					c         C` s   t  |  j  S(   N(   t   strR   (   R&   (    (    s4   lib/python2.7/site-packages/astropy/nddata/nddata.pyt   __str__θ   s    c         C` sD   |  j  j d } t j |  j d d d | } d j | | d g  S(   Nu   (t	   separatoru   , t   prefixu    u   )(   t	   __class__t   __name__R   t   array2stringR   t   join(   R&   R*   t   body(    (    s4   lib/python2.7/site-packages/astropy/nddata/nddata.pyt   __repr__λ   s    c         C` s   |  j  S(   u=   
        `~numpy.ndarray`-like : The stored dataset.
        (   R#   (   R&   (    (    s4   lib/python2.7/site-packages/astropy/nddata/nddata.pyR   π   s    c         C` s   |  j  S(   uΗ   
        any type : Mask for the dataset, if any.

        Masks should follow the ``numpy`` convention that valid data points are
        marked by ``False`` and invalid ones with ``True``.
        (   t   _mask(   R&   (    (    s4   lib/python2.7/site-packages/astropy/nddata/nddata.pyR   χ   s    c         C` s   | |  _  d  S(   N(   R1   (   R&   R   (    (    s4   lib/python2.7/site-packages/astropy/nddata/nddata.pyR     s    c         C` s   |  j  S(   uG   
        `~astropy.units.Unit` : Unit for the dataset, if any.
        (   R%   (   R&   (    (    s4   lib/python2.7/site-packages/astropy/nddata/nddata.pyR     s    c         C` s   |  j  S(   uU   
        any type : A world coordinate system (WCS) for the dataset, if any.
        (   R$   (   R&   (    (    s4   lib/python2.7/site-packages/astropy/nddata/nddata.pyR     s    c         C` s   |  j  S(   uc  
        any type : Uncertainty in the dataset, if any.

        Should have an attribute ``uncertainty_type`` that defines what kind of
        uncertainty is stored, such as ``'std'`` for standard deviation or
        ``'var'`` for variance. A metaclass defining such an interface is
        `~astropy.nddata.NDUncertainty` but isn't mandatory.
        (   t   _uncertainty(   R&   (    (    s4   lib/python2.7/site-packages/astropy/nddata/nddata.pyR     s    
c         C` s   | d  k	 r t | d  s= t j d  t | d t } n  t | t  r | j d  k	 rs | j	 | d t } n  |  | _
 q n  | |  _ d  S(   Nu   uncertainty_typeu3   uncertainty should have attribute uncertainty_type.R   (   R   R   R   R   R   R    R   R   t   _parent_nddataR+   t   parent_nddataR2   (   R&   R   (    (    s4   lib/python2.7/site-packages/astropy/nddata/nddata.pyR     s    N(   R,   t
   __module__t   __doc__R   t	   _meta_docR    R   R   R   R(   R0   t   propertyR   R   t   setterR   R   R   (    (    (    s4   lib/python2.7/site-packages/astropy/nddata/nddata.pyR      s   Z	r		
(   t
   __future__R    R   R   R   t   numpyR   R   R   t   nddata_baseR   t   nduncertaintyR   R   t    R   t   unitsR	   R
   t   utils.metadataR   t   __all__R7   R   (    (    (    s4   lib/python2.7/site-packages/astropy/nddata/nddata.pyt   <module>   s   "	