spec = slitlet[mid-3:mid+3, :] spec = np.median(spec, axis=0) continuum = median_filter(spec, 250) if fiducial_spec.shape == (0,): fiducial_spec = spec fiducial_spec /= continuum fiducial_spec /= fiducial_spec.max() soc = spec/continuum soc /= soc.max() as_per_pix = .18/1.4 shift = -np.median(loc)/as_per_pix lags = np.arange(shift-300,shift+300,dtype=np.int) xc = Fit.xcor(soc[800:1300], fiducial_spec[800:1300], lags) #start_shell() shift = lags[np.argmax(xc)] center = width/2 - shift print center, write_pos xs = np.arange(len(spec)) pl.plot(xs - shift, spec/continuum) try: out[(write_pos - dy):write_pos, center-1024:center+1024] = slitlet if minl > center-1024: minl = center-1024 if maxl < center+1024: maxl = center+1024