# Solar incidence angle using Google Earth Engine

I am using the formula for solar incidence angle: cosd = sin(a)sin(b) + cos(a)cos(b)cos(c), where a = 0.409sin((2pi/365)*DOY - 1.39), b = latitude of region and c = hour angle (taken as constant for daily estimates). The code for the formula is not working. My code:

``````// Zoom to a location.
Map.setCenter(80.34, 26.42); // Center on IIT Kanpur.
var G = 1367;

//dayofyear
var sequence = ee.Array(ee.List.sequence(1, 365));

//calculating the relative earth sun distance
print(dr);

//calculating the solar incidence angle
//getting latitude and longitude of the geometry
var l8 = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR")
.filterBounds(geometry);
var first = ee.Image(l8.first()).clip(geometry);
// get image projection
var proj = first.select([0]).projection();
// get coordinates image
var latlon = ee.Image.pixelLonLat().reproject(proj);

// put each lon lat in a list
var coords = latlon.select(['longitude', 'latitude'])
.reduceRegion({
reducer: ee.Reducer.toList(),
geometry: geometry,
scale: 30
});
var lat1 = ee.List(coords.get('latitude'));
var lat = ee.Array(lat1);
var lon = ee.List(coords.get('longitude'));
// zip them. Example: zip([1, 3],[2, 4]) --> [[1, 2], [3,4]]
var point_list = lon.zip(lat);
//getting the declination angle and hour angle
var d = ee.Number(dr).multiply(2*Math.PI).divide(365).subtract(1.39).sin().multiply(0.409);
var w = 1; //assuming average of hour angle as 0 degrees
var cosd1 =  d.sin();
var cosd2 = lat.sin();
var cosd3 = d.cos();
var cosd4 = lat.cos();
var cosd01 = cosd1.multiply(cosd2);
//print(cosd01);
var cosd02 = cosd3.multiply(cosd4);