 				   thrust::make_transform_iterator(thrust::make_counting_iterator(NY * NX), myspherer));
 
   float intensityfactor = (psum - lsum * myspherer.lfactor) / intensity;
-  if (intensityfactor < 1e-9)
+  if (intensityfactor < 1e-6)
 {
-target[idx] = -1e10;
-intens[idx] = 0;
+/*target[idx] = -1e10;
+intens[idx] = 0;*/
+intensityfactor = 1e-6;
 }
   intensityfactor *= pow(1.01, blockIdx.y - gridDim.y * 0.5);
   likelihood likelihooder(myspherer, intensityfactor);

__global__ void computeintensity(float* target, float* intens, idealsphere myspherer, float psum, float lsum)
{
  myspherer.r = exp(myspherer.roffset + (threadIdx.z + blockIdx.z * blockDim.z) * myspherer.rfactor);
  myspherer.offsetx = (threadIdx.x + blockIdx.x * blockDim.x) + myspherer.baseoffsetx;
  myspherer.offsety = /*(blockIdx.y +*/ myspherer.baseoffsety/*)*/;
  myspherer.lfactor = 1.0 / sqrt(lsum) * threadIdx.y + 1.0;

  int idx =  (threadIdx.x + blockIdx.x * blockDim.x)  + (threadIdx.y + blockIdx.y * blockDim.y) * gridDim.x * blockDim.x + (threadIdx.z + blockIdx.z * blockDim.z)  * gridDim.x * blockDim.x * gridDim.y * blockDim.y;
  float intensity = thrust::reduce(thrust::seq,

	{
	  for (int x = 0; x < NX; x++)
	    {
	      if (((y > 195 && y < 231) || y < 36 || ((x < 255  || (x < 300 && (y > 124 && y < 325))) && (y > 92 || x > 170 || x < 90)) && !(x<55 && y > 374))
	      || y < 105 || y > 343)
	      {
		photonVals[y][x] = 0;
		lambdaVals[y][x] = 0;
