I hope I did not come off as rude! I want to apologize if I did. I was unsure if arrows and circles would have been helpful, so I wrote some text.
Oh it’s not? Wow. From @mike3996 's darkframe (thanks for that!) I would still expect this method to somewhat help with offset problems at least. If the gain has row- and column-wise deviations, I guess a simple row-wise (colum wise) subtraction(division?) of the average probably won’t help.
I have in the back of my head that A1ex from MagicLantern had an octave/matlab script for tackling the problem somewhere…I’ll look what I can find, buit I don’t know if that script actually uses the dark pixel read-outs of canon raws (i.e. I don’t know if Leica saves those dark pixels in their DNG).
EDIT: found it. https://wiki.apertus.org/index.php/Pattern_Noise
It was A1ex but not on the magic lantern forum but for the apertus camera. That one uses an CMOSIS sensor, which, you guessed it, is also the designer of the sensor inside of the M240. Sooo, probably many things that were done for the apertus sensor could be helpful in this case!
I remember that the non-FLOSS nik-collection denoiser Dfine2 had an option to reduce banding, I don’t remember if that was actually helping much as Dfine2 was not particularily good at denoising (it was just okay). But I guess there are algorithms out there to tackle the problem.
kudos