CDT icon indicating copy to clipboard operation
CDT copied to clipboard

sinefit returns a constant way off

Open Iverno opened this issue 3 years ago • 2 comments

The constant offset (termoption 3 or 4) is not correct.

Iverno avatar Apr 15 '21 17:04 Iverno

@Iverno The examples in the documentation appear to work perfectly. Can you provide a minimal working example that replicates the problem you're running into?

chadagreene avatar Apr 15 '21 17:04 chadagreene

Hi

I used the option 4

  1. 4:
    

% case 4 % f = @(A,t) A(1)*sin((yr + A(2))2pi) + A(3) + A(4)*yr;

ft = [A doy_max C trend] also estimates a linear trend over the entire time series in units of y per year. Again, simultaneously solving for four terms will be much more computationally expensive than solving for two yerms, so you may prefer to estimate the trend on your own with polyfit, then calculate the two-term sine fit on your detrended data.

And I did not understand that the offset A(3) is calculated for the year yr = 0. My data is for 1990 – 2021 and the offset indicates that it was pretty cold when Jesus was born. The A(4) is about +0.03 degree/year. I have to do this in two steps, first to use option 3 to establish a sinus with a offset A(3) more like the mean temperature for the period of data, then eliminate the season variation by subtract the sinus values from observations. Then investigate the trends for the difference.

Iverno avatar Apr 16 '21 08:04 Iverno