{ } Raw JSON

bundles / astropy latest / astropy / io / fits / hdu / hdulist / HDUList / index_of

function

astropy.io.fits.hdu.hdulist:HDUList.index_of

source: /astropy/io/fits/hdu/hdulist.py :772

Signature

def   index_of ( self key )

Summary

Get the index of an HDU from the HDUList.

Parameters

key : int, str, tuple of (string, int) or BaseHDU

The key identifying the HDU. If key is a tuple, it is of the form (name, ver) where ver is an EXTVER value that must match the HDU being searched for.

If the key is ambiguous (e.g. there are multiple 'SCI' extensions) the first match is returned. For a more precise match use the (name, ver) pair.

If even the (name, ver) pair is ambiguous (it shouldn't be but it's not impossible) the numeric index must be used to index the duplicate HDU.

When key is an HDU object, this function returns the index of that HDU object in the HDUList.

Returns

index : int

The index of the HDU in the HDUList.

Raises

: ValueError

If key is an HDU object and it is not found in the HDUList.

: KeyError

If an HDU specified by the key that is an extension number, extension name, or a tuple of extension name and version is not found in the HDUList.

Aliases

  • astropy.io.fits.HDUList.index_of