-
Notifications
You must be signed in to change notification settings - Fork 0
/
Labeling.py
76 lines (66 loc) · 1.64 KB
/
Labeling.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
# combining all *.fits data
from astropy.io import fits
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
import os
import glob
def loaddata():
path1='/home/zhou/keras/kepler/kepler_0021_orig_nokoi'
step = 100
index = 0
name1=[]
transits=[]
#loading data into matrix
for filename in glob.glob(os.path.join(path1, '*.fits')):
name1.append(filename)
#print(len(name1))
#char = input("please stop")
#length estimation
#summ = 0
#for i in range(len(name1)):
#data = fits.getdata(name1[i])
#time = data[0]
#length = len(time)
#summ = summ + int(length/step)
#print (summ)
#char = input('1234')
#main function
s=(100,274189)
trainx=np.zeros(s)
trainy=np.zeros(274189)
for i in range(len(name1)):
data = fits.getdata(name1[i])
print (name1[i], i, i/len(name1))
time=data[0]
flux=data[1]
initialtime = time[0]
length=len(time)
k = 0
t = 1
print (time[length-1])
while(k<time[length-1]): #locating transits in time
k=initialtime+t*3.166666
transits.append(k)
t=t+1
initial = 0
for j in range(0, int(length/step)):
fluxtemp=flux[initial:initial+step]
#timetemp=time[initial:initial+step]
#trainy[j+index] = 0
#plt.plot(timetemp,fluxtemp)
#for m in range(len(transits)):
# if(time[initial]<transits[m] and transits[m]<time[initial+step]):
# trainy[j+index] = 1
#print(trainy[j+index])
#plt.show()
#char = input("please stop")
trainx[:,j+index]=fluxtemp
initial = initial+step
index = index + int(length/step)
print (index)
p = 'x-nokoi.csv'
q = 'y-nokoi.csv'
np.savetxt(p,trainx,delimiter=",")
np.savetxt(q,trainy,delimiter=",")
loaddata()