astropy: Problems with redshifted Gaussian example in compound model docs

One of the model composition examples (see https://astropy.readthedocs.org/en/latest/modeling/compound-models.html#model-composition) implements a RedshiftedGaussian model. However, there are two issues. First, the Gaussian appears to be blueshifted instead of redshifted, assuming the currently unlabeled (it should be labeled) x-axis is wavelength (see https://astropy.readthedocs.org/en/latest/modeling/compound-models-1.png). The green z=0 Gaussian appears to be at the largest wavelength (and the line is broadest).

The second issue is more subtle, but important. Redshifting a spectrum/emission line, etc. involves more than just transforming the wavelengths. There needs to be a corresponding transformation to conserve flux, e.g. wave’ = wave * (1 + z) and flux’ = flux / (1 + z). Again looking at the “redshifted” Gaussian figure, notice that the integrated line flux is changing with redshift because the line width is changing. There needs to be a corresponding amplitude change to conserve integrated flux.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 28 (28 by maintainers)

Most upvoted comments

It was never meant to be a “physical” example–just a demonstration of composing models. But if this makes it more palatable I’m all for it 😃

Okay, how about this?

import numpy as np
from astropy.modeling.models import Redshift, Gaussian1D

x = np.linspace(1000, 5000, 1000)
g0 = Gaussian1D(1, 2000, 200)  # No redshift is same as redshift with z=0

plt.figure(figsize=(8, 5))  # NOTE TO DEV: Changing the dimension from 3 to 5 should show the X label
plt.plot(x, g0(x), 'g--', label='$z=0$')

for z in (0.2, 0.4, 0.6):
    rs = Redshift(z).inverse
    g0.amplitude /= (1 + z)  # Rescale the flux to conserve energy
    g = rs | g0
    plt.plot(x, g(x), color=plt.cm.OrRd(z),
             label='$z={0}$'.format(z))

plt.xlabel('Wavelength')
plt.ylabel('Flux')
plt.legend()

figure_1