-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnancleaner.py
36 lines (28 loc) · 898 Bytes
/
nancleaner.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
import numpy as np
def nancleaner3d(flux, time):
dim = len(flux)
nans = []
for i in range(dim):
if np.isnan(flux[i,:]).all() == True:
nans.append(i)
fluxnew = np.delete(flux, nans, axis=0)
timenew = np.delete(time, nans)
return fluxnew, timenew
def nancleaner2d(flux, time):
blend = np.array([time, flux])
blend = np.transpose(blend)
blend2 = np.ma.compress_rows(np.ma.fix_invalid(blend))
timenew = blend2[:,0]
fluxnew = blend2[:,1]
return fluxnew, timenew
def nancleaner3d_c(flux, time, xcent, ycent):
dim = len(flux)
nans = []
for i in range(dim):
if np.isnan(flux[i,:]).all() == True:
nans.append(i)
fluxnew = np.delete(flux, nans, axis=0)
timenew = np.delete(time, nans)
xnew = np.delete(xcent, nans)
ynew = np.delete(ycent, nans)
return fluxnew, timenew, xnew, ynew