In Tonry and Davis (1979), p.1513, they formulated a cross-correlation method for extracting velocity redshifts:

Theory of Correlation Analysis

a) Introduction

Let $g(n)$ be the spectrum of a galaxy whose redshift and velocity dispersion are to be found and let $t(n)$ be a template spectrum of zero redshift and instrumentally broadened stellar-line profiles. These spectra are discretely sampled into $N$ bins, labeeled by bin number $n$; the relationship between wavelength and bin number is

$$n = A \ln \lambda + B$$ Because the spectra are binned linearly with $\ln \lambda$ a velocity redshift is a uniform linear shift. The spectra are assumed periodic with period $N$ [...]

They bin the linear spectra into logarithmic wavelength scale. Similar work was done by Baldry et. al (2014) and I have inserted relevant excerpt from TD79. I understand that log wavelength binning is a pre-requisite of cross-correlation procedure.

I have been trying to follow this approach and trying to rebin the linear spectra (3000 to 9000 Angstroms) in equal intervals of log wavelength. Could someone please give me a guidance about how to do this logarithmic re-binning in Python?

Here the text as picture: Tonry and Davis 1979

  • 1
    $\begingroup$ I got as far as $$\frac{dS}{d\log(\lambda)} = \frac{dS}{\frac{1}{\lambda}d\lambda} = \lambda \frac{dS}{d\lambda}$$ but it's 1 AM, that may be the wrong way to go, and I've got to "close up shop" for the night. These days we may not need to re-bin the spectrum so much as we just need to adjust what's plotted. I'll look at this again tomorrow, but I have a hunch someone will be able to write an authoritative answer a lot faster than I, that is unless it gets closed and everyone has to wait for it to be reopened again. $\endgroup$ – uhoh Jul 31 '19 at 17:11
  • 2
    $\begingroup$ @CarlWitthoft there are 228 posts that mention python here and 46 questions using the python tag, 16 tagged Astropy and 26 mention Skyfield and 34 mention PyEphem . The mentioning of python does not make a question off-topic. Let's leave it open and get this astronomy question answered! $\endgroup$ – uhoh Jul 31 '19 at 22:26
  • $\begingroup$ While I normally agree with uhoh on most borderline close issues, I disagree here. Astronomical knowledge is irrelevant to answering the question. Python (and general stats) knowledge is relevant. If you exchange the topic for something else (logarithmic binning for income distribution,say), the fundamental question remains the same and it can be answered the same. If you replace the logarithmic binning with a different technique, the question becomes different and the answer different. $\endgroup$ – Ingolifs Aug 1 '19 at 2:52
  • 1
    $\begingroup$ This (unanswered) meta question might be an appropriate place to discuss the relevance of this question. astronomy.meta.stackexchange.com/questions/513/… $\endgroup$ – Ingolifs Aug 1 '19 at 2:58
  • $\begingroup$ @Ingolifs while the absolute minimal answer imaginable might possibly squeeze by without touching on Astronomy, a good quality answer (remember those?) to the question will address the astronomical aspects of it head-on and add value to the site for future readers. (just for example padding after binning for the Fourier transform that comes next) I don't think "I could answer this while staying off-topic, so nobody could possibly write an on-topic answer (sic)" is the right way to think here. $\endgroup$ – uhoh Aug 1 '19 at 7:20

I think you could just take the natural log of your wavelength scale, then re-bin this onto a new log of wavelength scale generate using np.linspace(). Your new scale would be generated using the maximum and minimum values of your raw log of wavelength scale then it is up to you to define the amount of bin in the new homogenous log scale.

To re-bin the raw log of wavelength scale onto the homogenous log of wavelength scale you would assign fractions of the old flux values into the new bins where the fractions are determined by the fraction of the old bin (that the flux value was in) that overlaps the new bin.

In the end you will need this to be on kilometres per second or a unit of velocity. I expect you would simply multiply the scale by the speed of light although I have experienced slight loss of precision when I do this.

  • $\begingroup$ Welcome to astronomy SE! I slightly edited your answer, hope you are ok with the changes. $\endgroup$ – B--rian Feb 25 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.