I have a problem with the Moving average function in Python. I tried using a couple of methods but they didn't work. Moving average that I used before work well on my light curve, but problem occurs with phased diagram: Phase diagram with fitted moving average
I don't know why it's not working properly. Here is a code I use:
import matplotlib.pyplot as plt
import numpy as np
data = np.genfromtxt('phase.txt', dtype='float,float', names=["Time","Flux"])
t = data["Time"]
flux = data["Flux"]
def movingaverage(interval, window_size):
window = np.ones(int(window_size))/float(window_size)
return np.convolve(interval, window,'same')
av = movingaverage(flux, 10)
plt.plot(t,flux,"C0.", ms=2)
plt.plot(t,av,"r")
plt.show
I would expect something like this: fitted moving average
Here is my file with values in two columns: https://drive.google.com/file/d/1IQScAo8iduv90wuaor8o9eJT85qBpKY4/view?usp=sharing


