Sample Code
// Use these independent variables in the harmonic regression.
var harmonicIndependents = ee.List(['constant', 't', 'cos', 'sin']);
//print(harmonicIndependents, 'harmonicIndependents');
// Add harmonic terms as new image bands.
var harmonicLandsat = landsatCombined.map(function(image) {
var timeRadians = image.select('t').multiply(2 * Math.PI);
return image
.addBands(timeRadians.cos().rename('cos'))
.addBands(timeRadians.sin().rename('sin'))
.clip(roi);
});
print(harmonicLandsat, 'harmonicLandsat');
// // Fit the model.
var harmonicTrend = harmonicLandsat
.select(harmonicIndependents.add(dependent))
// The output of this reducer is a 4x1 array image.
.reduce(ee.Reducer.linearRegression(harmonicIndependents.length(),
1));
print(harmonicTrend, 'harmonicTrend');