You may compare with your script. Maybe the best thing is to export the mode data and using a script to calculate the confinement factor with your own math expression. To get mode data, you can refer to the following script:
E1=getresult("mode1","E");
x=E1.x;
Ex=E1.Ex;
H1=getresult("mode1","H");
y=H1.y;
Hy=H1.Hy;