The SKIRT project
advanced radiative transfer for astrophysics
Functions
pts.visual.makergbimages Namespace Reference

Creating RGB images for SKIRT simulation surface brightness output. More...

Functions

def makeConvolvedRGBImages (simulation, contributions, name="", *fileType="total", decades=3, fmax=None, fmin=None, outDirPath=None)
 This function creates broadband-convolved RGB images for surface brightness data cubes produced by the instruments of a SKIRT simulation. More...
 
def makeRGBImages (simulation, wavelengthTuples=None, *fileType="total", fromPercentile=30, toPercentile=100, outDirPath=None)
 This function creates RGB images for surface brightness maps produced by the instruments of a SKIRT simulation. More...
 

Detailed Description

Creating RGB images for SKIRT simulation surface brightness output.

The function in this module creates RGB images for surface brightness maps produced by the instruments of a SKIRT simulation. The caller can specify the wavelengths corresponding to the R,G,B frames in the image.

Function Documentation

◆ makeConvolvedRGBImages()

def pts.visual.makergbimages.makeConvolvedRGBImages (   simulation,
  contributions,
  name = "",
fileType = "total",
  decades = 3,
  fmax = None,
  fmin = None,
  outDirPath = None 
)

This function creates broadband-convolved RGB images for surface brightness data cubes produced by the instruments of a SKIRT simulation.

The color makeup of the image is defined by a list of broadbands, where each band can contribute with some given weight to each of the R,G,B channels. This allows arbitrary mapping of wavelength ranges to RGB color.

After convolving the SKIRT output data cubes with each of the specified broadbands, the function converts the surface brightness values for each band to per-frequency flavor (MJy/sr) before performing the RGB color mixing.

The final images are saved in PNG format and have the same name as the corresponding ".fits" file, possibly extended with a custom name segment. By default the images are placed next to the corresponding ".fits" files in the same directory, but another output directory can be specified if needed.

The function takes the following arguments:

  • simulation: a single Simulation or Instrument instance for which to create RGB images. When given a simulation, the function uses the same pixel range scaling for the RGB images across all instruments.
  • contributions: a sequence of 4-tuples (band, r, g, b), each containing a BroadBand instance and three weights that specify the contribution of the surface brightness in this band to each RGB channel.
  • name: a string that will be added to the image file name; defaults to the empty string.
  • fileType: a string indicating the final segment of the name of the instrument output files to be handled, excluding the ".fits" suffix (for example: "primaryscattered"); if this argument is missing, the function by default handles the "*_total.fits" output files.
  • decades: the dynamic range for the surface brightness values in the images, expressed in order of magnitudes (decades); the default value is 3. Pixels with a value less than decades order of magnitudes below the maximum value (in any of the channels/images) are clipped to zero.
  • fmax: the largest surface brightness value that will be shown in the images without clipping; this must be an astropy quantity with per-frequency surface brightness units (e.g. MJy/sr). If this argument is None or missing, the function uses the largest value found in any of the channels/images.
  • fmin: the smallest surface brightness value that will be shown in the image without clipping; this must be an astropy quantity with per-frequency surface brightness units (e.g. MJy/sr). If this argument is None or missing, the function determines this value from fmax and decades. using the formula \(f_\mathrm{range}=\log_{10}(f_\mathrm{max}/f_\mathrm{min})\). If fmin is specified, the value of decades is ignored.
  • imageDirPath: path to the PNG output directory; default is next to the fits files.

The function returns a tuple (fmin, fmax) specifying the surface brightness range actually used in the images, as an astropy quantity with per-frequency surface brightness units (MJy/sr).

◆ makeRGBImages()

def pts.visual.makergbimages.makeRGBImages (   simulation,
  wavelengthTuples = None,
fileType = "total",
  fromPercentile = 30,
  toPercentile = 100,
  outDirPath = None 
)

This function creates RGB images for surface brightness maps produced by the instruments of a SKIRT simulation.

Specifically, the function accepts a single Simulation or Instrument instance, and creates one or more RGB images for each ".fits" file actually produced by the instruments of the specified simulation or the specified instrument.

If the fileType argument is missing, the function by default handles the "*_total.fits" output files. Otherwise, the fileType argument must be a string indicating the final segment of the name of the instrument output files to be handled, excluding the ".fits" suffix. For example, "primaryscattered".

If the wavelengthTuples argument is missing, a single image is created for each ".fits" file using the frames loaded by default by the RGBImage constructor. Otherwise, the wavelengthTuples argument must contain a sequence or a dictionary of 3-tuples with (R,G,B) wavelengths. Each of these tuples causes an image to be created, loading the frames most closely corresponding to the specified wavelengths.

The fromPercentile and toPercentile arguments take the percentile values, in range [0,100], used to clip the luminosity values loaded from the fits file.

The images are saved in PNG format and have the same name as the corresponding ".fits" file but with a ".pdf" filename extension. If there are multiple images per ".fits" file, a serial number (for a sequence of wavelength tuples) or the tuple name (for a dictionary of wavelength tuples) is added. By default the images are placed next to the corresponding ".fits" files in the same directory, but another output directory can be specified if needed.

Note
The function uses the same pixel range scaling for all RGB images created for a particular wavelength tuple, across multiple instruments. To achieve this, the function makes a separate preprocessing pass over all files.