def __init__(self, ebands_kpath, phbst_file, phdos_file, ebands_kmesh=None): self.eb_kpath = ElectronBands.as_ebands(ebands_kpath) self.eb_kmesh = ElectronBands.as_ebands( ebands_kmesh) if ebands_kmesh is not None else None self.phbst_file = phbst_file if duck.is_string(self.phbst_file): self.phbst_file = PhbstFile(self.phbst_file) self.phb_qpath = self.phbst_file.phbands self.phdos_file = phdos_file if duck.is_string(self.phdos_file): self.phdos_file = PhdosFile(phdos_file)
def test_return_straceback_ifexc(self): """Testing return_straceback_ifexc.""" def f(a, b): return a + b with self.assertRaises(TypeError): f("hello", 1) newf = decs.return_straceback_ifexc(f) assert duck.is_string(newf("hello", 1))
def plot_linewidths_sigeph(self, sigeph, eb_ylims=None, **kwargs): """ Plot e-bands + e-DOS + Im(Sigma_{eph}) + phonons + gkq^2 Args: sigeph: |SigephFile| or string with path to file. eb_ylims: Set the data limits for the y-axis of the electron band. Accept tuple e.g. ``(left, right)`` or scalar e.g. ``left``. If None, limits are selected automatically. """ closeit = False if duck.is_string(sigeph): sigeph = SigEPhFile.from_file(sigeph) closeit = True # Build grid. share y-axis for Phbands and Phdos import matplotlib.pyplot as plt fig = plt.figure() # Electrons ax0 = plt.subplot2grid((2, 4), (0, 0), colspan=2, rowspan=1) ax1 = plt.subplot2grid((2, 4), (0, 2), colspan=1, rowspan=1) ax2 = plt.subplot2grid((2, 4), (0, 3), colspan=1, rowspan=1) # Share y-axis ax_share("y", ax0, ax1, ax2) # Phonons ax3 = plt.subplot2grid((2, 4), (1, 0), colspan=2, rowspan=1) ax4 = plt.subplot2grid((2, 4), (1, 2), colspan=1, rowspan=1) ax5 = plt.subplot2grid((2, 4), (1, 3), colspan=1, rowspan=1) # Share y-axis ax_share("y", ax3, ax4, ax5) e0 = "fermie" # Plot electrons with possible e-ph scattering channels. self.eb_kpath.plot(ax=ax0, e0=e0, with_gaps=True, ylims=eb_ylims, max_phfreq=self.phb_qpath.maxfreq, show=False) sigeph.plot_lws_vs_e0(ax=ax1, e0=e0, exchange_xy=True, show=False) sigeph.edos.plot(ax=ax2, e0=e0, exchange_xy=True, show=False) # Plot phonon bands self.phb_qpath.plot(ax=ax3, show=False) sigeph.plot_a2fw_skb_sum(ax=ax4, what="gkq2", exchange_xy=True, fontsize=8, show=False) # Plot phonon PJDOS self.phdos_file.plot_pjdos_type(ax=ax5, fontsize=8, exchange_xy=True, show=False) #set_visible(ax4, False, "ylabel") #ax4.tick_params("y", left=False, labelleft=False) #ax4.tick_params("y", right=True, labelright=True) if closeit: sigeph.close() return fig
def test_is_string(self): """Testing is_string.""" assert duck.is_string("hello") assert not duck.is_string(1) assert not duck.is_string([1, 2, 3])