I will demonstrate the use of cross-correlation to measure redshift using a Sloan template.
# get the data
import urllib
import astropy.io.fits as pyfits
lrgurl = 'http://www.sdss.org/dr5/algorithms/spectemplates/spDR2-028.fit'
urllib.urlretrieve(lrgurl,'spDR2-028.fit')
lrgobj = ('spDR2-028.fit')
lrgdata = pyfits.getdata(lrgobj)
spectrum = lrgdata[1,:] # 1 is "continuum-subtracted"
plot(spectrum)
[<matplotlib.lines.Line2D at 0x108b90710>]
# sigh... can't really go on unless I have wavelength axis
import image_registration.iterative_zoom as iz
import scipy.signal
xc = scipy.signal.correlate(spectrum,spectrum,'full')
plot(xc)
[<matplotlib.lines.Line2D at 0x108c2f0d0>]
reload(iz)
zoomed, zf, center = iz.iterative_zoom_1d(xc,minmax=np.max,mindiff=1e-10,verbose=True,return_zoomed=True,zoomshape=[50,],zoomstep=5)
Zoom factor 5, center = 3554, offset= 0, minpos= 3554, mindiff= 3.55271e-14
plot(zoomed)
[<matplotlib.lines.Line2D at 0x10d189350>]
-41.440239