-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplots.py
132 lines (127 loc) · 4.18 KB
/
plots.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import numpy as np
import pylab as pl
from gls import sinefitm
from multiplot import dofig, doaxes
fac1 = 100
fac2 = 1
fac3 = 1
ls = ['-','--',':','-.']
mrk = ['.',',','+','x']
col = ['k','c','m','y']
def plotTS(time, y1, y2, y3 = None, figno = 1, discrete = True, \
savefile = None, period = None, xper = False):
'''Plot light and RV curve(s)'''
M, N = np.shape(y1)
if discrete == True:
m1 = np.copy(mrk)
else:
m1 = np.copy(ls)
if (xper == True) * (not(period is None)):
tt = time / period - 0.5
xr = [-0.5,0.5]
xttl = 'phase'
else:
tt = time
xr = np.nanmin(time), np.nanmax(time)
xttl = 'time (days)'
if y3 is None:
ny = 2
else:
ny = 3
ee = dofig(figno, 1, ny, aspect = 1)
ax1 = doaxes(ee, 1, ny, 0, 0)
for i in np.arange(M):
pl.plot(tt, y1[i,:] * fac1, m1[i], c = col[i])
pl.ylabel(r"$\Delta F$ (\%)")
ymin = np.nanmin(y1) * fac1
ymax = np.nanmax(y1) * fac1
yr = ymax - ymin
pl.ylim(ymin - 0.1 * yr, ymax + 0.1 * yr)
ax2 = doaxes(ee, 1, ny, 0, 1, sharex = ax1)
for i in np.arange(M):
pl.plot(tt, y2[i,:] * fac2, m1[i], c = col[i])
pl.ylabel(r"$\Delta V$ (m/s)")
ymin = np.nanmin(y2) * fac2
ymax = np.nanmax(y2) * fac2
yr = ymax - ymin
pl.ylim(ymin - 0.1 * yr, ymax + 0.1 * yr)
if not(y3 is None):
ax3 = doaxes(ee, 1, ny, 0, 2, sharex = ax1)
for i in np.arange(M):
pl.plot(tt, y3[i,:] * fac2, m1[i], c = col[i])
pl.ylabel(r"$V_{\rm{bis}}$ (m/s)")
ymin = np.nanmin(y3) * fac2
ymax = np.nanmax(y3) * fac2
yr = ymax - ymin
pl.ylim(ymin - 0.1 * yr, ymax + 0.1 * yr)
pl.xlabel(xttl)
pl.xlim(xr[0], xr[1])
if savefile: pl.savefig(savefile)
return
def plotPer(time, y1, y2, y3 = None, figno = 2, \
savefile = None, period = None, fmp = 8):
'''Plot light curve and RV amplitude spectra'''
M, N = np.shape(y1)
pmax = 2* (np.nanmax(time) - np.nanmin(time))
if period is None:
dt = np.median(time[1:]-time[:N-1])
pmin = dt * 2.
else:
pmin = period / fmp
nper = 1000
if period is None:
fac = 1.0
else:
fac = period
if y3 is None:
ny = 2
else:
ny = 3
y = np.zeros((M*ny, N))
y[:M,:] = y1
y[M:2*M,:] = y2
if not (y3 is None):
y[2*M:,:] = y3
res = sinefitm(time, y, fmin = 1./pmax, fmax = 1./pmin, \
nfreq = nper)
freq, amps, ampc = res[0], res[2], res[3]
pers = 1.0 / freq
amp = np.sqrt(amps**2 + ampc**2)
amp1 = amp[:M,:]
amp2 = amp[M:2*M,:]
if not (y3 is None):
amp3 = amp[2*M:,:]
ee = dofig(figno, 1, ny, aspect = 1)
ax1 = doaxes(ee, 1, ny, 0, 0)
pl.setp(ax1.get_xticklabels(), visible = False)
pl.ylabel(r"$A_F$ (\%)")
for i in np.arange(M):
pl.plot(fac / pers, amp1[i,:] * fac1, ls[i], c = col[i])
pl.ylim(0, 1.1 * np.nanmax(amp1) * fac1)
ax2 = doaxes(ee, 1, ny, 0, 1, sharex = ax1)
pl.ylabel(r"$A_V$ (m/s)")
for i in np.arange(M):
pl.plot(fac / pers, amp2[i,:] * fac2, ls[i], c = col[i])
pl.ylim(0, 1.1 * np.nanmax(amp2) * fac2)
if not(y3 is None):
ax3 = doaxes(ee, 1, ny, 0, 2, sharex = ax1)
pl.ylabel(r"$A_{\mathrm{bis}}$ (m/s)")
for i in np.arange(M):
pl.plot(fac / pers, amp3[i,:] * fac3, ls[i], c = col[i])
pl.ylim(0, 1.1 * np.nanmax(amp3) * fac3)
if period is None:
pl.xlabel(r"Frequency (cycles/day)")
else:
pl.xlabel(r"Frequency (cycles/$P_{\mathrm{rot}}^{-1}$)")
if savefile:
pl.savefig(savefile)
return
def plotTSPer(time, y1, y2, y3 = None, figno = [1,2], savefile = [None, None], \
discrete = False, period = None, xper = False, \
fmp = 8):
'''Plot both time series and amplitude spectra for light and RV'''
plotTS(time, y1, y2, y3 = y3, figno = figno[0], discrete = discrete, \
savefile = savefile[0], period = period, xper = xper)
plotPer(time, y1, y2, y3 = y3, figno = figno[1], savefile = savefile[1], \
period = period, fmp = fmp)
return