# Path: EMpy/modesolvers/interface.py
# class Mode(object):
#     def get_x(self, x=None, y=None):
#         raise NotImplementedError()
# 
#     def get_y(self, x=None, y=None):
#         raise NotImplementedError()
# 
#     def intensity(self, x=None, y=None):
#         raise NotImplementedError()
# 
#     def TEfrac(self, x=None, y=None):
#         raise NotImplementedError()
# 
#     def overlap(self, x=None, y=None):
#         raise NotImplementedError()
# 
#     def get_fields_for_FDTD(self, x, y):
#         raise NotImplementedError()
# 
#     def save_for_FDTD(self, mode_id="", x=None, y=None):
#         """Save mode's fields on a staggered grid."""
#         Ex_FDTD, Ey_FDTD, Ez_FDTD, Hx_FDTD, Hy_FDTD, Hz_FDTD = self.get_fields_for_FDTD(
#             x, y
#         )
#         Ex_FDTD.real.T.tofile("ex" + mode_id + ".dat", sep=" ")
#         Ex_FDTD.imag.T.tofile("iex" + mode_id + ".dat", sep=" ")
#         Ey_FDTD.real.T.tofile("ey" + mode_id + ".dat", sep=" ")
#         Ey_FDTD.imag.T.tofile("iey" + mode_id + ".dat", sep=" ")
#         Ez_FDTD.real.T.tofile("ez" + mode_id + ".dat", sep=" ")
#         Ez_FDTD.imag.T.tofile("iez" + mode_id + ".dat", sep=" ")
#         Hx_FDTD.real.T.tofile("hx" + mode_id + ".dat", sep=" ")
#         Hx_FDTD.imag.T.tofile("ihx" + mode_id + ".dat", sep=" ")
#         Hy_FDTD.real.T.tofile("hy" + mode_id + ".dat", sep=" ")
#         Hy_FDTD.imag.T.tofile("ihy" + mode_id + ".dat", sep=" ")
#         Hz_FDTD.real.T.tofile("hz" + mode_id + ".dat", sep=" ")
#         Hz_FDTD.imag.T.tofile("ihz" + mode_id + ".dat", sep=" ")
# 
#     def plot(self, x=None, y=None):
#         raise NotImplementedError()
# 
# class ModeSolver(object):
#     def solve(self, *argv):
#         raise NotImplementedError()


from builtins import zip
from builtins import range
from builtins import object
from functools import reduce
from EMpy.modesolvers.interface import Mode, ModeSolver
import copy
import numpy
import scipy
import scipy.optimize
import pylab
import EMpy.utils
            y = numpy.atleast_1d(y_)

        f = self.fields(x, y)

        # fields
        pylab.figure()
        titles = ["Ex", "Ey", "Ez", "cBx", "cBy", "cBz"]
        for i in range(6):
            subplot_id = 231 + i
            pylab.subplot(subplot_id)
            pylab.contour(x, y, numpy.abs(f[i]))
            pylab.xlabel("x")
            pylab.ylabel("y")
            pylab.title(titles[i])
            pylab.axis("image")
        pylab.show()

        # power
        pylab.figure()
        pylab.contour(x, y, numpy.abs(f[-1]))
        pylab.xlabel("x")
        pylab.ylabel("y")
        pylab.title("cSz")
        pylab.axis("image")
        pylab.show()

    def __str__(self):
        return "neff = %s" % (self.keff / (2 * numpy.pi / self.slicesx[0].wl))



# Path: EMpy/modesolvers/interface.py
# class Mode(object):
#     def get_x(self, x=None, y=None):
#         raise NotImplementedError()
# 
#     def get_y(self, x=None, y=None):
#         raise NotImplementedError()
# 
#     def intensity(self, x=None, y=None):
#         raise NotImplementedError()
# 
#     def TEfrac(self, x=None, y=None):
#         raise NotImplementedError()
# 
#     def overlap(self, x=None, y=None):
#         raise NotImplementedError()
# 
#     def get_fields_for_FDTD(self, x, y):
#         raise NotImplementedError()
# 
#     def save_for_FDTD(self, mode_id="", x=None, y=None):
#         """Save mode's fields on a staggered grid."""
#         Ex_FDTD, Ey_FDTD, Ez_FDTD, Hx_FDTD, Hy_FDTD, Hz_FDTD = self.get_fields_for_FDTD(
#             x, y
#         )
#         Ex_FDTD.real.T.tofile("ex" + mode_id + ".dat", sep=" ")
#         Ex_FDTD.imag.T.tofile("iex" + mode_id + ".dat", sep=" ")
#         Ey_FDTD.real.T.tofile("ey" + mode_id + ".dat", sep=" ")
#         Ey_FDTD.imag.T.tofile("iey" + mode_id + ".dat", sep=" ")
#         Ez_FDTD.real.T.tofile("ez" + mode_id + ".dat", sep=" ")
#         Ez_FDTD.imag.T.tofile("iez" + mode_id + ".dat", sep=" ")
#         Hx_FDTD.real.T.tofile("hx" + mode_id + ".dat", sep=" ")
#         Hx_FDTD.imag.T.tofile("ihx" + mode_id + ".dat", sep=" ")
#         Hy_FDTD.real.T.tofile("hy" + mode_id + ".dat", sep=" ")
#         Hy_FDTD.imag.T.tofile("ihy" + mode_id + ".dat", sep=" ")
#         Hz_FDTD.real.T.tofile("hz" + mode_id + ".dat", sep=" ")
#         Hz_FDTD.imag.T.tofile("ihz" + mode_id + ".dat", sep=" ")
# 
#     def plot(self, x=None, y=None):
#         raise NotImplementedError()
# 
# class ModeSolver(object):
#     def solve(self, *argv):
#         raise NotImplementedError()


# Path: EMpy/modesolvers/FMM.py
from builtins import zip
from builtins import range
from builtins import object
from functools import reduce
from EMpy.modesolvers.interface import Mode, ModeSolver
import copy
import numpy
import scipy
import scipy.optimize
import pylab
import EMpy.utils

            y = numpy.atleast_1d(y_)

        f = self.fields(x, y)

        # fields
        pylab.figure()
        titles = ["Ex", "Ey", "Ez", "cBx", "cBy", "cBz"]
        for i in range(6):
            subplot_id = 231 + i
            pylab.subplot(subplot_id)
            pylab.contour(x, y, numpy.abs(f[i]))
            pylab.xlabel("x")
            pylab.ylabel("y")
            pylab.title(titles[i])
            pylab.axis("image")
        pylab.show()

        # power
        pylab.figure()
        pylab.contour(x, y, numpy.abs(f[-1]))
        pylab.xlabel("x")
        pylab.ylabel("y")
        pylab.title("cSz")
        pylab.axis("image")
        pylab.show()

    def __str__(self):
        return "neff = %s" % (self.keff / (2 * numpy.pi / self.slicesx[0].wl))



class FMM(ModeSolver):