Capture yearly and daily cyclicality using sine - cosine function I have an hourly time series of temperature: 
(can be downloaded here: http://workupload.com/file/eFFPWvL)
plot(my_data$time, my_data$temperature, type = "l")


for which I would like to calculate a sine cosine function of the form:

As I understand the sine cosine are able to capture any complex form of seasonality/cyclicality. In my data, there is yearly seasonaly as well as hourly which I would like to capture.
I tried (in R) what I thought might be appropriate using the model estimation formula like:
fit <- lm(temperature~ time + sin(2*pi/365*time)+cos(2*pi/365*time) +
                sin(2*pi/(365*24)*time)+cos(2*pi/(365*24)*time),data=df)
lines(fit$fitted.values, col = 2)

But the result does not look promising. 

Fist of all, the high frequency pattern does not seem to capture the within day fluctuations as there should be much more "waves" (for each day). Secondly, the magnitude of my fitted line is much lower than that of the data.
Can someone pelase tell me what am I doing wrong?
 A: Instead of 
fit <- lm(temperature~ time + sin(2*pi/365*time)+cos(2*pi/365*time) +
                sin(2*pi/(365*24)*time)+cos(2*pi/(365*24)*time),data=df)
lines(fit$fitted.values, col = 2)

try 
fit <- lm(temperature~ time + sin(2*pi/(365*24)*time)+cos(2*pi/(365*24)*time),data=df)
lines(fit$fitted.values, col = 2)

You said your data are hourly. If this is true, you cannot estimate an hourly trend (https://en.wikipedia.org/wiki/Nyquist_frequency). This regression I suggest will fit a regression onto a yearly frequency (1 cycle for every 365*24 hours). I got rid of the frequency that corresponded to 1 cycle for every 365 hours, which probably isn't special. As long as you understand the units of frequency, and as long as you keep them between $0$ and a half (not inclusive), you should be alright.
Also, you are including time as a regressor in your code, but not in your math. You may or may not want to remove the time from the above call to lm().
If you want to throw in a few more frequencies, use a periodogram (https://stat.ethz.ch/R-manual/R-devel/library/stats/html/spec.pgram.html) to tell you which frequencies are pertinent.
