Beispiel #1
0
    def OnComparePhbands(self, event):
        """Plot multiple phonon bands"""

        dialog = ewx.BandsCompareDialog(self, self.phbands_filepaths)
        if dialog.ShowModal() == wx.ID_CANCEL: return

        try:
            selected = dialog.GetSelectedIndices()

        except:
            awx.showErrorMessage(self)

        plotter = PhononBandsPlotter()
        # for path, phbands in zip(self.phbands_filepaths, self.phbands_list):
        #     label = os.path.relpath(path)
        #     plotter.add_phbands(label, phbands)

        for i in selected:
            label = os.path.relpath(self.phbands_filepaths[i])
            plotter.add_phbands(label, self.phbands_list[i])

        try:
            print(plotter.bands_statdiff())
        except:
            pass
        plotter.plot()
Beispiel #2
0
    def get_plotter(self):
        """
        Return an instance of |PhononBandsPlotter| that can be use to plot
        multiple phonon bands or animate the bands
        """
        plotter = PhononBandsPlotter()
        for iv, phbands in enumerate(self.phbands_qpath_vol):
            label = "V=%.2f $A^3$ " % phbands.structure.volume
            plotter.add_phbands(label, phbands)

        return plotter
Beispiel #3
0
    def get_plotter(self):
        """
        Return an instance of |PhononBandsPlotter| that can be use to plot
        multiple phonon bands or animate the bands
        """
        plotter = PhononBandsPlotter()
        for iv, phbands in enumerate(self.phbands_qpath_vol):
            label = "V=%.2f $A^3$ " % phbands.structure.volume
            plotter.add_phbands(label, phbands)

        return plotter
Beispiel #4
0
    def test_phbands_plotter(self):
        """Testing phbands plotter."""
        phbst_paths = 2 * [abidata.ref_file("trf2_5.out_PHBST.nc")]
        phdos_paths = 2 * [abidata.ref_file("trf2_5.out_PHDOS.nc")]

        plotter = PhononBandsPlotter()
        plotter.add_phbands("AlAs", phbst_paths[0], phdos=phdos_paths[0])
        plotter.add_phbands("Same-AlAs", phbst_paths[1], phdos=phdos_paths[1])
        repr(plotter)
        str(plotter)

        assert len(plotter.phbands_list) == 2
        assert len(plotter.phdoses_list) == 2
        assert plotter.has_same_formula()

        # __add__ merges two plotters:
        p2 = plotter.add_plotter(plotter)
        assert len(p2.phbands_list) == 2
        assert len(p2.phdoses_list) == 2

        df = dataframe_from_phbands(plotter.phbands_list)
        assert "nqpt" in df

        df = plotter.get_phbands_frame()
        assert df is not None

        if self.has_matplotlib():
            assert plotter.combiplot(units="eV", show=True)
            assert plotter.gridplot(units="meV", show=True)
            assert plotter.boxplot(units="cm-1", show=True)
            assert plotter.combiboxplot(units="Thz", show=True)
            assert plotter.animate(show=False)

        if self.has_nbformat():
            plotter.write_notebook(nbpath=self.get_tmpname(text=True))

        if self.has_ipywidgets():
            assert plotter.ipw_select_plot() is not None

        # Plotter without PHDOS
        plotter = PhononBandsPlotter(
            key_phbands=[("foo", phbst_paths[0]), ("bar", phbst_paths[1])])

        if self.has_matplotlib():
            assert plotter.combiplot(units="EV", show=True)
            assert plotter.gridplot(units="MEV", show=True)
            assert plotter.boxplot(units="cm^-1",
                                   mode_range=[0, 3],
                                   swarm=True,
                                   show=True)
            assert plotter.combiboxplot(units="THZ",
                                        mode_range=[0, 3],
                                        show=True)
Beispiel #5
0
    def test_phbands_plotter(self):
        """Testing phbands plotter."""
        phbst_paths = 2 * [abidata.ref_file("trf2_5.out_PHBST.nc")]
        phdos_paths = 2 * [abidata.ref_file("trf2_5.out_PHDOS.nc")]

        plotter = PhononBandsPlotter()
        plotter.add_phbands("AlAs", phbst_paths[0], phdos=phdos_paths[0])
        plotter.add_phbands("Same-AlAs", phbst_paths[1], phdos=phdos_paths[1])
        repr(plotter); str(plotter)

        assert len(plotter.phbands_list) == 2
        assert len(plotter.phdoses_list) == 2
        assert plotter.has_same_formula()

        # __add__ merges two plotters:
        p2 = plotter.add_plotter(plotter)
        assert len(p2.phbands_list) == 2
        assert len(p2.phdoses_list) == 2

        df = dataframe_from_phbands(plotter.phbands_list)
        assert "nqpt" in df

        df = plotter.get_phbands_frame()
        assert df is not None

        if self.has_matplotlib():
            assert plotter.combiplot(units="eV", show=True)
            assert plotter.gridplot(units="meV", show=True)
            assert plotter.boxplot(units="cm-1", show=True)
            assert plotter.combiboxplot(units="Thz", show=True)
            assert plotter.animate(show=False)

        if self.has_nbformat():
            plotter.write_notebook(nbpath=self.get_tmpname(text=True))

        if self.has_ipywidgets():
            assert plotter.ipw_select_plot() is not None

        # Plotter without PHDOS
        plotter = PhononBandsPlotter(key_phbands=[("foo", phbst_paths[0]), ("bar", phbst_paths[1])])

        if self.has_matplotlib():
            assert plotter.combiplot(units="EV", show=True)
            assert plotter.gridplot(units="MEV", show=True)
            assert plotter.boxplot(units="cm^-1", mode_range=[0, 3], swarm=True, show=True)
            assert plotter.combiboxplot(units="THZ", mode_range=[0, 3], show=True)