Parses the frequency dependent dielectric function (obtained with
        LOPTICS). Frequencies (in eV) are in self.frequencies, and dielectric
        tensor function is given as self.dielectric_tensor_function.

def read_freq_dielectric(self):
        """
        Parses the frequency dependent dielectric function (obtained with
        LOPTICS). Frequencies (in eV) are in self.frequencies, and dielectric
        tensor function is given as self.dielectric_tensor_function.
        """

        plasma_pattern = r"plasma frequency squared.*"
        dielectric_pattern = r"frequency dependent\s+IMAGINARY " \
                             r"DIELECTRIC FUNCTION \(independent particle, " \
                             r"no local field effects\)(\sdensity-density)*$"
        row_pattern = r"\s+".join([r"([\.\-\d]+)"] * 3)
        plasma_frequencies = collections.defaultdict(list)
        read_plasma = False
        read_dielectric = False
        energies = []
        data = {"REAL": [], "IMAGINARY": []}
        count = 0
        component = "IMAGINARY"
        with zopen(self.filename, "rt") as f:
            for l in f:
                l = l.strip()
                if re.match(plasma_pattern, l):
                    read_plasma = "intraband" if "intraband" in l else "interband"
                elif re.match(dielectric_pattern, l):
                    read_plasma = False
                    read_dielectric = True
                    row_pattern = r"\s+".join([r"([\.\-\d]+)"] * 7)

                if read_plasma and re.match(row_pattern, l):
                    plasma_frequencies[read_plasma].append(
                        [float(t) for t in l.strip().split()])
                elif read_dielectric:
                    if re.match(row_pattern, l.strip()):
                        toks = l.strip().split()
                        if component == "IMAGINARY":
                            energies.append(float(toks[0]))
                        xx, yy, zz, xy, yz, xz = [float(t) for t in toks[1:]]
                        matrix = [[xx, xy, xz], [xy, yy, yz], [xz, yz, zz]]
                        data[component].append(matrix)
                    elif re.match(r"\s*-+\s*", l):
                        count += 1
                    if count == 2:
                        component = "REAL"
                    elif count == 3:
                        break

        self.plasma_frequencies = {k: np.array(v[:3])
                                   for k, v in plasma_frequencies.items()}
        self.dielectric_energies = np.array(energies)
        self.dielectric_tensor_function = np.array(data["REAL"]) + \
                                          1j * np.array(data["IMAGINARY"])