def fitrzw(self, przw=None, funct=rzw_dist_model): """ dftvector.fitrzw(przw=None, funct=rzw_dist_model):): Fit a model consisting of an arbitrary phase, Fourier frequency offset (dr), Fourier f-dot (z), and Fourier f-dotdot (w) to dftvector. Return the best fitting parameters in an array of [phase, dr, z, w]. If 'przw' is defined it is used as the starting guess for the fit. If 'funct' is defined that is the function that is used during the minimization. """ if przw: przw = Numeric.asarray(przw) / Numeric.array([1.0, 1.0, 4.0, 20.0]) else: przw = Numeric.array([0.0, 0.0, 0.0, 0.0]) retval = leastsq(funct, przw, args=(self)) print(retval[1]) return retval[0] * Numeric.array([1.0, 1.0, 4.0, 20.0])
for (ii, file) in indexed(argv[1:]): print(".", end=' ') profs.append(read_bestprof(file)) print("\n") ps = [] times = [] for prof in profs: ps.append(prof.P_bary) ts.append(prof.MJD_bary) ps = asarray(ps) ts = asarray(ts) ts = (ts - ts[0])*86400.0 ret = leastsq(orbresid, [1.0/191.246, 5700.0, 0.04, 0.0], args=(ts, ps)) plotxy(ps*1000.0, ts, line=None, symbol=2, labx="Time (s)", laby="Pulse Period (ms)", device="4U_1820-303_orbit.ps/CPS") fullts = arange(1000.0)/1000.0*max(ts) plotxy(periodorbeqn(ret[0], fullts)*1000.0, fullts, line=1, symbol=None, color='red') closeplot() print("Best Ppsr (ms) = %17.15g" % ret[0][0]) print("Best Porb (s) = %17.15g" % ret[0][1]) print("Best Porb (h) = %17.15g" % (ret[0][1]/3600.0)) print("Best xorb (s) = %17.15g" % ret[0][2]) print("Best torb (s) = %17.15g" % ret[0][3]) print("Best torb (MJD) = %17.15g" % (MJD-ret[0][3]/86400.0))
for (ii, file) in indexed(argv[1:]): print ".", profs.append(read_bestprof(file)) print "\n" ps = [] times = [] for prof in profs: ps.append(prof.P_bary) ts.append(prof.MJD_bary) ps = asarray(ps) ts = asarray(ts) ts = (ts - ts[0]) * 86400.0 ret = leastsq(orbresid, [1.0 / 191.246, 5700.0, 0.04, 0.0], args=(ts, ps)) plotxy(ps * 1000.0, ts, line=None, symbol=2, labx="Time (s)", laby="Pulse Period (ms)", device="4U_1820-303_orbit.ps/CPS") fullts = arange(1000.0) / 1000.0 * max(ts) plotxy(periodorbeqn(ret[0], fullts) * 1000.0, fullts, line=1, symbol=None, color='red') closeplot()