sourcefinder.accessors.fitsimage#
Attributes#
Classes#
Use PyFITS to pull image data out of a FITS file. |
Module Contents#
- class sourcefinder.accessors.fitsimage.FitsImage(url, plane=None, beam=None, hdu_index=0)[source]#
Bases:
sourcefinder.accessors.dataaccessor.DataAccessorUse PyFITS to pull image data out of a FITS file.
Provide standard attributes, as per
DataAccessor. In addition, we provide atelescopeattribute if the FITS file has aTELESCOPheader.- Parameters:
- urlPath or str
The path or URL to the FITS file.
- planeint, default: None
If the data is a datacube, specifies which plane to use.
- beamtuple, default: None
Beam parameters in degrees, in the form (bmaj, bmin, bpa). If not supplied, the method will attempt to read these from the header.
- hdu_indexint, default: 0
The index of the HDU to use from the HDU list.
- _get_header(hdu_index)[source]#
Retrieve the header from the specified HDU in the FITS file.
- Parameters:
- hdu_indexint
The index of the Header Data Unit (HDU) to extract the header from.
- Returns:
- astropy.io.fits.Header
A copy of the header from the specified HDU.
- calculate_phase_centre()[source]#
Calculate the phase center of the FITS image.
The phase center is determined by finding the central pixel and converting that position to celestial coordinates.
- Returns:
- tuple[float]
A tuple containing the right ascension and declination of the phase center in degrees.
- parse_beam()[source]#
Read and return the beam properties bmaj, bmin and bpa values from the FITS header.
- Returns:
- bmajfloat
the major axis of the beam in degrees.
- bminfloat
the minor axis of the beam in degrees.
- bpafloat
the position angle of the beam in degrees.
Notes
AIPS FITS file: stored in the history section
- parse_coordinates()[source]#
Parse header to return a WCS (World Coordinate System) object.
- Returns:
- WCS
A WCS object containing the coordinate system information extracted from the FITS file header.
- Raises:
- TypeError
If the coordinate system is not specified in the FITS header.
Notes
If units are not specified in the header, degrees are assumed by default.
- parse_frequency()[source]#
Set some ‘shortcut’ variables for access to the frequency parameters in the FITS file header.
- Returns:
- freq_efffloat
The effective frequency extracted from the FITS header.
- freq_bwfloat
The bandwidth extracted from the FITS header.
- parse_start_time()[source]#
Parse and return the start time of the observation, that yielded this FITS image, from its header.
- Returns:
- datetime.datetime
The start time of the observation as an instance of datetime.datetime.
- Raises:
- KeyError
If the timestamp in the FITS file is unreadable.
- Warning
Logged if a non-standard date format is encountered in the FITS file.
- parse_times()[source]#
Attempt to do something sane with timestamps.
- Returns:
- taustart_tsdatetime.datetime
Timezone-naive (implicit UTC) datetime representing the start of the observation.
- tau_timefloat
Integration time in seconds.
- read_data(hdu_index, plane)[source]#
Read data from our FITS file.
- Parameters:
- hdu_indexint
The index of the Header Data Unit (HDU) to extract the data from.
- planeint, default: None
If the data is a datacube, specifies which plane to use.
- Returns:
- numpy.ndarray
The processed 2D data array, transposed for intuitive display.
Notes
PyFITS reads the data into an array indexed as [y][x]. We take the transpose to make this more intuitively reasonable and consistent with (eg) ds9 display of the FitsFile. Transpose back before viewing the array with RO.DS9, saving to a FITS file, etc.