forked from isadoranun/time-series-feats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
alignLC.py
59 lines (45 loc) · 1.77 KB
/
alignLC.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
import numpy as np
def Align_LC(mjd, mjd2, data, data2, error, error2):
if len(data2) > len(data):
new_data2 = []
new_error2 = []
new_mjd2 = []
new_mjd = np.copy(mjd)
new_error = np.copy(error)
new_data = np.copy(data)
count = 0
for index in xrange(len(data)):
where = np.where(mjd2 == mjd[index])
if np.array_equal(where[0], []) is False:
new_data2.append(data2[where])
new_error2.append(error2[where])
new_mjd2.append(mjd2[where])
else:
new_mjd = np.delete(new_mjd, index - count)
new_error = np.delete(new_error, index - count)
new_data = np.delete(new_data, index - count)
count = count + 1
new_data2 = np.asarray(new_data2).flatten()
else:
new_data = []
new_error = []
new_mjd = []
new_mjd2 = np.copy(mjd2)
new_error2 = np.copy(error2)
new_data2 = np.copy(data2)
count = 0
for index in xrange(len(data2)):
where = np.where(mjd == mjd2[index])
if np.array_equal(where[0], []) is False:
new_data.append(data[where])
new_error.append(error[where])
new_mjd.append(mjd[where])
else:
new_mjd2 = np.delete(new_mjd2, (index - count))
new_error2 = np.delete(new_error2, (index - count))
new_data2 = np.delete(new_data2, (index - count))
count = count + 1
new_data = np.asarray(new_data).flatten()
new_mjd = np.asarray(new_mjd).flatten()
return new_data, new_data2, new_mjd
#return new_mjd, new_data, new_error, new_mjd2, new_data2, new_error2