fit sine wave to data I have some astronomical data which I know has a sinusoidal component to it of the form 

y = Asin(Ωt+Φ). The period of the sinusoid is equal to a sidereal day. So I know the frequency Ω. So, I just need a way to find out optimal values for A and Φ.

Now, since the period of the sinusoid is so huge and we can track a source only to an extent of about  6 hours, I never get data that would have a full cycle of a sine wave in it. most of the cases I might have only 25 percent of it, at the maximum. In this situation where I don't even have a full cycle, what is the best way to estimate the value of the amplitude and phase of the sinusoid?
Write $y(t) = A\sin(\Omega t)\cos(\phi) + A\cos(\Omega t)\sin(\phi)$. Let $A_1 = A\cos(\phi)$, $A_2 = A\sin(\phi)$. Define the variables $w(t) = \sin(\Omega t)$ and $z(t) = \cos(\Omega t)$. Now you can write
$$y(t) = \begin{bmatrix}w(t) &amp; z(t)\end{bmatrix}\begin{bmatrix}A_1 \\ A_2\end{bmatrix}$$

The rest is linear regression. To be more clear you can write your datapoints as
$$\begin{bmatrix}y_1 \\ \vdots \\ y_n\end{bmatrix} = \begin{bmatrix}w_1 &amp; z_1\\ \vdots &amp; \vdots\\ w_n &amp; z_n \end{bmatrix}\begin{bmatrix}A_1 \\ A_2\end{bmatrix}$$
Using the matrix notation 
$$Y = XB$$
You want to solve the following minimization problem
$$  \min_{B} \lVert Y - XB \rVert  = \min_{B} (Y-XB)^\top (Y-XB) $$

If you differentiate the cost function with respect to $B$ and set it to $0$, you will see that $$B = (X^\top X)^{-1}X^\top Y$$.

Having $B$ you can solve for $A$ and $\phi$.
Two samples with $90^\circ$ difference method for $y=A\sin(\omega t+\pi)$ and $T$ as the period 

first sample : $y_1=A\sin(\omega t+\pi)$
second sample : $y_2=A\sin\left(\omega\left[t+\frac T4\right]+\pi\right)=A\cos(\omega t+\pi)$
so $A^2=y_1^2+y_2^2$

B.R
s.mosaviasl