
    1-Ph7                     f    d dgZ ddlmZ 	 ddlmZ n# e$ r  ed          w xY wd Zd
dZd	 ZdS )imreadimread_collection    N)fitszAstropy could not be found. It is needed to read FITS files.
Please refer to https://www.astropy.org for installation
instructions.c                     t          j        |           5 }d}|D ]F}t          |t           j                  st          |t           j                  r|j        	|j        } nGddd           n# 1 swxY w Y   |S )a  Load an image from a FITS file.

    Parameters
    ----------
    fname : string
        Image file name, e.g. ``test.fits``.

    Returns
    -------
    img_array : ndarray
        Unlike plugins such as PIL, where different color bands/channels are
        stored in the third dimension, FITS images are grayscale-only and can
        be N-dimensional, so an array of the native FITS dimensionality is
        returned, without color channels.

        Currently if no image is found in the file, None will be returned

    Notes
    -----
    Currently FITS ``imread()`` always returns the first image extension when
    given a Multi-Extension FITS file; use ``imread_collection()`` (which does
    lazy loading) to get all the extensions at once.

    N)r   open
isinstanceImageHDU
PrimaryHDUdata)fnamehdulist	img_arrayhdus       _/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/skimage/io/_plugins/fits_plugin.pyr   r      s    4 
5		 W 	 	 	C#t}-- C1Q1Q 8' #IE               s   AA--A14A1Tc           	      v   t          |           }|t          ur|t          urt          d          |t          ur| g} g }| D ]}t	          j        |          5 }t          t          t          |                    |          D ]\  }}t          |t          j
                  st          |t          j                  rJ	 |j        }n$# t          $ r |                                }Y nw xY w|dk    r|                    ||f           	 ddd           n# 1 swxY w Y   t          j        |t           |          S )a  Load a collection of images from one or more FITS files

    Parameters
    ----------
    load_pattern : str or list
        List of extensions to load. Filename globbing is currently
        unsupported.
    conserve_memory : bool
        If True, never keep more than one in memory at a specific
        time. Otherwise, images will be cached once they are loaded.

    Returns
    -------
    ic : ImageCollection
        Collection of images.

    z-Input must be a filename or list of filenamesr   N)	load_funcconserve_memory)typeliststr	TypeErrorr   r   ziprangelenr   r	   r
   sizeappendioImageCollectionFITSFactory)	load_patternr   intypeext_listfilenamer   nr   	data_sizes	            r   r   r   6   s   & ,FTfC//GHHH T$~ H  7 7Yx   
	7GeCLL117;; 	7 	73c4=11 7ZT_5U5U 7/$'H		$ / / /$'HHJJ			/ 1}} 1666	7
	7 
	7 
	7 
	7 
	7 
	7 
	7 
	7 
	7 
	7 
	7 
	7 
	7 
	7 
	7 K   s7   A$D<CDC%	"D$C%	%!DD	D	c                    t          | t                    st          d          t          |           dk    rt	          d          | d         }| d         }t          |t
                    rt          |t                    st	          d          t          j        |          5 }||         j	        }ddd           n# 1 swxY w Y   |t          d| d	| d
          |S )a  Load an image extension from a FITS file and return a NumPy array

    Parameters
    ----------
    image_ext : tuple
        FITS extension to load, in the format ``(filename, ext_num)``.
        The FITS ``(extname, extver)`` format is unsupported, since this
        function is not called directly by the user and
        ``imread_collection()`` does the work of figuring out which
        extensions need loading.

    zExpected a tuple   zExpected a tuple of length 2r      z&Expected a (filename, extension) tupleNz
Extension z of z has no data)r   tupler   r   
ValueErrorr   intr   r   r   RuntimeError)	image_extr#   extnumr   r   s        r   r   r   f   s'    i'' ,*+++
9~~7888|Hq\Fx%% C*VS*A*A CABBB	8		 $v#$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ |JJJHJJJKKKKs   $B>>CC)T)	__all__
skimage.ior   
astropy.ior   ImportErrorr   r   r        r   <module>r5      s   (
)         
+	  $ $ $N- - - -`! ! ! ! !s    $