yt.frontends.fits.misc module

Miscellaneous FITS routines

class yt.frontends.fits.misc.PlotWindowWCS(pw)[source]

Bases: object

Use the wcsaxes library to plot celestial coordinates on the axes of a on-axis PlotWindow plot. See for details.

Parameters:pw (on-axis PlotWindow instance) – The PlotWindow instance to add celestial axes to.
save(name=None, mpl_kwargs=None)[source]
yt.frontends.fits.misc.create_spectral_slabs(filename, slab_centers, slab_width, **kwargs)[source]

Given a dictionary of spectral slab centers and a width in spectral units, extract data from a spectral cube at these slab centers and return a FITSDataset instance containing the different slabs as separate yt fields. Useful for extracting individual lines from a spectral cube and separating them out as different fields.

Requires the SpectralCube ( library.

All keyword arguments will be passed on to the FITSDataset constructor.

  • filename (string) – The spectral cube FITS file to extract the data from.
  • slab_centers (dict of (float, string) tuples or YTQuantities) – The centers of the slabs, where the keys are the names of the new fields and the values are (float, string) tuples or YTQuantities, specifying a value for each center and its unit.
  • slab_width (YTQuantity or (float, string) tuple) – The width of the slab along the spectral axis.


>>> slab_centers = {'13CN': (218.03117, 'GHz'),
...                 'CH3CH2CHO': (218.284256, 'GHz'),
...                 'CH3NH2': (218.40956, 'GHz')}
>>> slab_width = (0.05, "GHz")
>>> ds = create_spectral_slabs("intensity_cube.fits",
...                            slab_centers, slab_width,
...                            nan_mask=0.0)
yt.frontends.fits.misc.ds9_region(ds, reg, obj=None, field_parameters=None)[source]

Create a data container from a ds9 region file. Requires the pyregion package ( to be installed.

  • ds (FITSDataset) – The Dataset to create the region from.
  • reg (string) – The filename of the ds9 region, or a region string to be parsed.
  • obj (data container, optional) – The data container that will be used to create the new region. Defaults to ds.all_data.
  • field_parameters (dictionary, optional) – A set of field parameters to apply to the region.


>>> ds = yt.load("m33_hi.fits")
>>> circle_region = ds9_region(ds, "circle.reg")
>>> print circle_region.quantities.extrema("flux")
yt.frontends.fits.misc.setup_counts_fields(ds, ebounds, ftype='gas')[source]

Create deposited image fields from X-ray count data in energy bands.

  • ds (Dataset) – The FITS events file dataset to add the counts fields to.
  • ebounds (list of tuples) – A list of tuples, one for each field, with (emin, emax) as the energy bounds for the image.
  • ftype (string, optional) – The field type of the resulting field. Defaults to “gas”.


>>> ds = yt.load("evt.fits")
>>> ebounds = [(0.1,2.0),(2.0,3.0)]
>>> setup_counts_fields(ds, ebounds)