§
    IR-e¥  ã                   óZ   — d dl mZ d dlmZ d dlmZ d dlmZmZ dgZ G d„ d¦  «        ZdS )é    )Úlog)ÚBaseHighLevelWCS)ÚBaseLowLevelWCS)ÚHighLevelWCSWrapperÚSlicedLowLevelWCSÚNDSlicingMixinc                   ó6   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	dS )	r   aÒ  Mixin to provide slicing on objects using the `NDData`
    interface.

    The ``data``, ``mask``, ``uncertainty`` and ``wcs`` will be sliced, if
    set and sliceable. The ``unit`` and ``meta`` will be untouched. The return
    will be a reference and not a copy, if possible.

    Examples
    --------
    Using this Mixin with `~astropy.nddata.NDData`:

        >>> from astropy.nddata import NDData, NDSlicingMixin
        >>> class NDDataSliceable(NDSlicingMixin, NDData):
        ...     pass

    Slicing an instance containing data::

        >>> nd = NDDataSliceable([1,2,3,4,5])
        >>> nd[1:3]
        NDDataSliceable([2, 3])

    Also the other attributes are sliced for example the ``mask``::

        >>> import numpy as np
        >>> mask = np.array([True, False, True, True, False])
        >>> nd2 = NDDataSliceable(nd, mask=mask)
        >>> nd2slc = nd2[1:3]
        >>> nd2slc[nd2slc.mask]
        NDDataSliceable([3])

    Be aware that changing values of the sliced instance will change the values
    of the original::

        >>> nd3 = nd2[1:3]
        >>> nd3.data[0] = 100
        >>> nd2
        NDDataSliceable([  1, 100,   3,   4,   5])

    See Also
    --------
    NDDataRef
    NDDataArray
    c                 ó„   — | j         j        dk    rt          d¦  «        ‚|                      |¦  «        } | j        di |¤ŽS )N© zscalars cannot be sliced.)ÚdataÚshapeÚ	TypeErrorÚ_sliceÚ	__class__©ÚselfÚitemÚkwargss      ú?lib/python3.11/site-packages/astropy/nddata/mixins/ndslicing.pyÚ__getitem__zNDSlicingMixin.__getitem__:   sK   € àŒ9Œ?˜bÒ Ð ÝÐ7Ñ8Ô8Ð8ð —’˜TÑ"Ô"ˆØˆtŒ~Ð'Ð' Ð'Ð'Ð'ó    c                 óâ   — i }| j         |         |d<   |                      |¦  «        |d<   |                      |¦  «        |d<   |                      |¦  «        |d<   | j        |d<   | j        |d<   |S )aÍ  Collects the sliced attributes and passes them back as `dict`.

        It passes uncertainty, mask and wcs to their appropriate ``_slice_*``
        method, while ``meta`` and ``unit`` are simply taken from the original.
        The data is assumed to be sliceable and is sliced directly.

        When possible the return should *not* be a copy of the data but a
        reference.

        Parameters
        ----------
        item : slice
            The slice passed to ``__getitem__``.

        Returns
        -------
        dict :
            Containing all the attributes after slicing - ready to
            use them to create ``self.__class__.__init__(**kwargs)`` in
            ``__getitem__``.
        r   ÚuncertaintyÚmaskÚwcsÚunitÚmeta)r   Ú_slice_uncertaintyÚ_slice_maskÚ
_slice_wcsr   r   r   s      r   r   zNDSlicingMixin._sliceC   sw   € ð, ˆØœ 4œˆˆv‰à $× 7Ò 7¸Ñ =Ô =ˆˆ}ÑØ×)Ò)¨$Ñ/Ô/ˆˆv‰ØŸš¨Ñ-Ô-ˆˆu‰àœˆˆv‰Øœˆˆv‰Øˆr   c                 ó”   — | j         €d S 	 | j         |         S # t          t          f$ r t          j        d¦  «         Y nw xY w| j         S )Nzuncertainty cannot be sliced.)r   r   ÚKeyErrorr   Úinfo©r   r   s     r   r   z!NDSlicingMixin._slice_uncertaintyd   sg   € ØÔÐ#Ø4ð	6ØÔ# DÔ)Ð)øÝ8Ð$ð 	6ð 	6ð 	6õ ŒHÐ4Ñ5Ô5Ð5Ð5Ð5ð		6øøøð
 ÔÐó   ‹ ˜%A ¿A c                 ó”   — | j         €d S 	 | j         |         S # t          t          f$ r t          j        d¦  «         Y nw xY w| j         S )Nzmask cannot be sliced.)r   r   r"   r   r#   r$   s     r   r   zNDSlicingMixin._slice_maskp   s_   € ØŒ9ÐØ4ð	/Ø”9˜T”?Ð"øÝ8Ð$ð 	/ð 	/ð 	/ÝŒHÐ-Ñ.Ô.Ð.Ð.Ð.ð	/øøøàŒyÐr%   c                 óÄ   — | j         €d S 	 t          | j         j        |¦  «        }t          |¦  «        S # t          $ r!}|                      ||¦  «         Y d }~d S d }~ww xY w)N)r   r   Úlow_level_wcsr   Ú	ExceptionÚ_handle_wcs_slicing_error)r   r   ÚllwcsÚerrs       r   r    zNDSlicingMixin._slice_wcsy   s}   € ØŒ8ÐØ4ð	6Ý% d¤hÔ&<¸dÑCÔCˆEÝ& uÑ-Ô-Ð-øÝð 	6ð 	6ð 	6Ø×*Ò*¨3°Ñ5Ô5Ð5Ð5Ð5Ð5Ð5Ð5Ð5øøøøð	6øøøs   ‹(4 ´
A¾AÁAc                 ó*   — t          d|› d¦  «        |‚)Nz'Slicing the WCS object with the slice 'z' failed, if you want to slice the NDData object without the WCS, you can remove by setting `NDData.wcs = None` and then retry.)Ú
ValueError)r   r,   r   s      r   r*   z(NDSlicingMixin._handle_wcs_slicing_error„   s3   € ÝðH°dð Hð Hð Hñ
ô 
ð ð		r   N)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r    r*   r   r   r   r   r      sz   € € € € € ð*ð *ðX(ð (ð (ðð ð ðB
 ð 
 ð 
 ðð ð ð6ð 6ð 6ðð ð ð ð r   N)	Úastropyr   Úastropy.wcs.wcsapir   r   r   r   Ú__all__r   r   r   r   ú<module>r6      s™   ðð
 Ð Ð Ð Ð Ð Ø /Ð /Ð /Ð /Ð /Ð /Ø .Ð .Ð .Ð .Ð .Ð .Ø EÐ EÐ EÐ EÐ EÐ EÐ EÐ EàÐ
€ð|ð |ð |ð |ð |ñ |ô |ð |ð |ð |r   