Ejemplo n.º 1
0
def addmodeldata(m):
    value = []
    value.append('')
    for k in Observable:
        #parameter.append(Observable[k])
        if type(m.__dict__[k]) in (tuple, list):
            val, err = m.__dict__[k]
            if k == 'RAJ':
                ra = RA(m.__dict__[k][0])
                raerr = m.__dict__[k][1]
                value.append('%s:%s:%s' % (ra.HH,ra.MM, parseerror(Decimal(ra.SS),Decimal(raerr))))
            elif k == 'DECJ':
                dec = Dec(m.__dict__[k][0])
                decerr = m.__dict__[k][1]
                value.append('%s:%s:%s' % (dec.dd,dec.mm, parseerror(Decimal(dec.ss),Decimal(decerr))))
            else:
                value.append(parseerror(*m.__dict__[k]))
        else:
            if k == 'DM':
                value.append(parseerror(*aveDM(m)))
            else:
                value.append((m.__dict__[k]))

    value.append('')

    for k in Fixed:
        #parameter.append(Fixed[k])
        try:
            value.append(parseerror(*m.__dict__[k]))
        except:
            if type(m.__dict__[k]) == type(''):
                value.append(m.__dict__[k])
            elif k == 'PEPOCH':
                value.append(m.__dict__[k].quantize(50000))
            elif k == 'OMDOT':
                value.append(m.__dict__[k].quantize(Decimal(0.0001)))
            else:
                value.append(SF(globals()[k](m)))
    #data = [parameter, value]

    value.append('')

    for k in Derived:
        #parameter.append(Derived[k])
        if k == 'PAASCNODE':
            value.append(m.__dict__[k])
        else:
            try:
                value.append(parseerror(*m.__dict__[k]))
            except:
                value.append(SF(globals()[k](m)))
    return value
Ejemplo n.º 2
0
def addmodeldata(m):
    value = []
    value.append('')
    for k in Observable:
        if k == 'KIN':
            try:
                kin = float(m.__dict__[k][0])/180.*np.pi; kinerr = float(m.__dict__[k][1])/180.*np.pi
                cosi = Decimal(str(np.cos(kin)))
                dcosi = Decimal(str(np.sin(kin)*kinerr))
                value.append(parseerror(*[cosi, dcosi]))
            except:
                k = 'SINI'
                sini = float(m.__dict__[k][0]); dsini = float(m.__dict__[k][0])
                cosi = np.sqrt(1 - sini**2)
                dcosi = Decimal(str(np.abs(dsini*sini/cosi)))
                cosi = Decimal(str(cosi))
                value.append(parseerror(*[cosi, dcosi]))
        #parameter.append(Observable[k])
        elif type(m.__dict__[k]) in (tuple, list):
            val, err = m.__dict__[k]
            if k == 'RAJ':
                ra = RA(m.__dict__[k][0])
                raerr = m.__dict__[k][1]
                value.append('%s:%s:%s' % (ra.HH,ra.MM, parseerror(Decimal(ra.SS),Decimal(raerr))))
            elif k == 'DECJ':
                dec = Dec(m.__dict__[k][0])
                decerr = m.__dict__[k][1]
                value.append('%s:%s:%s' % (dec.dd,dec.mm, parseerror(Decimal(dec.ss),Decimal(decerr))))
            elif k == 'PBDOT':
                if m.__dict__[k][0] < Decimal(1.e-10):
                    m.__dict__[k][0]/=Decimal(1.e-12)
                    m.__dict__[k][1]/=Decimal(1.e-12)
                    value.append(parseerror(*m.__dict__[k]))
                else:
                    value.append(parseerror(*m.__dict__[k]))
            else:
                value.append(parseerror(*m.__dict__[k]))
        else:
            if k == 'DM':
                value.append(parseerror(*aveDM(m)))
            else:
                value.append((m.__dict__[k]))

    value.append('')

    for k in Fixed:
        #parameter.append(Fixed[k])
        if k == 'OMDOT':
            value.append(m.__dict__[k][0].quantize(Decimal(0.00001)))
        elif not m.__dict__.has_key(k):
            value.append('--')
        else:
            try:
                value.append(parseerror(*m.__dict__[k]))
            except:
                if type(m.__dict__[k]) == type(''):
                    value.append(m.__dict__[k])
                elif k == 'PEPOCH':
                    value.append(m.__dict__[k].quantize(50000))
                elif k in ['RNAMP', 'RNIDX']:
                    value.append(m.__dict__[k].quantize(Decimal(0.001)))
                else:
                    value.append(SF(globals()[k](m)))
    #data = [parameter, value]

    value.append('')

    for k in Derived:
        #parameter.append(Derived[k])
        try:
            value.append(parseerror(*m.__dict__[k]))
        except:
            if k == 'M1':
                value.append(parseerror(*M1(m)))
            else:
                value.append(parseerror(*globals()[k](m)))
    return value
Ejemplo n.º 3
0
            value.append((m.__dict__[k]))

parameter.append(r'\textit{Fixed Parameters}')
value.append('')

for k in Fixed:
    parameter.append(Fixed[k])
    try:
        value.append(parseerror(*m.__dict__[k]))
    except:
        if type(m.__dict__[k]) == type(''):
            value.append(m.__dict__[k])
        elif type(m.__dict__[k]) == type(m.__dict__['PEPOCH']):
            value.append(m.__dict__[k].quantize(50000))
        else:
            value.append(SF(globals()[k](m)))
data = [parameter, value]

parameter.append(r'\textit{Derived Parameters}')
value.append('')

for k in Derived:
    parameter.append(Derived[k])
    try:
        value.append(parseerror(*m.__dict__[k]))
    except:
        value.append(SF(globals()[k](m)))
data = [parameter, value]


table = deluxetable(Caption=Caption, colsetting='lc', colnames = colnames, data=data, label="tab:par", comments=['Numbers in parentheses indicate the uncertainties on the last digit(s).  Uncertainties on parameters are estimated from a general least square fit using {\sc tempo}.', 'The averaged DM value; See Section 3.2 and Figure 2 for the more discussion.', 'See Figure 2 of \citealt{sns+05} for definition.'])
Ejemplo n.º 4
0
import numpy as np
from round import TexStyle as SF

#data = np.genfromtxt("g_rob.txt", dtypes=[('gx'), (), (), ()])
data = np.loadtxt("g_orb.txt", dtype='f')

print data.shape

g_x = data[:, 0]
g_y = data[:, 1]
print(g_x.mean(), np.std(g_x)), (g_y.mean(), np.std(g_y))
print SF([g_x.mean(), np.std(g_x)]), SF([g_y.mean(), np.std(g_y)])
Ejemplo n.º 5
0
def addmodeldata(m):
    value = []
    value.append('')
    for k in Observable:
        #parameter.append(Observable[k])
        if type(m.__dict__[k]) in (tuple, list):
            val, err = m.__dict__[k]
            if k == 'RAJ':
                ra = RA(m.__dict__[k][0])
                raerr = m.__dict__[k][1]
                value.append(
                    '%s:%s:%s' %
                    (ra.HH, ra.MM, parseerror(Decimal(ra.SS), Decimal(raerr))))
            elif k == 'DECJ':
                dec = Dec(m.__dict__[k][0])
                decerr = m.__dict__[k][1]
                value.append('%s:%s:%s' %
                             (dec.dd, dec.mm,
                              parseerror(Decimal(dec.ss), Decimal(decerr))))
            elif k == 'PBDOT':
                if m.__dict__[k][0] < Decimal(1.e-10):
                    m.__dict__[k][0] /= Decimal(1.e-12)
                    m.__dict__[k][1] /= Decimal(1.e-12)
                    value.append(parseerror(*m.__dict__[k]))
                else:
                    value.append(parseerror(*m.__dict__[k]))
            else:
                value.append(parseerror(*m.__dict__[k]))
        else:
            if k == 'DM':
                value.append(parseerror(*aveDM(m)))
            else:
                value.append((m.__dict__[k]))

    value.append('')

    for k in Fixed:
        #parameter.append(Fixed[k])
        if k == 'OMDOT':
            value.append(m.__dict__[k][0].quantize(Decimal(0.00001)))
        elif not m.__dict__.has_key(k):
            value.append('--')
        else:
            try:
                value.append(parseerror(*m.__dict__[k]))
            except:
                if type(m.__dict__[k]) == type(''):
                    value.append(m.__dict__[k])
                elif k == 'PEPOCH':
                    value.append(m.__dict__[k].quantize(50000))
                elif k in ['RNAMP', 'RNIDX', 'TNRedAmp', 'TNRedGam']:
                    value.append(m.__dict__[k].quantize(Decimal(0.001)))
                else:
                    value.append(SF(globals()[k](m)))
    #data = [parameter, value]

    value.append('')

    for k in Derived:
        #parameter.append(Derived[k])
        try:
            value.append(parseerror(*m.__dict__[k]))
        except:
            if k == 'M1':
                value.append(parseerror(*M1(m)))
            else:
                value.append(parseerror(*globals()[k](m)))
    return value
Ejemplo n.º 6
0
    #pf.PBDOT[0] *= Decimal('1.e-15')
    #pf.PBDOT[1] *= Decimal('1.e-15')
Shl = Shlkovskii(pf)
Gal = Pbdot_Gal(pf)
GW = Pbdot_GW(pf)
Pbdot_exc_1713 = float(pf.PBDOT[0]) - Gal[0] - Shl[0] - GW[0]
Pbdot_Shl = Shl[0]
Pbdot_Shl_err = Shl[1]
Pbdot_Gal_val = Gal[0]
Pbdot_Gal_err = Gal[1]
Pbdot_exc_err = sqrt(float(pf.PBDOT[1])**2 + Gal[1]**2 + Shl[1]**2 + GW[1]**2)
print 'PSR ', pf.PSRJ
#print Pbdot_Shl_err, Pbdot_Gal_err, Pbdot_exc_err
#print M1(pf)
#print 'Pbdot_obs:', SF((float(pf.PBDOT[0])*1.e13, float(pf.PBDOT[1])*1.e13))
print 'Pbdot_obs:', SF((float(pf.PBDOT[0]), float(pf.PBDOT[1])))
print 'Pbdot_Shl:', SF((Pbdot_Shl, Pbdot_Shl_err))
print 'Pbdot_Gal:', SF((Pbdot_Gal_val, Pbdot_Gal_err))
#print 'Pbdot_exc:', SF((float(Pbdot_exc_1713)*1.e13, Pbdot_exc_err))
print 'Pbdot_exc:', SF((float(Pbdot_exc_1713), Pbdot_exc_err))
print 'Pbdot_GW:', SF(Pbdot_GW(pf))
#sys.exit(0)
PbdOPb1713 = float(Pbdot_exc_1713) / float(pf.PB[0]) / secperday
#PbdOPberr1713 = float(pf.PBDOT[1])/float(pf.PB[0])/secperday
PbdOPberr1713 = Pbdot_exc_err / float(pf.PB[0]) / secperday

print 'Pbdot/Pb [%s]:' % (pf.PSRJ), SF((PbdOPb1713, PbdOPberr1713))

#sys.exit(0)

PbdOPb1012 = -0.4e-14 / 0.60467271355 / secperday
Ejemplo n.º 7
0
    def testSF(self):
        self.assertEqual(SF(self.string),self.stringres)
        self.assertEqual(SF(self.float),self.floatres)
        self.assertEqual(SF(self.float1),self.float1res)
        self.assertEqual(SF(self.float2),self.float2res)
        self.assertEqual(SF(self.float3),self.float3res)
        self.assertEqual(SF(self.tuple2),self.tuple2res)
        self.assertEqual(SF(self.tuple2s),self.tuple2sres)
        self.assertEqual(SF(self.tuple2a),self.tuple2ares)
        self.assertEqual(SF(self.tuple2b),self.tuple2bres)
        self.assertEqual(SF(self.tuple2c),self.tuple2cres)
        self.assertEqual(SF(self.tuple2d),self.tuple2dres)
        self.assertEqual(SF(self.tuple2e),self.tuple2eres)
        self.assertEqual(SF(self.tuple2f),self.tuple2fres)
        self.assertEqual(SF(self.tuple3),self.tuple3res)
        self.assertEqual(SF(self.tuple3s),self.tuple3sres)
        self.assertEqual(SF(self.tuple3a),self.tuple3ares)
        self.assertEqual(SF(self.tuple3b),self.tuple3bres)
        self.assertEqual(SF(self.tuple3c),self.tuple3cres)
        self.assertEqual(SF(self.tuple3d),self.tuple3dres)
        self.assertEqual(SF(self.tuple3e),self.tuple3eres)
        self.assertEqual(SF(self.tuple3f),self.tuple3fres)
        #self.assertEqual(SF(self.tuplewithstring),self.tuplewithstringres)
        self.assertEqual(SF(self.tuple3jinwei),self.tuple3jinweires)
        #self.assertEqual(SF(self.lists1),self.lists1res)
        #self.assertEqual(SF(self.lists2),self.lists2res)
        self.assertEqual(SF(self.tentotheone),self.tentotheoneres)
        self.assertEqual(SF(self.verysmallerr),self.verysmallerrres)
        self.assertEqual(SF(self.numsigdigittest, NumSigDigit=1),self.numsigdigittestres)
        self.assertEqual(SF(self.numsigdigittest1, NumSigDigit=1),self.numsigdigittestres1)
        self.assertEqual(SF(self.numsigdigittest2, NumSigDigit=1),self.numsigdigittestres2)

        self.show(self.string,self.stringres)
        self.show(self.float,self.floatres)
        self.show(self.float1,self.float1res)
        self.show(self.float2,self.float2res)
        self.show(self.float3,self.float3res)
        self.show(self.tuple2,self.tuple2res)
        self.show(self.tuple2s,self.tuple2sres)
        self.show(self.tuple2a,self.tuple2ares)
        self.show(self.tuple2b,self.tuple2bres)
        self.show(self.tuple2c,self.tuple2cres)
        self.show(self.tuple2d,self.tuple2dres)
        self.show(self.tuple2e,self.tuple2eres)
        self.show(self.tuple2f,self.tuple2fres)
        self.show(self.tuple3,self.tuple3res)
        self.show(self.tuple3s,self.tuple3sres)
        self.show(self.tuple3a,self.tuple3ares)
        self.show(self.tuple3b,self.tuple3bres)
        self.show(self.tuple3c,self.tuple3cres)
        self.show(self.tuple3d,self.tuple3dres)
        self.show(self.tuple3e,self.tuple3eres)
        self.show(self.tuple3f,self.tuple3fres)
        #self.show(self.tuplewithstring,self.tuplewithstringres)
        self.show(self.tuple3jinwei,self.tuple3jinweires)
        #self.show(self.lists1,self.lists1res)
        #self.show(self.lists2,self.lists2res)
        self.show(SF(self.tentotheone),self.tentotheoneres)
        self.show(SF(self.verysmallerr),self.verysmallerrres)
        self.show(SF(self.numsigdigittest, NumSigDigit=1),self.numsigdigittestres)
        self.show(SF(self.numsigdigittest1, NumSigDigit=1),self.numsigdigittestres1)
        self.show(SF(self.numsigdigittest2, NumSigDigit=1),self.numsigdigittestres2)
Ejemplo n.º 8
0
    #pf  = PARfile('./mcmcresult.par')
    #pf  = PARfile('./1713.Apr.par')
    pf  = PARfile('./Oct.T2.par')
    if pf.PBDOT[0] > Decimal('1.e-10'):#tempo 1 units
        pf.PBDOT[0] *= Decimal('1.e-12')
        pf.PBDOT[1] *= Decimal('1.e-12')

    from round import shortform as SF
    Shl = Shlkovskii(pf)
    Gal = Pbdot_Gal(pf)
    GW = Pbdot_GW(pf)
    if pf.__dict__.has_key('PSR'):
        print pf.PSR
    else:
        print pf.PSRJ
    print 'PBdot(shlkovskii):', SF(Shl)
    print 'PBdot(Galaxtic):' , SF(Gal)
    print 'PBdot(GW):', SF(GW)
    pb_exc = (float(pf.PBDOT[0]) - Gal[0] - Shl[0] - GW[0]), sqrt(float(pf.PBDOT[1])**2 + Gal[1]**2 + Shl[1]**2 + GW[1]**2)
    print "PBdot - PBdot(Galaxtic) - PBdot(shlkovskii) - PBdot(GW), PBdot_exc_err:",
    print SF(pb_exc)   
    print float(pf.PBDOT[0]) - Gal[0] - Shl[0] - GW[0], sqrt(float(pf.PBDOT[1])**2 + Gal[1]**2 + Shl[1]**2 + GW[1]**2)
    print "PBdot , PBdot(Galaxtic) + PBdot(shlkovskii) + PBdot(GW):",
    print pf.PBDOT[0] , Shl[0]+Gal[0]+GW[0]
    print "-PBdot_excess/PB/2 --> Gdot/G (95%):",

    print SF((-1*pb_exc[0]/float(pf.PB[0])/secperday/2*secperyear, pb_exc[1]/float(pf.PB[0])/secperday*secperyear))
    print ((pb_exc[0]/float(pf.PB[0])/secperday*secperyear, pb_exc[1]/float(pf.PB[0])/secperday*secperyear*2))
    #print SF(( float((pf.PBDOT[0] - Pbdot_Gal(pf) - Decimal(Shlkovskii(pf)) )/ pf.PB[0]/ secperday) , float( pf.PBDOT[1]*2 / pf.PB[0]/ secperday ) ))

    #Pbdot_exc_1713 = (pf.PBDOT[0] - Pbdot_Gal(pf) - Decimal(Shlkovskii(pf)) )
Ejemplo n.º 9
0
ddmers = data[3, ...]
#A,B,r,p,s = linregress(np.log(delays), np.log(ddmsqs))
a = axes([.62, .6, .25, .3])


def func(x, b, c):
    return c * (x)**(b - 2)


popt, pcov = curve_fit(func, delays, ddmsqs)
popt, pcov = curve_fit(func, delays, ddmsqs, sigma=ddmers, p0=popt)
B, C = popt
Berr = np.sqrt(pcov[0, 0])
Cerr = np.sqrt(pcov[1, 1])
from round import shortform as SF
print 'beta:', SF((B, Berr)), 'C:', SF((C, Cerr))
x = np.linspace(10, 1.e4, 30)
y = func(x, B, C)
a.plot(x, y, 'k-')

#def Kfunc(x,  c):
#return c*(x)**(11./3-2)
#popt, pcov = curve_fit(Kfunc, delays, ddmsqs, sigma=ddmers)
#C = popt[0]
#y = Kfunc(x, C)#Kolmogorov
#y = func(x, 11./3, C)#Kolmogorov
#a.plot(x,y, 'k--')

a.errorbar(delays, ddmsqs, xerr=biners, yerr=ddmers, fmt='ok')
a.semilogx()
a.semilogy()
Ejemplo n.º 10
0
ylim = (int(ymax / ybinwidth) + 1) * ybinwidth

axScatter.set_xlim((-xlim, xlim))
axScatter.set_ylim((-ylim, ylim))

xbins = np.arange(-xlim, xlim + xbinwidth, xbinwidth)
ybins = np.arange(-ylim, ylim + ybinwidth, ybinwidth)
axHistx.hist(x, bins=xbins, normed=1)
axHisty.hist(y, bins=ybins, orientation='horizontal', normed=1)
axHistx.plot(xbins, xkde.evaluate(xbins), 'r-')
axHisty.plot(ykde.evaluate(ybins), ybins, 'r-')
axHistx.plot(xbins, xpdf.pdf(xbins), 'g-')
axHisty.plot(ypdf.pdf(ybins), ybins, 'g-')

axHistx.set_xlim(axScatter.get_xlim())
axHisty.set_ylim(axScatter.get_ylim())

for t1 in axHistx.get_xticklabels():
    t1.set_visible(False)
axHistx.set_yticks([0])
for t1 in axHisty.get_yticklabels():
    t1.set_visible(False)
axHisty.set_xticks([0])

plt.draw()
plt.show()

from round import shortform as SF

print SF((xm, xsigma)), SF((ym, ysigma))