def OnCompareEdos(self, event): """Plot multiple electron DOSes""" # Open dialog to get DOS parameters. dialog = ewx.ElectronDosDialog(self) if dialog.ShowModal() == wx.ID_CANCEL: return dos_params = dialog.GetParams() plotter = ElectronDosPlotter() for path, ebands in zip(self.ebands_filepaths, self.ebands_list): try: edos = ebands.get_edos(**dos_params) label = os.path.relpath(path) plotter.add_edos(label, edos) except: awx.showErrorMessage(self) plotter.plot()
def test_api(self): """Test ElelectronDosPlotter API.""" gsr_path = abidata.ref_file("si_scf_GSR.nc") gs_bands = ElectronBands.from_file(gsr_path) edos = gs_bands.get_edos() plotter = ElectronDosPlotter() plotter.add_edos("edos1", edos) plotter.add_edos("edos2", gsr_path, edos_kwargs=dict(method="gaussian", step=0.2, width=0.4)) assert len(plotter.edos_list) == 2 if self.has_matplotlib(): plotter.combiplot(show=False) plotter.gridplot(show=False) if self.has_nbformat(): plotter.write_notebook(nbpath=self.get_tmpname(text=True))
def test_api(self): """Testing ElelectronDosPlotter API.""" gsr_path = abidata.ref_file("si_scf_GSR.nc") gs_bands = ElectronBands.from_file(gsr_path) si_edos = gs_bands.get_edos() plotter = ElectronDosPlotter() plotter.add_edos("edos1", si_edos) with self.assertRaises(ValueError): plotter.add_edos("edos1", si_edos) plotter.add_edos("edos2", gsr_path, edos_kwargs=dict(method="gaussian", step=0.2, width=0.4)) assert len(plotter.edos_list) == 2 assert not plotter._can_use_basenames_as_labels() if self.has_matplotlib(): assert plotter.combiplot(show=False) assert plotter.gridplot(show=False) if self.has_ipywidgets(): assert plotter.ipw_select_plot() is not None if self.has_nbformat(): assert plotter.write_notebook(nbpath=self.get_tmpname(text=True))