I want to write a function that cross correlates a spectrum with a quasar template

I’d like to ask you how can I convert my flux density vs wavelength spectrum to log-wavelength. It’s not clear to me if I should just take wavelength axis -> log-wavelength axis. Or should I do something else?

From what I understand from reading here other people's questions, I need the spectra to be binned linearly in log-wavelength.

Sorry for my ignorance, but what does it mean? I understand how it helps but not the action itself. And how do I do that (let's say on Matlab or Python)? I know it's related to interpolation but I do not understand how to do it and why.


1 Answer 1


If your limits in wavelength are $\lambda_1$ and $\lambda_2$, then take the log of these and then divide your x-axis into $n$ bins with equal steps in log wavelength.

If you already have your spectra binned in linear wavelength then you have to decide how much of each pixel to allocate to the newly created log wavelength pixel array.

There are a number of ways to do this. The simplest is to allocate a fraction of the flux equal to the fraction of the pixel that lies within the log wavelength pixel. This correctly conserves flux.

A more complicated scheme would fit a line, or some other function, to the pixels spanning each log wavelength pixel and then integrate that function between the boundaries of the log wavelength pixels.

There are some examples of python code here.

Even better, there is a python spectrum analysis package called specutils and it has "resampling" functions ready to go. https://specutils.readthedocs.io/en/stable/manipulation.html#resampling


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .