
[c           @   s  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l 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 m Z m Z m Z m Z m Z m Z m Z m Z d d l m Z m Z d	 d
 l m Z m Z d	 d l m  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+ d e, f d     YZ- e-   Z. i d d 6d d 6d d 6d d 6d d 6d d 6Z/ i	 d d 6d d 6d d 6d d 6d d  6d d 6d d! 6d d 6d d 6Z0 d" e1 f d#     YZ2 d$   Z3 d% e4 f d&     YZ5 e e5  d' e, f d(     Y Z6 e6 Z7 e6 j8 Z8 e6 j9 Z9 d) e6 f d*     YZ: d+ e6 e f d,     YZ; d- e6 e f d.     YZ< d/ e< f d0     YZ= e= Z> d1 e= f d2     YZ? e? Z@ d S(3   i(   t   divisionNi   (   t   conf(   t   _File(   t   Headert   _pad_length(	   t   _is_intt   _is_pseudo_unsignedt   _unsigned_zerot   itersubclassest   decode_asciit   _get_array_mmapt   firstt   _free_space_checkt   _extract_number(   t   _Verifyt   _ErrListi   (   t   string_typest   add_metaclass(   t   range(   t   lazyproperty(   t   suppress(   t	   signaturet	   Parameter(   t   AstropyUserWarning(   t   deprecated_renamed_argumentt   _Delayedc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR      s   t   uint8i   t   int16i   t   int32i    t   int64i@   t   float32it   float64it   uint16t   uint32t   uint64t   InvalidHDUExceptionc           B   s   e  Z d  Z RS(   s   
    A custom exception class used mainly to signal to _BaseHDU.__new__ that
    an HDU cannot possibly be considered valid, and must be assumed to be
    corrupted.
    (   R   R   t   __doc__(    (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR%   3   s   c         C   s   |  } | r x t  t t |     D] } yD | j j d  pL | |  j k sU w% n  | j |  rn | } Pn  Wq% t k
 r q% q% t k
 r } t	 j
 d j |  t  t	 j
 d t  t } ~ Pq% Xq% Wn  | S(   s   
    Used primarily by _BaseHDU.__new__ to find an appropriate HDU class to use
    based on values in the header.  See the _BaseHDU.__new__ docstring.
    s   astropy.io.fits.sM   An exception occurred matching an HDU header to the appropriate HDU type: {0}s%   The HDU will be treated as corrupted.(   t   reversedt   listR   R   t
   startswitht   _hdu_registryt   match_headert   NotImplementedErrort	   Exceptiont   warningst   warnt   formatR   t   _CorruptedHDU(   t   clst   headert   klasst   ct   exc(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt   _hdu_class_from_header;   s.    	t   _BaseHDUMetac           B   s   e  Z d    Z RS(   c         C   sf   d | k rb | d } t  | t t f  rb | j d  k rb d   } t |  d | j |   qb n  d  S(   Nt   datac         S   sW   |  j  d  k	 rS |  j rS t j |  j  } |  j d =| d k rS |  j  j   qS n  d  S(   NR9   i   (   t   _filet   Nonet   _data_loadedt   syst   getrefcountR9   t   __dict__t   _maybe_close_mmap(   t   selft   data_refcount(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR9   j   s
    
(   t
   isinstanceR   t   propertyt   fdelR;   t   setattrt   deleter(   R2   t   namet   basest   memberst	   data_propR9   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt   __init__^   s    
	(   R   R   RL   (    (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR8   ]   s   t   _BaseHDUc           B   s  e  Z d  Z e   Z e Z d Z d Z d) d) d  Z
 d) d) d  Z e d    Z e j d    Z e d    Z e j d    Z e d	    Z e j d
    Z e d    Z e j d    Z e d    Z e d    Z e d    Z e d    Z e d    Z e d    Z e e e d   Z e e e d   Z e d d d  d e e d   Z e d) e e d   Z d   Z e e d  Z  d   Z! d d d   Z" d!   Z# d"   Z$ d#   Z% d$   Z& d%   Z' e e d&  Z( d'   Z) e d(  Z* RS(*   s2   Base class for all HDU (header data unit) classes.s    t    c         O   s%   t  |  |  } t t |   j |  S(   s?  
        Iterates through the subclasses of _BaseHDU and uses that class's
        match_header() method to determine which subclass to instantiate.

        It's important to be aware that the class hierarchy is traversed in a
        depth-last order.  Each match_header() should identify an HDU type as
        uniquely as possible.  Abstract types may choose to simply return False
        or raise NotImplementedError to be skipped.

        If any unexpected exceptions are raised while evaluating
        match_header(), the type is taken to be _CorruptedHDU.
        (   R7   t   superRM   t   __new__(   R2   R9   R3   t   argst   kwargsR4   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyRP      s    c         O   s   | d  k r t   } n  | |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ t |  _	 t |  _
 t |  _ t |  _ d |  j k r d |  j k r d |  _ n d |  j k r t |  _ n  d  S(   Nt   DATASUMt   CHECKSUMt   datasum(   R;   R   t   _headerR:   t   _buffert   _header_offsett   _data_offsett
   _data_sizet   Falset   _data_replacedt   _data_needs_rescalet   Truet   _newt   _output_checksum(   RA   R9   R3   RQ   RR   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyRL      s     										c         C   s   |  j  S(   N(   RV   (   RA   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR3      s    c         C   s   | |  _  d  S(   N(   RV   (   RA   t   value(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR3      s    c         C   s   t  |  j j d |  j   S(   Nt   EXTNAME(   t   strRV   t   gett   _default_name(   RA   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyRH      s    c         C   sl   t  | t  s t d   n  t j s6 | j   } n  d |  j k rU | |  j d <n | d f |  j d <d  S(   Ns!   'name' attribute must be a stringRb   s   extension name(   RC   R   t	   TypeErrorR   t   extension_name_case_sensitivet   upperRV   (   RA   Ra   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyRH      s    	c         C   s   |  j  j d d  S(   Nt   EXTVERi   (   RV   Rd   (   RA   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt   ver   s    c         C   sQ   t  |  s t d   n  d |  j k r: | |  j d <n | d f |  j d <d  S(   Ns"   'ver' attribute must be an integerRi   s   extension value(   R   Rf   RV   (   RA   Ra   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyRj      s
    c         C   s   |  j  j d d  S(   Nt   EXTLEVELi   (   RV   Rd   (   RA   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt   level   s    c         C   sQ   t  |  s t d   n  d |  j k r: | |  j d <n | d f |  j d <d  S(   Ns$   'level' attribute must be an integerRk   s   extension level(   R   Rf   RV   (   RA   Ra   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyRl      s
    c         C   sd   |  j  d k pc d |  j k oc |  j d d k pc |  j d d k oc d |  j k oc |  j d t k S(   Nt   PRIMARYt   XTENSIONt   IMAGEt   BINTABLEt   ZIMAGE(   RH   RV   R^   (   RA   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt   is_image   s
    c         C   s   d |  j  k o |  j t k	 S(   NR9   (   R?   R9   t   DELAYED(   RA   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR<      s    c         C   s   |  j  o |  j d  k	 S(   N(   R<   R9   R;   (   RA   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt	   _has_data   s    c         C   s   |  j  j |  d  S(   N(   R*   t   add(   R2   t   hducls(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt   register_hdu   s    c         C   s&   | |  j  k r" |  j  j |  n  d  S(   N(   R*   t   remove(   R2   Rv   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt   unregister_hdu   s    c         C   s
   t   d  S(   N(   R,   (   R2   R3   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR+     s    c         K   s   |  j  | d | d | | S(   s  
        Creates a new HDU object of the appropriate type from a string
        containing the HDU's entire header and, optionally, its data.

        Note: When creating a new HDU from a string without a backing file
        object, the data of that HDU may be read-only.  It depends on whether
        the underlying string was an immutable Python str/bytes object, or some
        kind of read-write memory buffer such as a `memoryview`.

        Parameters
        ----------
        data : str, bytearray, memoryview, ndarray
           A byte string containing the HDU's header and data.

        checksum : bool, optional
           Check the HDU's checksum and/or datasum.

        ignore_missing_end : bool, optional
           Ignore a missing end card in the header data.  Note that without the
           end card the end of the header may be ambiguous and resulted in a
           corrupt HDU.  In this case the assumption is that the first 2880
           block that does not begin with valid FITS header data is the
           beginning of the data.

        kwargs : optional
           May consist of additional keyword arguments specific to an HDU
           type--these correspond to keywords recognized by the constructors of
           different HDU classes such as `PrimaryHDU`, `ImageHDU`, or
           `BinTableHDU`.  Any unrecognized keyword arguments are simply
           ignored.
        t   checksumt   ignore_missing_end(   t   _readfrom_internal(   R2   R9   Rz   R{   RR   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt
   fromstring  s    #c         K   s]   t  | t  s t |  } n  |  j | d | d | | } | j | j | j t j  | S(   s$  
        Read the HDU from a file.  Normally an HDU should be opened with
        :func:`open` which reads the entire HDU list in a FITS file.  But this
        method is still provided for symmetry with :func:`writeto`.

        Parameters
        ----------
        fileobj : file object or file-like object
            Input FITS file.  The file's seek pointer is assumed to be at the
            beginning of the HDU.

        checksum : bool
            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.

        ignore_missing_end : bool
            Do not issue an exception when opening a file that is missing an
            ``END`` card in the last header.
        Rz   R{   (   RC   R   R|   t   seekRY   RZ   t   ost   SEEK_SET(   R2   t   fileobjRz   R{   RR   t   hdu(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt   readfrom-  s    	t   clobbert	   overwrites   2.0t	   exceptionc         C   s?   d d l  m } | |  g  } | j | | d | d | d S(   s  
        Write the HDU to a new file. This is a convenience method to
        provide a user easier output interface if only one HDU needs
        to be written to a file.

        Parameters
        ----------
        name : file path, file object or file-like object
            Output FITS file.  If the file object is already opened, it must
            be opened in a writeable mode.

        output_verify : str
            Output verification option.  Must be one of ``"fix"``,
            ``"silentfix"``, ``"ignore"``, ``"warn"``, or
            ``"exception"``.  May also be any combination of ``"fix"`` or
            ``"silentfix"`` with ``"+ignore"``, ``+warn``, or ``+exception"
            (e.g. ``"fix+warn"``).  See :ref:`verify` for more info.

        overwrite : bool, optional
            If ``True``, overwrite the output file if it exists. Raises an
            ``OSError`` (``IOError`` for Python 2) if ``False`` and the
            output file exists. Default is ``False``.

            .. versionchanged:: 1.3
               ``overwrite`` replaces the deprecated ``clobber`` argument.

        checksum : bool
            When `True` adds both ``DATASUM`` and ``CHECKSUM`` cards
            to the header of the HDU when written to the file.
        i   (   t   HDUListR   Rz   N(   t   hdulistR   t   writeto(   RA   RH   t   output_verifyR   Rz   R   R   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR   S  s    "c            s5  d } d } d } t   t  rg | d k rR   j   } t j   d | } n    }   j   }	 n y t j d d d d   Wn& t k
 r t d j	      n X| d k r  f d   }
 t j
 |
 t d | t  \ } } t    t |  k r  } qn   r  } n  d } t |  }	 t |  |  }  t |  j  } | j   } t j d	   | j j   D k rx* | D] } | | j k r| | =qqWn  |  d
 t d | |  } | | _ | | _ | | _ |	 | _ | j } | t |  | _ | r1| d k r1t | t  r1| j |  n  | S(   s   
        Provides the bulk of the internal implementation for readfrom and
        fromstring.

        For some special cases, supports using a header that was already
        created, and just using the input data for the actual array data.
        i    t   endcardt   dtypet   ubytet   buffers9  The provided object {!r} does not contain an underlying memory buffer.  fromstring() requires an object that supports the buffer interface such as bytes, str (in Python 2.x but not in 3.x), buffer, memoryview, ndarray, etc.  This restriction is to ensure that efficient access to the array/table data is possible.c         3   s=   d } x0 | t     k  r8   | | |  !V| |  7} q	 Wd  S(   Ni    (   t   len(   t   nbytest   idx(   R9   (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt
   block_iter  s    RN   c         s   s   |  ] } | j  Vq d  S(   N(   t   kind(   t   .0t   x(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pys	   <genexpr>  s    R9   R3   Rx   N(    (   R;   RC   R   t   tellR   t   fromfilet   npt   ndarrayRf   R0   t   _from_blocksR^   R   R7   R   RL   t   copyR   t   VAR_KEYWORDt
   parameterst   valuesRs   R:   RW   RX   RY   t   sizeR   RZ   t	   _ValidHDUt   _verify_checksum_datasum(   R2   R9   R3   Rz   R{   RR   t
   hdu_buffert   hdu_fileobjt   header_offsett   data_offsetR   t
   header_strt   sigt
   new_kwargst   keyR   R   (    (   R9   s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR|   {  sT    	"					!c         C   sv   t  | t  r | f } n  |  j rF t j | d | d |  j d | S|  j rn |  j j d | d | d |  Sd Sd S(   sb   
        Return raw array from either the HDU's memory buffer or underlying
        file.
        R   R   t   offsett   shapeN(   RC   t   intRW   R   R   R:   t	   readarrayR;   (   RA   R   t   codeR   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt   _get_raw_data  s    		c         C   s   |  j    |  j |  d  S(   N(   t   _update_uint_scale_keywordst   _update_checksum(   RA   Rz   t   inplace(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt   _prewriteto  s    
c         C   s   |  j  r |  j r t |  j j  r d |  j k rO |  j j d d d d n> d |  j k rz |  j j d d d d n |  j j d d  |  j j d t |  j j  d d n  d S(   se   
        If the data is unsigned int 16, 32, or 64 add BSCALE/BZERO cards to
        header.
        t   TFIELDSt   BSCALEi   t   aftert   GCOUNTt   BZERON(   Rt   t	   _standardR   R9   R   RV   t   setR   (   RA   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR     s    RT   RS   c         C   sn  |  j  j p |  j } | d k r\ | |  j  k r= |  j  | =n  | |  j  k rj|  j  | =qjn| s |  j s | rjd |  j  k s d |  j  k rj| d k r |  j d |  qj| d k r |  j d d d |  qj| d	 k r|  j |  j d | |  j |  j t d
 | d | qj| d k rB|  j d d d
 | d |  qj| rj|  j d d d
 | d |  qjn  d S(   s!  Update the 'CHECKSUM' and 'DATASUM' keywords in the header (or
        keywords with equivalent semantics given by the ``checksum_keyword``
        and ``datasum_keyword`` arguments--see for example ``CompImageHDU``
        for an example of why this might need to be overridden).
        Rx   RT   RS   RU   t   datasum_keywordt   nonstandard_datasumt   blockingt   nonstandardt   testt   checksum_keywordt   standardN(	   RV   t	   _modifiedR<   R_   t   add_datasumt   _datasum_commentt   add_checksumt   _checksum_commentR^   (   RA   Rz   R   R   t   modified(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR     s8    



c         C   sY   |  j  rU |  j rU t |  j j  rU x. d D]# } t t   |  j | =Wd  QXq+ Wn  d  S(   NR   R   (   R   R   (   Rt   R   R   R9   R   R   t   KeyErrorRV   (   RA   t   keyword(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt   _postwriteto*  s
    c         C   s   d } | j  s t t t   | j   } Wd  QX|  j j |  y | j   | } Wq t t f k
 r t t |  j   } q Xn t t |  j   } | | f S(   Ni    (	   t   simulateonlyR   t   AttributeErrort   IOErrorR   RV   t   tofileR   Rc   (   RA   R   R   R   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt   _writeheader3  s    	c         C   s  d } d } | j  sL | j   y | j   } WqL t k
 rH d } qL Xn  |  j s^ |  j r |  j d  k	 r | |  j |  7} n  | d k r t	 |  |  j
 } | j | j d   | t |  7} q n | |  j |  7} | j  s | j   n  | | f S(   Ni    t   ascii(   R   t   flushR   R   R<   R]   R9   R;   t   _writedata_internalR   t   _padding_bytet   writet   encodeR   t   _writedata_direct_copy(   RA   R   R   R   t   padding(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt
   _writedataD  s&    	
	c         C   s0   | j  s | j |  j  n  |  j j |  j j S(   s#  
        The beginning and end of most _writedata() implementations are the
        same, but the details of writing the data array itself can vary between
        HDU types, so that should be implemented in this method.

        Should return the size in bytes of the data written.
        (   R   t
   writearrayR9   R   t   itemsize(   RA   R   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR   j  s    		c         C   sC   |  j  |  j d |  j  } | d k	 r; | j |  | j Sd Sd S(   s  Copies the data directly from one file/buffer to the new file.

        For now this is handled by loading the raw data from the existing data
        (including any padding) via a memory map or from an already in-memory
        buffer and using Numpy's existing file-writing facilities to write to
        the new file.

        If this proves too slow a more direct approach may be used.
        R   i    N(   R   RZ   RY   R;   R   R   (   RA   R   t   raw(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR   w  s
    
c         C   si   y t  j j | j j  } Wn t t f k
 r; d  } n Xt |  |   |  j	 | | |  Wd  QXd  S(   N(
   R   t   patht   dirnameR:   RH   R   Rf   R;   R   t   _writeto_internal(   RA   R   R   R   R   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt   _writeto  s    
c         C   s  | s |  j  re |  j |  \ } } |  j |  \ } } |  j  ra | |  _ | |  _ | |  _ n  d  S|  j } |  j |  j }	 |  j }
 |  j } |  j j r |  j j	 |  |  j |  \ } }	 | |	 }
 nJ | r|  j j	 |  | j
   } | j |  j j |	   | j
   }
 n  |  j r|  j d  k	 r| s?|  j rHd  } n t |  j  } | d  k	 rp| j   q|  j j	 |  j  |  j |  \ }
 } qn | r|  j |  } n  | |  _ |
 |  _ | |  _ t |  _ d  S(   N(   R_   R   R   RX   RY   RZ   RV   R   R:   R~   R   R   t   readR<   R9   R;   R\   R
   R   R   R[   (   RA   R   R   R   R   t   _R   t	   data_sizet   hdrloct   hdrsizet   datloct   datsizet
   array_mmap(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR     sH    											c         C   s1   | r- |  j  r- t |  j  d  k	 r- |  ` n  d  S(   N(   R<   R
   R9   R;   (   RA   t   closed(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt   _close  s    N(+   R   R   R&   R   R*   R^   R   R   Re   R;   RP   RL   RD   R3   t   setterRH   Rj   Rl   Rr   R<   Rt   t   classmethodRw   Ry   R+   R[   R}   R   R   R   R|   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyRM   ~   sX   				&%&V		(				&				AR1   c           B   s/   e  Z d  Z e d    Z d   Z d   Z RS(   sQ  
    A Corrupted HDU class.

    This class is used when one or more mandatory `Card`s are
    corrupted (unparsable), such as the ``BITPIX``, ``NAXIS``, or
    ``END`` cards.  A corrupted HDU usually means that the data size
    cannot be calculated or the ``END`` card is not found.  In the case
    of a missing ``END`` card, the `Header` may also contain the binary
    data

    .. note::
       In future, it may be possible to decipher where the last block
       of the `Header` ends, but this task may be difficult when the
       extension is a `TableHDU` containing ASCII data.
    c         C   s4   |  j  d k	 r# t |  j   |  j S|  j j |  j S(   sE   
        Returns the size (in bytes) of the HDU's data part.
        N(   RW   R;   R   RY   R:   R   (   RA   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR     s    c         C   s   |  j  |  j d f S(   Nt   CorruptedHDU(   RH   Rj   (   RA   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt   _summary	  s    c         C   s   d  S(   N(    (   RA   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt   verify  s    (   R   R   R&   RD   R   R   R   (    (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR1     s   	t   _NonstandardHDUc           B   s_   e  Z d  Z e Z e d    Z e d    Z d   Z	 d   Z
 e d    Z d d  Z RS(   sx  
    A Non-standard HDU class.

    This class is used for a Primary HDU when the ``SIMPLE`` Card has
    a value of `False`.  A non-standard HDU comes from a file that
    resembles a FITS file but departs from the standards in some
    significant way.  One example would be files where the numbers are
    in the DEC VAX internal storage format rather than the standard
    FITS most significant byte first.  The header for this HDU should
    be valid.  The data for this HDU is read from the file as a byte
    stream that begins at the first byte after the header ``END`` card
    and continues until the end of the file.
    c         C   sL   | j  d } | j d k rD d | k r; | j t k r; t St  n t Sd S(   st   
        Matches any HDU that has the 'SIMPLE' keyword but is not a standard
        Primary or Groups HDU.
        i    t   SIMPLEt   GROUPSN(   t   cardsR   Ra   R[   R^   R%   (   R2   R3   t   card(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR+   !  s    	c         C   s4   |  j  d k	 r# t |  j   |  j S|  j j |  j S(   sE   
        Returns the size (in bytes) of the HDU's data part.
        N(   RW   R;   R   RY   R:   R   (   RA   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR   5  s    c         C   s   d } d } | j  sL | j   y | j   } WqL t k
 rH d } qL Xn  |  j d k	 r | j  s | j |  j  | j   t |  j  } q n  | | f S(   s   
        Differs from the base class :class:`_writedata` in that it doesn't
        automatically add padding, and treats the data as a string of raw bytes
        instead of an array.
        i    N(   R   R   R   R   R9   R;   R   R   (   RA   R   R   R   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR   @  s    	
	
c         C   s   |  j  |  j d t |  j  f S(   Nt   NonstandardHDU(   RH   Rj   R   RV   (   RA   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR   [  s    c         C   s   |  j  |  j d |  j  S(   s'   
        Return the file data.
        R   (   R   R   RY   (   RA   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR9   ^  s    R/   c         C   sC   t  g  d d } x* |  j j D] } | j | j |   q W| S(   Nt   unitt   Card(   R   RV   R   t   appendt   _verify(   RA   t   optiont   errsR   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR   f  s    (   R   R   R&   R[   R   R   R+   RD   R   R   R   R   R9   R   (    (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR     s   		R   c           B   sC  e  Z d  Z d+ d+ d+ d  Z e d    Z e d    Z d   Z	 d   Z
 d   Z d d  Z d	   Z d+ d
 d d  Z d+ e d
 d d d  Z d
 d  Z d
 d  Z d   Z d   Z d   Z d d  Z d d
 d  Z d d  Z d d d d g Z d d d d d  d! d" d# d$ d% d& d' d( g Z d)   Z d*   Z RS(,   s:   
    Base class for all HDUs which are not corrupted.
    c         K   s;   t  t |   j d | d |  | d  k	 r7 | |  _ n  d  S(   NR9   R3   (   RO   R   RL   R;   RH   (   RA   R9   R3   RH   RR   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyRL   u  s    c         C   s   t  | j    d k S(   s  
        Matches any HDU that is not recognized as having either the SIMPLE or
        XTENSION keyword in its header's first card, but is nonetheless not
        corrupted.

        TODO: Maybe it would make more sense to use _NonstandardHDU in this
        case?  Not sure...
        R   Rn   (   R   Rn   (   R   t   keys(   R2   R3   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR+   z  s    c         C   s   d } |  j  j d d  } | d k r d } x3 t |  D]% } | |  j  d t | d  } q: W|  j  d } |  j  j d d  } |  j  j d d  } t |  | | | d } n  | S(   sA   
        Size (in bytes) of the data portion of the HDU.
        i    t   NAXISi   t   BITPIXR   t   PCOUNTi   (   RV   Rd   R   Rc   t   abs(   RA   R   t   naxisR   t   bitpixt   gcountt   pcount(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR     s    #c         C   s+   t    } |  j |  d |  j |  d S(   sh   
        Calculates and returns the number of bytes that this HDU will write to
        a file.
        i   (   R   R   R   (   RA   t   f(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt	   filebytes  s    	c         C   sY   t  |  d  rQ |  j rQ i |  j d 6|  j j d 6|  j d 6|  j d 6|  j d 6Sd Sd S(   sx  
        Returns a dictionary detailing information about the locations
        of this HDU within any associated file.  The values are only
        valid after a read or write of the associated file with no
        intervening changes to the `HDUList`.

        Returns
        -------
        dict or None

           The dictionary details information about the locations of
           this HDU within an associated file.  Returns `None` when
           the HDU is not associated with a file.

           Dictionary contents:

           ========== ================================================
           Key        Value
           ========== ================================================
           file       File object associated with the HDU
           filemode   Mode in which the file was opened (readonly, copyonwrite,
                      update, append, ostream)
           hdrLoc     Starting byte location of header in file
           datLoc     Starting byte location of data block in file
           datSpan    Data size including padding
           ========== ================================================
        R:   t   filet   filemodet   hdrLoct   datLoct   datSpanN(   t   hasattrR:   t   modeRX   RY   RZ   R;   (   RA   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt   fileinfo  s
    c         C   sF   |  j  d k	 r! |  j  j   } n d } |  j d | d |  j j    S(   sJ   
        Make a copy of the HDU, both header and data are copied.
        R9   R3   N(   R9   R;   R   t	   __class__RV   (   RA   R9   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR     s    R/   c            s  t  g  d d } t j   t |  t  r< d } |  j } n d } t } |  j | d d  | | |  |  j d d   f d   d	 | |  |  j d
 d d   d | |  |  j	 j
 d
 d  } | d k  rxa t d | d  D]L } d
 t | d  } |  j | | d   t |  j	 | d d | |  q Wx |  j	 D] } | j d
  r7t |  d k r7y5 t | d  }	 |	 d k s|	 | k rt  n  Wqt k
 rd j | |  }
 |  | d  } | j |  j d | d |
 d | d d   qXq7q7Wn  d |  j	 k rkt |  j	 d t  skd }
 d } |  j	 d  } | j |  j | d |
 d | d |  qkn  x* |  j	 j D] } | j | j |   qxW| S(   NR   R   Rn   R   i    R   i   c            s   t  |   o   |   S(   N(   R   (   t   v(   t   is_valid(    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt   <lambda>  s    i   R   i   c         S   s"   t  |   o! |  d k o! |  d k S(   Ni    i  (   R   (   R  (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR    s    i  i   c         S   s   t  |   o |  d k S(   Ni    (   R   (   R  (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR    s    t   defaulti   s3   NAXISj keyword out of range ('{}' when NAXIS == {})c         S   s   |  j  | =d  S(   N(   RV   (   RA   R   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt   fix  s    R   t   err_textR  t   fix_texts   Deleted.Rb   s-   The EXTNAME keyword must have a string value.s0   Converted the EXTNAME keyword to a string value.c         S   s   t  |  d  |  d <d  S(   NRb   (   Rc   (   R3   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR  	  s    (   R   t   BITPIX2DTYPEt   __contains__RC   t   ExtensionHDUt
   _extensionR^   t	   req_cardsR;   RV   Rd   R   Rc   R   R)   R   R   t
   ValueErrorR0   R   t
   run_optionR   R   R   (   RA   R   R   t   firstkeyt   firstvalR   t   axR   R   t   numberR  R  R  R   (    (   R  s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR     sX    	
	
!c            s  | } d } y |  j j |  }	 Wn t k
 r; d }	 n X  d k	 }
 t |  j  d  t |  r |   f d   } n  |	 d k rd j |  } d j |  } |
 r |   f } |   | d  } n  | j |  j | d | d | d | d	 |
  n| d k	 rz| |	  szd
 j | |	  } d j   } |  |	  d  } | j |  j | d | d | d |  qzn  | r|  j | } | |  sd j | |  } d j    } |
 r|  |     f d  } n  | j |  j | d | d | d | d	 |
  qn  | S(   s	  
        Check the existence, location, and value of a required `Card`.

        Parameters
        ----------
        keyword : str
            The keyword to validate

        pos : int, callable
            If an ``int``, this specifies the exact location this card should
            have in the header.  Remember that Python is zero-indexed, so this
            means ``pos=0`` requires the card to be the first card in the
            header.  If given a callable, it should take one argument--the
            actual position of the keyword--and return `True` or `False`.  This
            can be used for custom evaluation.  For example if
            ``pos=lambda idx: idx > 10`` this will check that the keyword's
            index is greater than 10.

        test : callable
            This should be a callable (generally a function) that is passed the
            value of the given keyword and returns `True` or `False`.  This can
            be used to validate the value associated with the given keyword.

        fix_value : str, int, float, complex, bool, None
            A valid value for a FITS keyword to to use if the given ``test``
            fails to replace an invalid value.  In other words, this provides
            a default value to use as a replacement if the keyword's current
            value is invalid.  If `None`, there is no replacement value and the
            keyword is unfixable.

        option : str
            Output verification option.  Must be one of ``"fix"``,
            ``"silentfix"``, ``"ignore"``, ``"warn"``, or
            ``"exception"``.  May also be any combination of ``"fix"`` or
            ``"silentfix"`` with ``"+ignore"``, ``+warn``, or ``+exception"
            (e.g. ``"fix+warn"``).  See :ref:`verify` for more info.

        errlist : list
            A list of validation errors already found in the FITS file; this is
            used primarily for the validation system to collect errors across
            multiple HDUs and multiple calls to `req_cards`.

        Notes
        -----
        If ``pos=None``, the card can be anywhere in the header.  If the card
        does not exist, the new card will have the ``fix_value`` as its value
        when created.  Also check the card's value by using the ``test``
        argument.
        i   c            s
   |    k S(   N(    (   R   (   t
   insert_pos(    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR  Z  s    s   '{}' card does not exist.s#   Fixed by inserting a new '{}' card.c         S   s   |  j  j | |  d  S(   N(   RV   t   insert(   RA   R!  R   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR  e  s    R  R  R  t   fixables'   '{}' card at the wrong place (card {}).s0   Fixed by moving it to the right place (card {}).c         S   s1   |  j  j | } |  j  | =|  j  j | |  d  S(   N(   RV   R   R"  (   RA   t   indexR!  R   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR  s  s    
s!   '{}' card has invalid value '{}'.s"   Fixed by setting a new value '{}'.c            s     |  j  | <d  S(   N(   RV   (   RA   R   t   val(   t	   fix_value(    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR    s    N(	   R;   RV   R$  R  R   R   R0   R   R  (   RA   R   t   posR   R&  R   t   errlistR   R  R$  R#  R  R  R   R%  (    (   R&  R!  s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR    sP    3
		R   RS   c         C   sP   |  j  |  } | d k r3 d j |  j    } n  t |  | f |  j | <| S(   s  
        Add the ``DATASUM`` card to this HDU with the value set to the
        checksum calculated for the data.

        Parameters
        ----------
        when : str, optional
            Comment string for the card that by default represents the
            time when the checksum was calculated

        blocking : str, optional
            "standard" or "nonstandard", compute sum 2880 bytes at a time, or
            not

        datasum_keyword : str, optional
            The name of the header keyword to store the datasum value in;
            this is typically 'DATASUM' per convention, but there exist
            use cases in which a different keyword should be used

        Returns
        -------
        checksum : int
            The calculated datasum

        Notes
        -----
        For testing purposes, provide a ``when`` argument to enable the comment
        value in the card to remain consistent.  This will enable the
        generation of a ``CHECKSUM`` card with a consistent value.
        s   data unit checksum updated {}N(   t   _calculate_datasumR;   R0   t   _get_timestampRc   RV   (   RA   t   whenR   R   t   cs(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR     s
    !RT   c         C   s   | s! |  j  | | d | } n |  j |  } | d k rT d j |  j    } n  | |  j k r |  j j | d | d | n |  j j | d	 |  |  j | | d | } | |  j | <d S(
   sC  
        Add the ``CHECKSUM`` and ``DATASUM`` cards to this HDU with
        the values set to the checksum calculated for the HDU and the
        data respectively.  The addition of the ``DATASUM`` card may
        be overridden.

        Parameters
        ----------
        when : str, optional
           comment string for the cards; by default the comments
           will represent the time when the checksum was calculated

        override_datasum : bool, optional
           add the ``CHECKSUM`` card only

        blocking : str, optional
            "standard" or "nonstandard", compute sum 2880 bytes at a time, or
            not

        checksum_keyword : str, optional
            The name of the header keyword to store the checksum value in; this
            is typically 'CHECKSUM' per convention, but there exist use cases
            in which a different keyword should be used

        datasum_keyword : str, optional
            See ``checksum_keyword``

        Notes
        -----
        For testing purposes, first call `add_datasum` with a ``when``
        argument, then call `add_checksum` with a ``when`` argument and
        ``override_datasum`` set to `True`.  This will provide consistent
        comments for both cards and enable the generation of a ``CHECKSUM``
        card with a consistent value.
        R   s   HDU checksum updated {}t   0i   t   beforeR   Nt   0000000000000000R/  (   R   R)  R;   R0   R*  RV   R   t   _calculate_checksum(   RA   R+  t   override_datasumR   R   R   t   data_cst   csum(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR     s    '
	c         C   sf   d |  j  k r^ |  j |  } | t |  j  d  k r; d S| d k rW |  j d d  Sd Sn d Sd S(	   s  
        Verify that the value in the ``DATASUM`` keyword matches the value
        calculated for the ``DATASUM`` of the current HDU data.

        blocking : str, optional
            "standard" or "nonstandard", compute sum 2880 bytes at a time, or
            not

        Returns
        -------
        valid : int
           - 0 - failure
           - 1 - success
           - 2 - no ``DATASUM`` keyword present
        RS   i   t   eitherR   R   i    i   N(   RV   R)  R   t   verify_datasum(   RA   R   RU   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR5    s    c         C   s   d |  j  k r d |  j  k r0 |  j |  } n d } |  j | |  } | |  j  d k r_ d S| d k r{ |  j d d  Sd Sn d Sd	 S(
   s  
        Verify that the value in the ``CHECKSUM`` keyword matches the
        value calculated for the current HDU CHECKSUM.

        blocking : str, optional
            "standard" or "nonstandard", compute sum 2880 bytes at a time, or
            not

        Returns
        -------
        valid : int
           - 0 - failure
           - 1 - success
           - 2 - no ``CHECKSUM`` keyword present
        RT   RS   i    i   R4  R   R   i   N(   RV   R)  R0  t   verify_checksum(   RA   R   RU   Rz   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR6    s    c         C   s  d |  j  k rl |  j  d |  _ |  j  j d |  _ |  j |  s~ t j d j |  j |  j	 f  t
  q~ n d |  _ d |  _ d |  j  k r |  j  d |  _ |  j  j d |  _ |  j |  st j d j |  j |  j	 f  t
  qn$ d |  _ d |  _ d |  _ d |  _ d S(   s   
        Verify the checksum/datasum values if the cards exist in the header.
        Simply displays warnings if either the checksum or datasum don't match.
        RT   s*   Checksum verification failed for HDU {0}.
RS   s)   Datasum verification failed for HDU {0}.
N(   RV   t	   _checksumt   commentsR   R6  R.   R/   R0   RH   Rj   R   R;   t   _datasumR   R5  (   RA   R   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR   3  s(    
					c         C   s   t  j  j   j   d  S(   s   
        Return the current timestamp in ISO 8601 format, with microseconds
        stripped off.

        Ex.: 2007-05-30T19:05:11
        i   (   t   datetimet   nowt	   isoformat(   RA   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR*  V  s    c         C   s   |  j  sM |  j d k rF |  j |  j d |  j  } |  j | d | Sd Sn2 |  j d k	 r{ |  j |  j j d  d | Sd Sd S(   sJ   
        Calculate the value for the ``DATASUM`` card in the HDU.
        i    R   R   N(	   R<   R   R   RZ   RY   t   _compute_checksumR9   R;   t   view(   RA   R   t   raw_data(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR)  `  s    	c         C   sz   |  j  | } d |  j  | <|  j  j   j d  } |  j t j | d d | d | } |  j |  } | |  j  | <| S(   sJ   
        Calculate the value of the ``CHECKSUM`` card in the HDU.
        R-  i   t   utf8R   R   R   R/  (   RV   t   tostringR   R=  R   t
   frombuffert   _char_encode(   RA   RU   R   R   t   old_checksumt   sR,  (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR0  u  s    	i    c         C   s   i d d 6t  |  d 6d d 6d t 6| } t j |  } xV t d t  |  |  D]< } t | t  |  |  } |  j | | | | !|  } qT W| S(   s  
        Compute the ones-complement checksum of a sequence of bytes.

        Parameters
        ----------
        data
            a memory region to checksum

        sum32
            incremental checksum value from another region

        blocking
            "standard", "nonstandard", or "either"
            selects the block size on which to perform checksumming,
            originally the blocksize was chosen incorrectly.  "nonstandard"
            selects the original approach,  "standard" selects the
            interoperable blocking size of 2880 bytes.  In the context of
            _compute_checksum, "either" is synonymous with "standard".

        Returns
        -------
        ones complement checksum
        i@  R   R   R4  i    (   R   R^   R   R#   R   t   mint   _compute_hdu_checksum(   RA   R9   t   sum32R   t   blocklent   it   length(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR=    s    
!c         C   sn  t  j d  } t  j d  } t  j d  } | j d rQ | d } | d  } n t  j d  } | j d  } | | ?} | | @} | t  j j | d d d  d	 t  j 7} | t  j j | d
 d d  d	 t  j 7} | j d d r | | | >7} n | | | >7} | | ?}	 | | ?}
 x@ |	 s.|
 ra| | @|
 } | | @|	 } | | ?}	 | | ?}
 q"W| | >| S(   s  
        Translated from FITS Checksum Proposal by Seaman, Pence, and Rots.
        Use uint32 literals as a hedge against type promotion to int64.

        This code should only be called with blocks of 2880 bytes
        Longer blocks result in non-standard checksums with carry overflow
        Historically,  this code *was* called with larger blocks and for that
        reason still needs to be for backward compatibility.
        i   i   i  i   ii    s   >u2NR   i   (   R   R#   R   R>  Ru   t   reduceR$   (   RA   R9   RH  t   u8t   u16t   uFFFFt   lastt   hit   lot   hicarryt   locarry(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyRG    s.    


,,


I       i   i   i   i:   i;   i<   i=   i>   i?   i@   i[   i\   i]   i^   i_   i`   c         C   s   | d t  d  } | d } t j | | | | | g d d } t } x | r t } xy |  j D]n } xe d d g D]W } | | | k s | | d | k ru | | c d 7<| | d c d 8<t } qu qu Wqb WqL W| S(   s'   
        Encode a single byte.
        i   R-  R   R   i    i   i   (   t   ordR   t   arrayR^   R[   t   _EXCLUDE(   RA   t   bytet   quotientt	   remaindert   cht   checkR   t   j(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt   _encode_byte  s    
		$c         C   s   t  j |  } t  j d d d } t  j d	 d d } xm t d  D]_ } | |  j | @d | d ?} |  j |  } x* t d  D] } | | | d | | <q WqF Wx* t d  D] } | | d d | | <q Wt | j    S(
   s   
        Encodes the checksum ``value`` using the algorithm described
        in SPR section A.7.2 and returns it as a 16 character string.

        Parameters
        ----------
        value
            a checksum

        Returns
        -------
        ascii encoded checksum
        i   R   RX  i   i   i   i   (   i   (   i   (   R   R#   t   zerosR   t   _MASKR^  R	   RA  (   RA   Ra   t   ascR   RJ  RX  R[  R]  (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyRC    s    N(   R   R   R&   R;   RL   R   R+   RD   R   R  R  R   R   R  R   R[   R   R5  R6  R   R*  R)  R0  R=  RG  R`  RW  R^  RC  (    (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR   p  s<   	
	$	E	v(;"	#	
	$.		R  c           B   sS   e  Z d  Z d Z e d    Z e d d d  d e e d   Z d d	  Z	 RS(
   s   
    An extension HDU class.

    This class is the base class for the `TableHDU`, `ImageHDU`, and
    `BinTableHDU` classes.
    RN   c         C   s
   t   d S(   s   
        This class should never be instantiated directly.  Either a standard
        extension HDU type should be used for a specific extension, or
        NonstandardExtHDU should be used.
        N(   R,   (   R2   R3   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR+   (  s    R   R   s   2.0R   c         C   sU   d d l  m } d d l m } | |   |  g  } | j | | d | d | d S(   s  
        Works similarly to the normal writeto(), but prepends a default
        `PrimaryHDU` are required by extension HDUs (which cannot stand on
        their own).

        .. versionchanged:: 1.3
           ``overwrite`` replaces the deprecated ``clobber`` argument.
        i   (   R   (   t
   PrimaryHDUR   Rz   N(   R   R   t   imageRb  R   (   RA   RH   R   R   Rz   R   Rb  R   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR   2  s
    R/   c         C   sz   t  t |   j d |  } |  j j d d  } |  j d | d d   d | |  |  j d | d d	   d
 | |  | S(   NR   R   i    R   i   c         S   s   t  |   o |  d k S(   Ni    (   R   (   R  (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR  K  s    R   i   c         S   s   t  |   o |  d k S(   Ni   (   R   (   R  (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR  M  s    i   (   RO   R  R   RV   Rd   R  (   RA   R   R   R   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR   E  s    (
   R   R   R&   R  R   R+   R   R[   R   R   (    (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR    s   
t   NonstandardExtHDUc           B   s;   e  Z d  Z e Z e d    Z d   Z e d    Z	 RS(   s  
    A Non-standard Extension HDU class.

    This class is used for an Extension HDU when the ``XTENSION``
    `Card` has a non-standard value.  In this case, Astropy can figure
    out how big the data is but not what it is.  The data for this HDU
    is read from the file as a byte stream that begins at the first
    byte after the header ``END`` card and continues until the
    beginning of the next header or the end of the file.
    c         C   sS   | j  d } | j } t | t  r4 | j   } n  d } | j d k oR | | k S(   sh   
        Matches any extension HDU that is not one of the standard extension HDU
        types.
        i    Ro   t   TABLERp   t   A3DTABLERn   (   Ro   Re  Rp   Rf  (   R   Ra   RC   R   t   rstripR   (   R2   R3   R   t   xtensiont   standard_xtensions(    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR+   f  s    	c         C   s   |  j  |  j d t |  j  f S(   NRd  (   RH   Rj   R   RV   (   RA   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR   z  s    c         C   s   |  j  |  j d |  j  S(   s'   
        Return the file data.
        R   (   R   R   RY   (   RA   (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyR9   }  s    (
   R   R   R&   R[   R   R   R+   R   R   R9   (    (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyRd  X  s
   
	(A   t
   __future__R    R:  R   R=   R.   t   numpyR   RN   R   R  R   R3   R   R   t   utilR   R   R   R   R	   R
   R   R   R   R   R   R   t
   extern.sixR   R   t   extern.six.movesR   t   utilsR   t   utils.compatR   t   utils.compat.funcsigsR   R   t   utils.exceptionsR   t   utils.decoratorsR   t   objectR   Rs   R  t   DTYPE2BITPIXR-   R%   R7   t   typeR8   RM   t   _AllHDURw   Ry   R1   R   R   R  t   _ExtensionHDURd  t   _NonstandardExtHDU(    (    (    s7   lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyt   <module>   sV   @	
	"!  e		%`  7/