astrohack.utils.fits
Functions
|
Get which of the axis in the header is the stokes axis |
|
Tries to fetch a keyword from a FITS header / dictionary |
|
Brute force reading of a fits file, no checks are performed |
|
Reads a square FITS file and do sanity checks on its dimensionality |
|
Pull axis information from FITS file and store it in a numpy array, ignores rotation in axes. |
|
Write a dictionary and a dataset to a FITS file |
|
Adds resolution information to standard header keywords: BMAJ, BMIN and BPA |
|
Process an axis to create a FITS compatible linear axis description |
|
Inserts a dedicated stokes axis in the header at iaxis |
Module Contents
- get_stokes_axis_iaxis(header)[source]
Get which of the axis in the header is the stokes axis :param header: FITS header
- Returns:
None if no stokes axis is found, iaxis if stokes axis is found
- safe_keyword_fetch(header_dict, keyword)[source]
Tries to fetch a keyword from a FITS header / dictionary :param header_dict: FITS header / Dictionary :param keyword: The intended keyword to fetch
- Returns:
Keyword value if prensent, None if not present.
- read_fits_no_checks(filename)[source]
Brute force reading of a fits file, no checks are performed :param filename: Fits filename
- Returns:
FITS header as a dict and associated data
- read_fits(filename, header_as_dict=True)[source]
Reads a square FITS file and do sanity checks on its dimensionality :param filename: a string containing the FITS file name/path :param header_as_dict: return header as dictionary
Returns: The FITS header and the associated data array
- get_axis_from_fits_header(header, iaxis, pixel_offset=True)[source]
Pull axis information from FITS file and store it in a numpy array, ignores rotation in axes. :param header: FITS header :param iaxis: Which axis is to be fetched from the header. :param pixel_offset: apply one pixel offset
- Returns:
numpy array representation of axis, axis type and axis unit
- write_fits(header, imagetype, data, filename, unit, origin=None, reorder_axis=True)[source]
Write a dictionary and a dataset to a FITS file :param header: The dictionary containing the header :param imagetype: Type to be added to FITS header :param data: The dataset :param filename: The name of the output file :param unit: to be set to bunit :param origin: Which astrohack mds has created the FITS being written :param reorder_axis: Reorder data axes so that they are compatible with regular FITS ordering
- put_resolution_in_fits_header(header, resolution)[source]
Adds resolution information to standard header keywords: BMAJ, BMIN and BPA :param header: The dictionary header to be augmented :param resolution: The lenght=2 array with the resolution elements
Returns: The augmented header dictionary
- put_axis_in_fits_header(header: dict, axis, iaxis, axistype, unit, iswcs=True)[source]
Process an axis to create a FITS compatible linear axis description :param header: The header to add the axis description to :param axis: The axis to be described in the header :param iaxis: The position of the axis in the data :param axistype: Axis type to be displayed in the fits header :param unit: Axis unit :param iswcs: Is the axis a part of World Coordinate System for the image?
Returns: The augmented header