forked from StuartLittlefair/lfit_python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestCV.py
77 lines (61 loc) · 1.71 KB
/
testCV.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from __future__ import division, print_function
import os
import subprocess
import sys
import time
import lfit
import matplotlib.pyplot as plt
import numpy as np
from future import standard_library
from past.utils import old_div
from trm import roche
standard_library.install_aliases()
q = 0.1
inc = 86.9
phi = np.linspace(-0.5,0.5,1000)
width = np.mean(np.diff(phi))*np.ones_like(phi)/2.
xl1 = roche.xl1(q)
dphi = roche.findphi(q,inc)
rwd = 0.01 #r1_a
w = lfit.PyWhiteDwarf(old_div(rwd,xl1),0.4)
rdisc = 0.6
rexp = 0.2
d = lfit.PyDisc(q,old_div(rwd,xl1),rdisc,rexp,1000)
az = 157.0
frac = 0.2
scale = 0.039
exp1 = 2.0
exp2 = 1.0
tilt = 120.0
yaw = 1.0
#s = lfit.PySpot(q,rdisc,az,frac,scale)
s = lfit.PySpot(q,rdisc,az,frac,scale,exp1=exp1,exp2=exp2,tilt=tilt,yaw=yaw,complex=True)
rs = lfit.PyDonor(q,400)
start = time.clock()
ywd = w.calcFlux(q,inc,phi,width)
yd = d.calcFlux(q,inc,phi,width)
ys = s.calcFlux(q,inc,phi,width)
yrs = rs.calcFlux(q,inc,phi,width)
stop = time.clock()
print('LFIT version took %f' % (stop-start))
#start = time.time()
#os.system("../lfit_fake gfit.in 0.333 0.333 0.333 0.05 0.5 1.5 1000")
#stop = time.time()
#print 'C++ version took %f' % (stop-start)
pars = [0.333,0.333,0.333,0.05,
q,dphi,rdisc,0.4,rwd,scale,az,frac,rexp,0.0,
exp1,exp2,tilt,yaw]
cv = lfit.CV(pars)
flux2 = cv.calcFlux(pars,phi,width)
flux = 0.3333*(ywd + yd + ys) + 0.05*yrs
np.savetxt('cv.txt', np.column_stack((phi, flux, 0.0001*np.ones_like(flux))))
plt.plot(phi,0.33*ywd,'--b')
plt.plot(phi,0.33*yd,'--r')
plt.plot(phi,0.33*ys,'--g')
plt.plot(phi,0.05*yrs,'--y')
plt.plot(phi,flux,'-k')
plt.plot(phi,flux2,'-r')
#phi,flux,err = np.loadtxt('IYUMa.txt').T
#plt.plot(phi-1,flux,'--k')
plt.ylim((0.0,1.1))
plt.show()