AstroPy Integrations

yt enables a number of integrations with the AstroPy package. These are listed below, but more detailed descriptions are given at the given documentation links.

Round-Trip Unit Conversions Between yt and AstroPy

AstroPy has a symbolic units implementation similar to that in yt. For this reason, we have implemented “round-trip” conversions between YTArray objects and AstroPy’s Quantity objects. These are implemented in the from_astropy() and to_astropy() methods.

FITS Image File Reading and Writing

Reading and writing FITS files is supported in yt using AstroPy’s FITS file handling.

yt has basic support for reading two and three-dimensional image data from FITS files. Some limited ability to parse certain types of data (e.g., spectral cubes, images with sky coordinates, images written using the FITSImageData class described below) is possible. See FITS Data for more information.

Fixed-resolution two-dimensional images generated from datasets using yt (such as slices or projections) and fixed-resolution three-dimensional grids can be written to FITS files using yt’s FITSImageData class and its subclasses. Multiple images can be combined into a single file, operations can be performed on the images and their coordinates, etc. See Writing FITS Images for more information.

Converting Field Container and 1D Profile Data to AstroPy Tables

Data in field containers, such as spheres, rectangular regions, rays, cylinders, etc., are represented as 1D YTArrays. A set of these arrays can then be exported to an AstroPy Table object, specifically a QTable. QTable is unit-aware, and can be manipulated in a number of ways and written to disk in several formats, including ASCII text or FITS files.

Similarly, 1D profile objects can also be exported to AstroPy QTable, optionally writing all of the profile bins or only the ones which are used. For more details, see Exporting Profiles to QTable.