I am a beginner with GEE and I am trying to calculate the incoming net radiation for that I need the square inverse of relative earth sun distance using the expression dr = 1 + 0.033*cos(J*2*pi/365) where J is the day of year.

Can someone help me with this code?

``````var sequence = ee.List.sequence(1, 365);
and alternatively I used
var doy = image.date().getRelative('day', 'year');
var doyBand = ee.Image.constant(doy).uint16().rename('doy');

};
var image = ee.ImageCollection('LANDSAT/LT05/C01/T2')
.filterDate('1987-01-01', '1990-05-01')
.filterBounds(geometry);
print(withDate);
``````

You prabably want to calculate the dr on a per image basis, similar as you did for calculating the doy. That's why you will have to map over the image collection. You could add the dr function inside the function were you calculate the doy.

As your function in the question differs from the function you typed in the code below it, I assumed you want to use this: dr = 1 + 0.033*cos(J*2*pi/365):

``````// and alternatively I used

// calculate the doy band
var doy = image.date().getRelative('day', 'year');
var doyBand = ee.Image.constant(doy).uint16().rename('doy');

// calculate the dr using: dr = 1 + 0.033*cos(J*2*pi/365)
var temp = doyBand.multiply(2).multiply(Math.PI).divide(365);
var temp2 = temp.cos();
``````var sequence = ee.Array(ee.List.sequence(1, 365));