if ( fabs(im_position.x - lens[0].position_x[iterator]) <= dx/2. and fabs(im_position.y - lens[0].position_y[iterator]) <= dx/2.){
skip_image = 1;
printf("WARNING: You are using SIE potentials. An image to close to one of the potential centers has been classified as numerical error and removed \n");
}
}*/
if(skip_image==0){
//checking whether a closest image has already been found
// Loop over all images in the set that are not yet allocated to a theoretical image
// and allocate the closest one
for(inti=0;i<nimages_strongLensing[source_id]&&nimagesfound[image_id][i]==0;i++)// we search for an observed image not already linked (nimagesfound=0)
{
if(im_dist[i]<im_dist[second_closest_id])
{
second_closest_id=i;
im_index=i;// im_index value changes only if we found a not linked yet image
tim[image_id][im_index]=temp;// if we found an observed and not already linked image, we allocate the theoretical image temp
}
}
nimagesfound[image_id][im_index]++;// increasing the total number of images found (If we find more than 1 theoretical image linked to 1 real image, these theoretical
// images are included in this number)
}
}
thread_found_image=0;// for next iteration
}
}
}
}
//////////////////////////////////////computing the local chi square//////////////////////////////////////