ó
;c]c           @` s   d  Z  d d l m Z m Z m Z d d l m Z d d l m Z d a
 d   Z d e f d     YZ e d	 d
 d d  Z e j e  d S(   s     Plugin for reading FITS files.
i    (   t   absolute_importt   print_functiont   divisioni   (   t   formats(   t   Formatc           C` s8   y d d l  m a Wn t k
 r3 t d   n Xt S(   Ni    (   t   fitsso   The FITS format relies on the astropy package.Please refer to http://www.astropy.org/ for further instructions.(   t
   astropy.ioR   t   _fitst   ImportError(    (    (    s3   lib/python2.7/site-packages/imageio/plugins/fits.pyt   load_lib   s    t
   FitsFormatc           B` s9   e  Z d  Z d   Z d   Z d e j f d     YZ RS(   sB	   Flexible Image Transport System (FITS) is an open standard defining a
    digital file format useful for storage, transmission and processing of
    scientific and other images. FITS is the most commonly used digital
    file format in astronomy.
    
    This format requires the ``astropy`` package.

    Parameters for reading
    ----------------------
    cache : bool
        If the file name is a URL, `~astropy.utils.data.download_file` is used
        to open the file.  This specifies whether or not to save the file
        locally in Astropy's download cache (default: `True`).
    uint : bool
        Interpret signed integer data where ``BZERO`` is the
        central value and ``BSCALE == 1`` as unsigned integer
        data.  For example, ``int16`` data with ``BZERO = 32768``
        and ``BSCALE = 1`` would be treated as ``uint16`` data.

        Note, for backward compatibility, the kwarg **uint16** may
        be used instead.  The kwarg was renamed when support was
        added for integers of any size.
    ignore_missing_end : bool
        Do not issue an exception when opening a file that is
        missing an ``END`` card in the last header.
    checksum : bool or str
        If `True`, verifies that both ``DATASUM`` and
        ``CHECKSUM`` card values (when present in the HDU header)
        match the header and data of all HDU's in the file.  Updates to a
        file that already has a checksum will preserve and update the
        existing checksums unless this argument is given a value of
        'remove', in which case the CHECKSUM and DATASUM values are not
        checked, and are removed when saving changes to the file.
    disable_image_compression : bool, optional
        If `True`, treats compressed image HDU's like normal
        binary table HDU's.
    do_not_scale_image_data : bool
        If `True`, image data is not scaled using BSCALE/BZERO values
        when read.
    ignore_blank : bool
        If `True`, the BLANK keyword is ignored if present.
    scale_back : bool
        If `True`, when saving changes to a file that contained scaled
        image data, restore the data to the original type and reapply the
        original BSCALE/BZERO values.  This could lead to loss of accuracy
        if scaling back to integer values after performing floating point
        operations on the data.
    c         C` s   | j  |  j k S(   N(   t	   extensiont
   extensions(   t   selft   request(    (    s3   lib/python2.7/site-packages/imageio/plugins/fits.pyt	   _can_readO   s    c         C` s   t  S(   N(   t   False(   R   R   (    (    s3   lib/python2.7/site-packages/imageio/plugins/fits.pyt
   _can_writeT   s    t   Readerc           B` s8   e  Z e d   Z d   Z d   Z d   Z d   Z RS(   c         K` sŋ   t  s t   n  t  j |  j j   d | | } g  |  _ t  j t  j t  j f } x] t	 t
 t |   |  D]@ \ } } t | |  rn | j d k rŪ |  j j |  qŪ qn qn W| |  _ d  S(   Nt   cachei    (   R   R	   t   openR   t   get_filet   _indext   ImageHDUt
   PrimaryHDUt   CompImageHDUt   zipt   ranget   lent
   isinstancet   sizet   appendt   _hdulist(   R   R   t   kwargst   hdulistt   allowed_hdu_typest   nt   hdu(    (    s3   lib/python2.7/site-packages/imageio/plugins/fits.pyt   _open[   s    
!	(c         C` s   |  j  j   d  S(   N(   R    t   close(   R   (    (    s3   lib/python2.7/site-packages/imageio/plugins/fits.pyt   _closej   s    c         C` s   t  |  j  S(   N(   R   R   (   R   (    (    s3   lib/python2.7/site-packages/imageio/plugins/fits.pyt   _get_lengthm   s    c         C` sQ   | d k  s! | t  |  j  k r0 t d   n  |  j |  j | j } | i  f S(   Ni    s*   Index out of range while reading from fits(   R   R   t
   IndexErrorR    t   data(   R   t   indext   im(    (    s3   lib/python2.7/site-packages/imageio/plugins/fits.pyt	   _get_datap   s    !c         C` s   t  d   d  S(   Ns+   The fits format does not support meta data.(   t   RuntimeError(   R   R,   (    (    s3   lib/python2.7/site-packages/imageio/plugins/fits.pyt   _get_meta_datax   s    (   t   __name__t
   __module__R   R&   R(   R)   R.   R0   (    (    (    s3   lib/python2.7/site-packages/imageio/plugins/fits.pyR   Z   s
   			(   R1   R2   t   __doc__R   R   R   R   (    (    (    s3   lib/python2.7/site-packages/imageio/plugins/fits.pyR
      s   1		R   s-   Flexible Image Transport System (FITS) formats   fits fit fts fzt   iIvVN(   R3   t
   __future__R    R   R   t    R   t   coreR   t   NoneR   R	   R
   t   formatt
   add_format(    (    (    s3   lib/python2.7/site-packages/imageio/plugins/fits.pyt   <module>   s   	b