radio-astro-tools / spectral-cube

Library for reading and analyzing astrophysical spectral data cubes
http://spectral-cube.rtfd.org
BSD 3-Clause "New" or "Revised" License
95 stars 61 forks source link

Question about spectral smoothing #876

Closed Antares1234 closed 1 year ago

Antares1234 commented 1 year ago

There are some examples of spectral smoothing in the docs, and I am a little confused about the Gaussian kernels in these examples.

image

It seems that the FWHM of the Gaussian kernel is calculated in different ways in the two examples. The former is 2/0.5, while the latter is (0.25^2 - 0.1^2)^0.5/0.1. Why doesn't the latter use 0.25/0.1 as the FWHM?

keflavich commented 1 year ago

The Gaussian1DKernel object takes a value in units of pixels.

When you convolve two Gaussians, the result is a Gaussian with width: $$\sigma^2{final} = \sigma^2{1} + \sigma^2_{2}$$

The first above example is smoothing by 4 pixels FWHM, which smooths by 4 pixels. If the original data had resolution of 0.1 km/s, this would result in smoothing to (0.1^2 + (4/2.35 * 0.1)^2)^0.5 = 0.197 km/s. The second example smooths to a target resolution of 0.25 km/s.

Antares1234 commented 1 year ago

I see. Thanks for your explanation. And there is another question. I'm reading the cube projection tutorial: https://learn.astropy.org/tutorials/SpectralCubeReprojectExample.html.

image

Here the standard deviation of the kernel is 1.886/2.35. Why isn't it divided by the original pixel width (velocity_res_2)?

keflavich commented 1 year ago

Good catch, that looks like an error. It would be helpful to propose a suggested fix there!