The SKIRT project
advanced radiative transfer for astrophysics
Functions
pts.simulation.fits Namespace Reference

Handling SKIRT FITS output files. More...

Functions

def _grid (npix, crpix, crval, cdelt, cunit)
 This helper function constructs a regular linear grid based on the information for an axis in the FITS header. More...
 
def getFitsAxes (path)
 This function retrieves the axis grid points from a FITS file produced by SKIRT, and returns the result as a tuple of astropy quantity arrays: (x, y) for data frames or (x, y, z) for data cubes. More...
 
def loadFits (path)
 This function loads the complete contents from a FITS file produced by SKIRT, and returns the resulting data frame or data cube as a two- or three-dimensional astropy quantity array. More...
 
def writeFits (outFilePath, data, xaxis=None, yaxis=None, zaxis=None)
 This function writes a frame or data cube to a FITS file that resembles a SKIRT output file. More...
 

Detailed Description

Handling SKIRT FITS output files.

This module offers functions for reading frames and data cubes from SKIRT FITS output files with support for units, and for writing frames and data cubes to FITS files with the same structure as SKIRT output files.

Function Documentation

◆ _grid()

def pts.simulation.fits._grid (   npix,
  crpix,
  crval,
  cdelt,
  cunit 
)
private

This helper function constructs a regular linear grid based on the information for an axis in the FITS header.

◆ getFitsAxes()

def pts.simulation.fits.getFitsAxes (   path)

This function retrieves the axis grid points from a FITS file produced by SKIRT, and returns the result as a tuple of astropy quantity arrays: (x, y) for data frames or (x, y, z) for data cubes.

The function assumes that x and y represent spatial axes with a regular, linear grid. For a data cube, the function expects the z-axis grid points (often wavelengths) to be listed in a binary table extension.

The file path is interpreted as described for the pts.utils.absPath() function.

◆ loadFits()

def pts.simulation.fits.loadFits (   path)

This function loads the complete contents from a FITS file produced by SKIRT, and returns the resulting data frame or data cube as a two- or three-dimensional astropy quantity array.

The indices of the array are in the order [x, y] for a data frame and [x, y, z] for a data cube, where x and y are usually spatial axes and z is often the wavelength axis. The appropriate units for the array values are obtained from the FITS file header written by SKIRT.

The file path is interpreted as described for the pts.utils.absPath() function.

◆ writeFits()

def pts.simulation.fits.writeFits (   outFilePath,
  data,
  xaxis = None,
  yaxis = None,
  zaxis = None 
)

This function writes a frame or data cube to a FITS file that resembles a SKIRT output file.

It expects the following arguments:

  • outFilePath: the output file's absolute or relative path, including filename and '.fits' extension, interpreted as described for the pts.utils.absPath() function.
  • data: a two- or three-dimensional astropy quantity array; the indices of the array are in the order [x, y] for a data frame and [x, y, z] for a data cube, where usually x and y are spatial axes and z the wavelength axis.
  • xaxis (optional): a 1D astropy quantity array listing the grid points for the x-axis.
  • yaxis (optional): a 1D astropy quantity array listing the grid points for the y-axis.
  • zaxis (optional; used only if data is 3D): a 1D astropy quantity array listing the grid points for the z-axis.

The grid points for the x- and y-axis are assumed to have a regular linear distribution. The grid points for the z-axis can have any distribution; all points are included in the FITS file as a table.

The function includes information in the FITS header fields about the data and axes in the same way as SKIRT does for its output files. If the information for a given axis is missing, the corresponding information is simply not written to the FITS file. The information for the z-axis is written only if the data array has three dimensions.

The current implementation does not include information on the line of sight and distance from the model.