fc = FigureCollection(pagesize=(3, 5.5),
                          figure_style="science",
                          col=1,
                          row=9)
    # fc.fc_param["figure.lpad"] = 0.02
    # fc.fc_param["figure.rpad"] = 0.0
    fc.fc_param["figure.tpad"] = 0.05
    fc.fc_param["figure.bpad"] = 0.05
    # fc.fc_param["annotation.location"] = (0,0)
    fig1, num1 = fc.add_figure(loc=(0, 0, 1, 3), label=True)
    fig1.add_file_figure("../img/scheme-EDL.pdf")
    fig2, num1 = fc.add_figure(loc=(0, 3, 1, 3), label=True)
    fig2.set_plot_func(plot_ph_dep, MD=False)
    fig3, num2 = fc.add_figure(loc=(0, 6, 1, 3), label=True)
    fig3.set_plot_func(plot_ph_dep, MD=True)
    org.figure(
        fc.save_all("../img/2d-ph-dependency+MD_1.pdf", outline=False),
        label="fig:res-EDL",
        caption=
        ("(a) Scheme of the interface between the 2D material "
         "and the aqueous phase. "
         r"(b) $(\Delta\cos\theta)^{\mathrm{EDL}}$ "
         "as a function of "
         r"$\sigma_{\mathrm{2D}}$ with varied solute concentrations. "
         r"The concentration $c_{0}$ varies from "
         r"$10^{0}$ to $10^{-7}$ mol$\cdot\mathrm{L}^{-1}$ "
         r"(c) Overall change of contact angle $(\Delta \cos \theta)^{\mathrm{Orien+EDL}}$ "
         "combining the orientation and EDL effects, "
         "with varied solute concentrations as in (b)."),
        attributes=[("latex", ":width 0.5\linewidth")])
# ax2.set_xlim(ax1.get_xlim())
# ax2.set_xticks(c_atom_to_sigma(ax2_ticks)/10**13)
# ax2.set_xticklabels(list(map(str, ax2_ticks)))
# # ax2.plot(charge_per_atom, potential_tot, alpha=0)
# ax2.set_xlabel("Unit charge per atom", labelpad=10)


# # print(ax1.get_ylim())
# # print(ax1.get_yticks())
# ax3.set_yticks(ax1.get_yticks())
# ax3.set_ylim(ax1.get_ylim())
# ax3_yticks = ax1.get_yticks()/A_c/const.N_A*10**6
# ax3.set_yticklabels(list(map(lambda a: "%.1f"%a, ax3_yticks)))
# # ax3.plot(sigma/10**13, potential_tot/A_c/const.N_A*1000, alpha=0.0)
# ax3.set_ylabel(r"$\Delta\gamma_{\mathrm{WG}}$ [mJ$\cdot$m$^{-2}$]", labelpad=-2)


# org.figure(plt.savefig("../img/e-vdw.png"))


if __name__ == "__main__":
    matplotlib.style.use("science")

    fig = plt.figure(figsize=(3, 3))
    plot_Phi_charge(fig, error=True)
    org.figure(plt.savefig("../img/e-vdw-2.pdf"))

    fig = plt.figure(figsize=(3, 3))
    plot_fitting(fig)
    org.figure(plt.savefig("../img/e-Phi-fitting.pdf"))
Esempio n. 3
0
    def org(self):
        '''Print an org-represention of the plate and data.

        '''
        from pycse.orgmode import table, figure, headline, print_redirect, link
        import datetime
        import json
        import time

        ts = time.time()
        st = datetime.datetime.fromtimestamp(ts).strftime('[%Y-%m-%d %a %H:%M:%S]')

        CWD = os.getcwd()
        os.chdir(os.path.join(self.base,
                              self.directory))

        try:
            import matplotlib
            matplotlib.use('TkAgg')
            A, B = self.metadata['A'], self.metadata['B']


            print(f'#+TITLE: {A}-{B}')
            print(f'#+CREATED: {st}')
            print('#+STARTUP: showall')
            print()
            print('Generated report. Do not edit. Changes may be lost.\n')
            headline('Summary',
                     tags=[A, B],
                     body=str(self))

            link('file+sys', f'./primary_data/{A}col{B}rowdata.xls')

            link('file+sys', './images', 'Image directory')

            link('file+sys', './auxillary_data', 'auxillary_data')

            print()
            headline('Hydrogen data')
            headline('Hydrogen production plots', level=2)

            plt.figure()

            self.data['mmolH'].plot_mmolH_grid_window()
            plt.tight_layout()
            figure('espyranto/kinetics-grid.png',
                   name='fig-kinetics-grid',
                   attributes=[['org', ':width 600']],
                   caption=f'Hydrogen umolH in each well for {A}-{B}.')
            plt.clf()
            print()

            headline('Max production', level=2)

            ncols, nrows = self.ncols, len(self.data['mmolH'].mmolH) // self.ncols
            maxh = np.max(self.data['mmolH'].mmolH, axis=1).reshape(nrows, ncols)

            data = np.round(maxh, 2)
            # Add row and column labels
            col_labels = self.A.reshape(nrows, ncols)[0][None, :]
            row_labels = np.concatenate(([['']],
                                         self.B.reshape(nrows, ncols)[:, 0][:, None]))
            data = np.concatenate((col_labels, data))
            data = np.concatenate((row_labels, data), axis=1)
            data = list(data)
            data.insert(1, None)
            data[0][0] = f'{B}\{A}'

            table(data, name='tab-maxh', caption='Maxh µmol H_{2} produced.')
            print()

            self.data['mmolH'].plot_mmolH_max();
            plt.tight_layout()
            figure('espyranto/maxh.png',
                   name='fig-maxh',
                   attributes=[['org', ':width 600']],
                   caption=f'Maximum hydrogen produced for {A}-{B}.')
            plt.clf()
            print()

            tot_conc = (self.A + self.B)

            # The nself.where deals with the case where A = B = 0.0
            x_A = self.A / np.where(tot_conc > 0, tot_conc, 1)

            plt.figure()
            plt.scatter(x_A, np.max(self.data['mmolH'].mmolH, axis=1),
                        tot_conc * 20)
            plt.xlabel(f'$x_{{{A}}}$');
            plt.ylabel('$\mu molH$');
            print()
            figure('espyranto/maxh-scatter.png',
                   name='fig-maxh-scatter',
                   attributes=[['org', ':width 600']],
                   caption=f'Scatter plot for maximum hydrogen produced for {A}-{B}.')
            print()

            headline('Max rate', level=2)

            # Heatmap of max rates
            print()
            self.data['mmolH'].plot_mmolH_max_derivative_window()
            figure('espyranto/maxrate.png',
                   name='fig-maxrate',
                   attributes=[['org', ':width 600']],
                   caption=f'Maximum rate (window) of hydrogen produced for {A}-{B}.')


            # Scatter plot
            print()
            mmolH = self.data['mmolH']
            t = np.arange(0, len(mmolH[0])) * mmolH.timestep / 3600
            rate_data = []
            for row in self.data['mmolH'].mmolH:
                ys = mmolH.smooth_window(row)
                dydx = np.gradient(ys, t, edge_order=2)
                rate_data += [np.max(dydx)]


            # Scatter plot
            plt.figure()
            plt.scatter(x_A, rate_data, tot_conc * 20)
            plt.xlabel(f'$x_{{{A}}}$');
            plt.ylabel('$\mu molH/hr$');
            print()
            figure('espyranto/maxrate-scatter.png',
                   name='fig-maxrate-scatter',
                   attributes=[['org', ':width 600']],
                   caption=f'Scatter plot for maximum rate of hydrogen production for {A}-{B}.')
            print()


            # For making a table
            rate_data = np.round(rate_data, 2)
            rate_data = rate_data.reshape((nrows, ncols))
            rate_data = np.concatenate((col_labels, rate_data))
            rate_data = np.concatenate((row_labels, rate_data), axis=1)
            rate_data = list(rate_data)
            rate_data.insert(1, None)
            rate_data[0][0] = f'{B}\{A}'

            table(rate_data, name='tab-maxrate', caption='Max rate µmol/hr H_{2} produced.')
            print()

            headline('Metadata')
            print()
            print(f'''#+name: metadata
#+BEGIN_SRC json
{json.dumps(self.metadata, sort_keys=True, indent=2)}
#+END_SRC

''')

        finally:
            os.chdir(CWD)
            plt.close('all')
                "{:.3f}\n".format(f_esem),
                r"$\sigma_{0}$",
                "={:.1f}".format(sigma_i_esem * 10),
                r"$\times 10^{12}$",
                r" $e\cdot$cm$^{-2}$",
            )))
    ax.set_xlabel(r"$\sigma_{\mathrm{2D}}$ ($10^{13}$ $e\cdot$cm$^{-2}$)")
    ax.set_ylabel(r"$\Delta\cos\theta$")
    ax.legend(loc=0, frameon=True)
    ax.set_xlim(-2, 2)
    ax.set_ylim(-0.05, 0.5)
    fig.tight_layout()


matplotlib.style.use("science")
fig = plt.figure(figsize=(4.0, 3.0))

if __name__ == "__main__":
    plot_fitting_f(fig)
    org.figure(plt.savefig("../img/plot-fitting.pdf"),
               attributes=[("latex", ":width 0.95\linewidth")],
               label="fig:f-nc-exp",
               caption=("Theoretical and fitted experimental data of "
                        r"$\Delta\cos\theta$ "
                        "as a function of "
                        r"$\sigma_{\mathrm{2D}}$. "
                        "The electrowetting data are extracted from Ref. "
                        "[[cite:hong_mechanism_2016]]; "
                        "the ESEM data are extracted from Ref. "
                        "[[cite:ashraf_doping-induced_2016]]. "))
Esempio n. 5
0
def test_fig5():
    figure("pycse/tests/test_orgmode.png", caption="test",
           name='fig', attributes=[('org', ':width 300')])
    assert sys.stdout.getvalue() == ('#+attr_org: :width 300\n'
                                     '#+name: fig\n#+caption: test\n'
                                     '[[file:pycse/tests/test_orgmode.png]]\n')
Esempio n. 6
0
                    d_sys[:, 1],
                    label=r"%d$\times10^{-3}$ $e$/atom" % (c))
        ax.set_ylabel(r"$\rho_{\mathrm{w}}$ (kg$\cdot$m$^{-3}$)")
        ax.set_xlabel(r"$z$ (nm)")
        ax.set_xlim(0, 1.5)
        ax.legend(loc=0)
    elif what is "charge":
        for index, c in enumerate(charge_per_atom):
            c_sys = numpy.genfromtxt(f_charge_base.format(name[index]),
                                     delimiter=(12, 17),
                                     skip_header=19)
            ax.plot(c_sys[:, 0] - z_gr,
                    c_sys[:, 1],
                    label=r"%d$\times10^{-3}$ $e$/atom" % (c))
        ax.set_ylabel(r"$\delta_{\mathrm{w}}$ ($e\cdot$nm$^{-3}$)")
        ax.set_xlabel(r"$z$ (nm)")
        ax.set_xlim(0, 1.5)
        ax.legend(loc=0)

    fig.tight_layout(pad=0)


if __name__ == "__main__":
    fig = plt.figure()
    plot_den(fig, what="mass")
    org.figure(plt.savefig("img/density_m.pdf"))
    plt.cla()
    fig = plt.figure()
    plot_den(fig, what="charge")
    org.figure(plt.savefig("img/density_c.pdf"))
Esempio n. 7
0
def test_fig4():
    figure("pycse/tests/test_orgmode.png", caption="test", name='fig')
    assert sys.stdout.getvalue() == ('#+name: fig\n#+caption: test\n'
                                     '[[file:pycse/tests/test_orgmode.png]]\n')
Esempio n. 8
0
def test_fig3():
    figure("pycse/tests/test_orgmode.png", caption="test")
    result = '#+caption: test\n[[file:pycse/tests/test_orgmode.png]]\n'
    assert sys.stdout.getvalue() == result
Esempio n. 9
0
def test_fig2():
    figure("pycse/tests/test_orgmode.png")
    assert sys.stdout.getvalue() == '[[file:pycse/tests/test_orgmode.png]]\n'
Esempio n. 10
0
def test_fig():
    figure("test")
    assert sys.stdout.getvalue() == '[[file:test]]\n'
    elif what is "charge":
        for index, c in enumerate(charge_per_atom):
            c_sys = numpy.genfromtxt(f_charge_base.format(name[index]),
                                     delimiter=(12, 17),
                                     skip_header=19)
            zz = numpy.linspace(c_sys[:, 0].min(), c_sys[:, 0].max(), 50000)
            f_y = interp1d(c_sys[:, 0], c_sys[:, 1], kind="cubic")
            yy = f_y(zz)
            # ax.plot(c_sys[:, 0] - z_gr, c_sys[:, 1],
            # label=r"%d$\times10^{-3}$ $e$/atom" % (c) )
            ax.plot(zz - z_gr, yy, label=r"%s $e$/atom" % (label_name[index]))
        ax.set_ylabel(r"$\delta_{\mathrm{L}}$ ($e\cdot$nm$^{-3}$)")
        ax.set_xlabel(r"$z$ (nm)")
        ax.set_xlim(0, 1)
        ax.legend(loc=0, title=r"$\sigma_{\mathrm{2D}}$")

    fig.tight_layout(pad=0.05)


if __name__ == "__main__":
    matplotlib.style.use("science")

    fig = plt.figure(figsize=(2.5, 2.5))
    plot_den(fig, what="mass")
    org.figure(plt.savefig("../img/density_m_small.pdf"))
    plt.cla()

    fig = plt.figure(figsize=(2.5, 2.5))
    plot_den(fig, what="charge")
    org.figure(plt.savefig("../img/density_c_small.pdf"))