
    k h7                     \    d dgZ ddlmZ 	 ddlmZ d Zd	dZd Zy# e$ r	  ed      w xY w)
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 ]Q  }t        |t         j                        st        |t         j                        s8|j
                  E|j
                  } n ddd       |S # 1 sw Y   S xY w)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       {/home/developers/rajanand/mypropertyqr-fmb-refixing-v2/venv/lib/python3.12/site-packages/skimage/io/_plugins/fits_plugin.pyr   r      sy    4 
5	 W 	 	C#t}}-C1Q88' #I			  s   <A9A9 A99Bc           	      D   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                        s;	 |j                  }|dkD  sN|j                  ||f       b 	 ddd        t        j                  |t         |      S # t        $ r |j                         }Y ]w xY w# 1 sw Y   xY w)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 T$~ H  7YYx  
	7GeCL17; 	73c4==1ZT__5U/$'HH	 !1} 16	7
	7 
	77 K  % /$'HHJ	/
	7 
	7s7   AD)C75D;D7D	DD	DD	c                 r   t        | t              st        d      t        |       dk7  rt	        d      | d   }| d   }t        |t
              rt        |t              st	        d      t        j                  |      5 }||   j                  }ddd       t        d| d	| d
      |S # 1 sw Y   xY w)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|Hq\Fx%*VS*AABB	8	 $v##$ |ZxtH:\JKKK$ $s   ?B--B6)T)	__all__
skimage.ior   
astropy.ior   ImportErrorr   r   r        r   <module>r5      sP   (
) $N-`!  
	 s    +