FitsFileContextManager¶
- class gdt.core.file.FitsFileContextManager[source]¶
Bases:
AbstractContextManagerA context manager for FITS files. Includes some convenience functions.
Attributes Summary
The filename
The list of Header Data Units
The headers
The number of HDUs
Methods Summary
close()Close the file
column(hdu_num, col_name)Return a column from an HDU as an array.
columns_as_array(hdu_num, col_names[, dtype])Return a list of columns from an HDU as an array.
get_column_names(hdu_num)Get the column names in a HDU.
hdu_index_from_name(ext_name)Returns the index into the HDU list based on the extension name.
open(file_path[, mode, memmap])Open a FITS file.
write(directory[, filename])Write the file to disk.
Attributes Documentation
- filename¶
The filename
- Type:
(str)
- hdulist¶
The list of Header Data Units
- Type:
(astropy.io.fits.hdu.HDUList)
- headers¶
The headers
- Type:
- num_hdus¶
The number of HDUs
- Type:
(int)
Methods Documentation
- column(hdu_num: int, col_name: str) array[source]¶
Return a column from an HDU as an array.
- Parameters:
hdu_num (int) – The HDU number
col_name (str) – The name of the column
- Returns:
(np.array)
- columns_as_array(hdu_num: int, col_names: List[str], dtype: dtype = None) array[source]¶
Return a list of columns from an HDU as an array.
- Parameters:
hdu_num (int) – The HDU number
col_names (list of str) – The names of the columns
dtype (np.dtype, optional) – The custom dtype of the output array
- Returns:
(np.array)
- get_column_names(hdu_num: int)[source]¶
Get the column names in a HDU. Returns empty if there is no data extension in the HDU.
- Parameters:
hdu_num (int) – The HDU number
- Returns:
(tuple)
- hdu_index_from_name(ext_name)[source]¶
Returns the index into the HDU list based on the extension name. If there is no match, returns None.
- Parameters:
ext_name (str) – The extension name
- Returns:
(int)