(input_data, hdu=None, memmap=None)
return fits_hdu
Return an HDU from a FITS file

    Parameters
    ----------
    input_data : str or HDUList or HDU instance
        The input FITS file, either as a filename, HDU list, or HDU instance.

    Returns
    -------
    fits_hdu : HDU
        The extracted HDU
Return an HDU from a FITS file
Return an HDU from a FITS file
def _get_hdu(input_data, hdu=None, memmap=None):
    """
    Return an HDU from a FITS file

    Parameters
    ----------
    input_data : str or HDUList or HDU instance
        The input FITS file, either as a filename, HDU list, or HDU instance.

    Returns
    -------
    fits_hdu : HDU
        The extracted HDU
    """
    if isinstance(input_data, allowed_paths):
        hdulist = pf.open(input_data, memmap=memmap)
        return _get_hdu(hdulist, hdu=hdu)

    if isinstance(input_data, pf.HDUList):
        if isinstance(hdu, int) and hdu >= len(input_data):
            raise ValueError("Available hdu in [0-%d]" % len(input_data))
        else:
            fits_hdu = input_data[hdu]
    elif isinstance(
        input_data,
        (pf.PrimaryHDU, pf.ImageHDU, pf.BinTableHDU, pf.TableHDU, pf.GroupsHDU),
    ):
        fits_hdu = input_data
    else:
        raise TypeError(
            "First argument should be a input_data (str or pathlib.Path), HDUList instance, or HDU instance"
        )

    return fits_hdu
def _get_hdu ( input_data , hdu = None , memmap = None ) : if isinstance ( input_data , allowed_paths ) : hdulist = pf . open ( input_data , memmap = memmap ) return _get_hdu ( hdulist , hdu = hdu ) if isinstance ( input_data , pf . HDUList ) : if isinstance ( hdu , int ) and hdu >= len ( input_data ) : raise ValueError ( "Available hdu in [0-%d]" % len ( input_data ) ) else : fits_hdu = input_data [ hdu ] elif isinstance ( input_data , ( pf . PrimaryHDU , pf . ImageHDU , pf . BinTableHDU , pf . TableHDU , pf . GroupsHDU ) , ) : fits_hdu = input_data else : raise TypeError ( "First argument should be a input_data (str or pathlib.Path), HDUList instance, or HDU instance" ) return fits_hdu