Sunlight script problems

Hi, I have a problem with the output of Shadowstudy.
In the resulting output, the color scale is not working and there are black pixels in places where it does not make sense. Do you know what could be the problem please?
I am attaching the used script with the file and png images.