The source project of this merge request has been removed.
Scaling of the amplitudes on the right code
The code should find the amplitude gains using the maths that I sent you. Then I take the median and correct the model visibilities using the diffuse sky as a reference. I did not have time to fully run this code, so use it with caution. It worked on the old version of your code.
Lastly, I think that some variables, like the zenith, can be calculated locally, but I did not have time to look at it fully yet. This version should work and I can improve it when I am back or if I get bored in the holiday.