This is a question on methodology. But I have 4d temperature and salinity gridded data (time, depth, lat and lon). The time is in monthly time steps. How would I get the annual harmonics of temperature and salinity using a periodicity of 12 months:

The equation is:

$$ Var(t,z,y,x) = A (z,y,x) * \cos [ (2 \pi t/P + \phi(z,y,x)] $$

Where $A$ is the amplitudes of the annual component, where $var$ is either temp or salinity. $\phi$ is the phase angle which determine the time when the maximum of the annual harmonic occurs. And $t$ varies from 0 - n months (however long the time series is).

We can isolate $A(z,y,x)$ just with algebra, but the issue is finding the phase angle where the maximum of the annual harmonic occurs.

Do you you need to take a fourier transform of monthly means (January - December), or do you take the FT of the entire time series but just look at the power spectrum at 12 months... I am using Python, and taking the fourier transform is no problem. I just don't know how to treat the data to obtain the phase angle where the maximum of the annual harmonic occurs. What might be the steps to find the annual harmonic amplitude given 4D temp and salinity (time in months, depth, lat and lon)?


1 Answer 1


With a little bit of math:

$$ A * \cos [ (2 \pi t/P + \phi] = a\sin(2\pi t/P)+b\cos(2\pi t/P)$$

Then, the amplitude is:

$$A=\sqrt{a^2+b^2}$$ and the phase is $$\phi=\arctan{\frac{b}{a}}$$


  • $\begingroup$ yeah, thank you! My issue is applying this to the 4D data... and to what extent, like monthly means (January - December) or just the trended, monthly data itself $\endgroup$
    – wabash
    Commented Nov 5, 2021 at 18:11
  • $\begingroup$ I would recommend that you use the monthly data. There is also the possibility that the A(x,y,z) could have a change in time. You have to do it point by point of the grid. You could try to do a regional average and then get the seasonal cycle in each region, but that may alias the magnitude of the cycle $\endgroup$
    – arkaia
    Commented Nov 5, 2021 at 18:49
  • $\begingroup$ Oh ok, thank you! Sorry one last question... to get the amplitude of the annual harmonic, could I just get the amplitude from the FFT just at the period of 12 months (or frequency of 1/12)? Would that constitute as the annual harmonic? $\endgroup$
    – wabash
    Commented Nov 5, 2021 at 19:23
  • 1
    $\begingroup$ You don't even need to do the FFT, you could just do a fit to that function exclusively. The issue of the FFt is that you might get some of the energy of the annual cycle into other frequencies. You can difinitely try the 1/12 frequency and see if it makes sense $\endgroup$
    – arkaia
    Commented Nov 5, 2021 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.