layer code has a systematic error for every point. This is the last version before debugging.
a code that was tested on powder and gives the correct final weighted average, some print statements should be deleted
comments and prints mostly deleted