SKIRT / SKIRT9

SKIRT version 9 -- advanced radiative transfer in dusty systems
http://www.skirt.ugent.be
GNU Affero General Public License v3.0
35 stars 30 forks source link

noise issues across different wavelength images #92

Closed dnelson86 closed 3 years ago

dnelson86 commented 3 years ago

Description

I have a SKIRT9 run on a TNG100-1 galaxy where everything seems reasonable. However, when I construct a RGB image from e.g. SDSS g,r,i bands I get the attached.

In the galaxy itself (~edge-on) seems ok, but in the outskirts there seems to be single noise pixels which are either red, green, or blue, e.g. there are 'noisy' pixels in the outskirts which are different per band, thus this rainbow noise in the composite.

Any ideas? I thought maybe smoothing lengths for stars? Or something about the random number generator / random photons are changing per band?

Ana suggested looking at the statistics outputs, and the relative error, also included here. With 1e7 packets and reducing to a very low number of photons I can get this to be reasonable (<0.2) only in the actual center of the galaxy. This seems to reply ridiculous, i.e. impossibly high, photon counts for the outskirts and/or more interesting pixel counts. I tried adjusting the biasing from Log to Lin and focusing it more on the wavelength range of interest, but there wasn’t any noticeable change.

Do you have any further suggestions other than increasing the packet number? It seems that even with 1e9 packets I wouldn’t resolve this issue?

Reproduce

Same setup and run as Issue #91 (increasing pixel number to e.g. 100x100 or 200x200 makes things increasingly obvious)

Output

image_TNG100-1_sh343503_total_edgeon_sdss_i.pdf image_TNG100-1_sh343503_total_edgeon_sdss_g.pdf image_TNG100-1_sh343503_total_edgeon_sdss_r.pdf

image_TNG100-1_sh343503_total_edgeon_rgb.pdf

image_sh343503_faceon_sdss_i_relerr.pdf image_sh343503_edgeon_sdss_i_relerr.pdf

dnelson86 commented 3 years ago

Thanks to @anatrcka for the following thoughts (for future reference):

This is not strange, it comes from the fact that SKIRT9 launches different number of photon packets for different bands. This is determined from a combination of the source luminosity and a wavelength bias distribution. This complexity has been introduced in SKIRT9 so that narrow spectral features would be properly sampled, and to allow supporting kinematics.

You can see some more info here:

In an instrument, the number of photon packets contributing to a given (logarithmic or broadband) wavelength bin will depend on the (effective) width of that bin (in addition to the “density” of emitted photon packets in that range, as mentioned previously).

Also, there is also a more physical reasoning, that comes from the wavelength dependence of the extinction cross section, where larger absorption cross sections cause the contribution of individual photon packets to be smaller, leading to worse statistics. Larger scattering cross sections may lead to the diversion of photon packets into to line of sight in regions away from the primary sources. However, in your case the numerical issue is dominant.

petercamps commented 3 years ago

Making RGB images from MCRT results is notoriously tricky. However, there are some things you can do to reduce the issues described here. I'll try and provide some ideas and hints early next week.

petercamps commented 3 years ago

When combining SKIRT output frames at different wavelengths into a single artificial-color RGB image, the Monte Carlo noise in low-intensity regions induces ugly color artifacts. In the most extreme case, a given pixel may have received just a single photon packet in the “red” frame and no packets at all in the other frames, while another pixel has received just a single photon packet in the “blue” frame and no packets in the other frames. As a result, the pixel colors will be very saturated rather than “averaged” to near-white, producing “color noise”. A similar effect can be observed in photographs taken with a digital camera in extreme low-light conditions.

Let us assume that the RGB images produced from SKIRT results are intended for illustrative purposes and not as a basis for actual science. In other words, we don’t expect the photometry to be preserved exactly. Reducing color-noise (and improving the quality of the image in general) requires attention in the following areas:

  1. Maximize the number of photon packets arriving in the frames
  2. Reduce blurring caused by wavelength-dependent physics
  3. Optimize the heuristic for creating a color-composite image

Optical only

We first assume that we are only interested in a wavelength range where dust emission is not relevant, so that we can run an extinction-only simulation in SKIRT. For goal (1), we should limit the wavelengths of the emitted photon packets to wavelengths that will actually end up in the frames that will be used for the color image. We could do this by widening the instrument wavelength bins, for example by using broadbands instead of logarithmic bins, but this goes against goal (2). Indeed, widening the receiving wavelength bins increases blurring caused by wavelength-dependent extinction and scattering. For the same reason, it is best no to enable any kinematics in the simulation (assuming, of course, that the kinematics don’t dominate the results to a point where they are no longer meaningful).

It turns out that SKIRT offers a perfect mechanism to achieve all of this: the oligochromatic simulation mode (selected very early on in the configuration process). In this mode, all photon packets are emitted at one or more discrete wavelengths configured by the user. The mode does not support kinematics nor dust emission, and it does not properly sample a very fine-grained source SED (because it is limited to discrete wavelengths), but it is perfect for making RGB images in conditions where these aspects are insignificant. We configure three wavelengths, one for each of the RGB channels, and ALL photon packets will be emitted and detected at exactly those wavelengths.

Note that the frames in the output data cube are always sorted by increasing wavelength, regardless of the order of the user-configured wavelengths. Also, in SKIRT 9, the configured number of photon packets always specifies the total number emitted for all wavelengths combined (this was different in earlier SKIRT versions).

Concerning item (3), several heuristics exist beyond simply assigning pixel values from the SKIRT output to the RGB channels. The first step is to consider the mapping for each color separately: functional form (linear, power-law, logarithmic, …), max limit (e.g. put the maximum at the 98 percentile of the pixel values), min limit (e.g. limit to a given nr of decades), gamma-curve (e.g. for additional contrast). The second step is combining the colors: relative weight for each channel (also depending on the surface brightness output flavor used in SKIRT), or heuristics to adjust the saturation of the color in a more complex manner based on the individual components. Finally, a nicer image may be obtained by including information from additional wavelengths, e.g. adding some blue for UV and some red for NIR. This comes at the expense of configuring 4 or 5 wavelengths in the simulation instead of 3, and increasing the nr of photon packets accordingly.

Including FIR

To make false-color images that include (or solely consist of) FIR wavelengths, we need to include dust emission in the SKIRT simulation. This rules out the use of the oligochromatic simulation mode. SKIRT needs sufficient wavelength coverage to estimate the radiation field and the resulting dust heating and emission. One option is to use a regular panchromatic simulation (with properly resolved radiation field and dust emission wavelength grids) and configure instruments with broadband wavelength grids, so that a fair number of photon packets are actually detected in the bands used for the color image. However, this will include some blurring because of wavelength-dependent physics.

To reduce the blurring, we could consider using the advanced technique of "discrete panchromatic simulation mode", described here, at the expense of requiring more photon packets and the risk of reduced accuracy of the physics if the number of discrete wavelengths is too small.