%attempting to lsf sin and cos funcs
data = daily_anoms.pH;
time = daily_anoms.date;
P1 = 225/6; % period of cycle. 225 time steps and 6 days. If diel then 1 peak per day.
% P2 = 225/12; % this is next highest frq from the power spectrum

time = (1:1:length(time))';
A2 = [ones(length(time)) sin((2*pi*time)/P1) cos((2*pi*time)/P1)];
x2 = A2\data;
B = x2(1);
A = sqrt(sum(x2(2:end).^2));
fit = A2*x2;

% data = daily_anoms.pH;
% A2 = [ones(length(time)) sin((2*pi*time)/P1) cos((2*pi*time)/P1) sin((2*pi*time)/P2) cos((2*pi*time)/P2) sin((2*pi*time)/P3) cos((2*pi*time)/P3)];
% x2 = A2\data;
% fitO2 = A2*x2;
figure
clf
plot(time,daily_anoms.pH,'.')
hold on
plot(time,fit)
plot(time,movmean(daily_anoms.pH,15))

% plot(time,fitO2)