def main(self, img): """Calculate and display the Fourier transform of img""" transimg, odimg, com, n0, a, bprime = norm_and_guess(img) rad_coord, rad_profile = radial_interpolate(odimg, com, 0.3) self.ax.plot(rad_coord, rad_profile) self.ax.set_xlabel(r'pix') self.ax.set_ylabel(r'OD')
print 'err', (err**2).sum() return err def residuals2(p, rr, rrdata): print 'p', p n0_th, r0_th = p """ Returns the residuals of the fit of n2D_bose_thermal() to the od10 image. p is the array of fit parameters """ err = rrdata - n2D_bose_thermal(rr, n0_th, r0_th) print 'err', (err**2).sum() return err # radial averaging of transmission image rcoord, rtrans_prof = radial_interpolate(transimg, com, 0.15, dphi=12) # generate radial density profile od_prof = where(rtrans_prof>1e-10, -log10(rtrans_prof), 10) # fit density profile where it is not blacked out ans, succes = leastsq(residuals, p0, args=(rcoord[100:], od_prof[100:]), ftol=1e-8) #p02 = [ans[0], ans[1]] #ans2, succes2 = leastsq(residuals2, p02, args=(rcoord[700:], od_prof[700:]), ftol=1e-8) # determine temperature and number of atoms T = 0.5*mass_Na*wr**2/(1+wr**2*t_tof**2)*(ans[1]*pixsize/mag)**2/kb print 'T = ', T sigma = 3*589e-9**2/(2*pi) # resonant photon absorption cross-section for Na N = (pixsize/float(mag))**2*integrate.quad(n2D_r, 0, rcoord.max(), args=(ans))[0]/sigma
def residuals2(p, rr, rrdata): print 'p', p n0_th, r0_th = p """ Returns the residuals of the fit of n2D_bose_thermal() to the od10 image. p is the array of fit parameters """ err = rrdata - n2D_bose_thermal(rr, n0_th, r0_th) print 'err', (err**2).sum() return err # radial averaging of transmission image rcoord, rtrans_prof = radial_interpolate(transimg, com, 0.15, dphi=12) # generate radial density profile od_prof = where(rtrans_prof > 1e-10, -log10(rtrans_prof), 10) # fit density profile where it is not blacked out ans, succes = leastsq(residuals, p0, args=(rcoord[100:], od_prof[100:]), ftol=1e-8) #p02 = [ans[0], ans[1]] #ans2, succes2 = leastsq(residuals2, p02, args=(rcoord[700:], od_prof[700:]), ftol=1e-8) # determine temperature and number of atoms T = 0.5 * mass_Na * wr**2 / (1 + wr**2 * t_tof**2) * (ans[1] * pixsize / mag)**2 / kb