def probcal(pf): global smallestchisq pf.write() #m2 = float(str(pf.M2[0])) #Omega = float(str(pf.PAASCNODE)) #sini = float(str(pf.SINI[0])) #if m2 <= 0 or Omega > 360 or Omega < -360 or sini > 1.: #return 0 chisq, dof = tempofit(parfile, toafile = toafile, pulsefile = pulsefile) pf.chisq = chisq #print dof, chisq if chisq < smallestchisq: smallestchisq = chisq try: #return exp((smallestchisq - chisq)/2.) #Ingrid/Paul? return (smallestchisq - chisq)/2. #Ingrid/Paul? except OverflowError: print chisq, smallestchisq print pf.parfile raise OverflowError
parfile = options.parfile toafile = options.toafile pulsefile = options.pulsefile steps = options.steps mixing = options.mixing rseed = options.seed stepsize = options.stepsize px = options.paral pf =PARfile(parfile) #pf = model(parfile) pf.freezeall() pf.thawall('JUMP_') pf.write('mcmc.par') touchparfile('mcmc.par', NITS=1) chisq, dof = tempofit('mcmc.par', toafile = toafile, pulsefile = pulsefile) #pf.tempofit(TOAfile(toafile), pulsefile = pulsefile) smallestchisq = chisq #print 'smallestchisq', smallestchisq, dof cwd=os.getcwd() plist = [x for x in pf.manifest if x in pf.parameters.keys() if not x.startswith('DMX') and not x.startswith('JUMP')] bestpar = {'BEST':[pf.__dict__[p][0] for p in plist] + [chisq], 'parfile':pf.parfile, 'parameters':plist + ['chisq']} pickle.dump(bestpar, open('%s/bestpar.p' % cwd, 'w', 0), protocol=2) def run(argv): s, MarkovChain = argv