I will demonstrate the use of cross-correlation to measure redshift using a Sloan template.
In [19]:
# 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)
In [32]:
spectrum = lrgdata[1,:] # 1 is "continuum-subtracted"
In [33]:
plot(spectrum)
Out[33]:
In [34]:
# sigh... can't really go on unless I have wavelength axis
In [35]:
import image_registration.iterative_zoom as iz
In [36]:
import scipy.signal
In [37]:
xc = scipy.signal.correlate(spectrum,spectrum,'full')
In [38]:
plot(xc)
Out[38]:
In [78]:
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)
In [79]:
plot(zoomed)
Out[79]:
In [50]:
Out[50]:
In [ ]: