code: private void calcInsolation( double lambda, WritableRaster demWR, WritableRaster gradientWR, WritableRaster insolationWR,
              int day, double dx ) {
          // calculating the day angle
          // double dayang = 2 * Math.PI * (day - 1) / 365.0;
          double dayangb = (360 / 365.25) * (day - 79.436);
          dayangb = Math.toRadians(dayangb);
          // Evaluate the declination of the sun.
          delta = getDeclination(dayangb);
          // Evaluate the radiation in this day.
          double ss = Math.acos(-Math.tan(delta) * Math.tan(lambda));
          double hour = -ss + (Math.PI / 48.0);
          while( hour <= ss - (Math.PI / 48) ) {
              omega = hour;
              // calculating the vector related to the sun
              double sunVector[] = calcSunVector();
              double zenith = calcZenith(sunVector[2]);
              double[] inverseSunVector = calcInverseSunVector(sunVector);
              double[] normalSunVector = calcNormalSunVector(sunVector);
  
              int height = demWR.getHeight();
              int width = demWR.getWidth();
              WritableRaster sOmbraWR = calculateFactor(height, width, sunVector, inverseSunVector, normalSunVector, demWR, dx);
              double mr = 1 / (sunVector[2] + 0.15 * Math.pow((93.885 - zenith), (-1.253)));
              for( int j = 0; j < height; j++ ) {
                  for( int i = 0; i < width; i++ ) {
                      // evaluate the radiation.
                      calcRadiation(i, j, demWR, sOmbraWR, insolationWR, sunVector, gradientWR, mr);
                  }
              }
              hour = hour + Math.PI / 24.0;
          }
      }
docs: Evaluate the radiation.
  
  @param lambda
  the latitude.
  @param demWR
  the raster of elevation
  @param gradientWR
  the raster of the gradient value of the dem.
  @param insolationWR
  the wr where to store the result.
  @param the
  day in the year.
  @paradx the resolutiono of the dem.