コード例 #1
0
ファイル: hydro_collision.py プロジェクト: Ingwar/amuse
def energy_evolution_plot(time, kinetic, potential, thermal, figname="energy_evolution.png"):
    native_plot.subplot(211)
    plot(time, kinetic, label='K')
    plot(time, potential, label='U')
    plot(time, thermal, label='Q')
    plot(time, kinetic + potential + thermal, label='E')
    xlabel('Time')
    ylabel('Energy')
    native_plot.legend(prop={'size':"x-small"}, loc=4)
    native_plot.subplot(212)
    plot(time, thermal, label='Q')
    native_plot.savefig(figname)
    native_plot.clf()
コード例 #2
0
def energy_evolution_plot(time, kinetic, potential, thermal, figname="energy_evolution.png"):
    native_plot.subplot(211)
    plot(time, kinetic, label='K')
    plot(time, potential, label='U')
    plot(time, thermal, label='Q')
    plot(time, kinetic + potential + thermal, label='E')
    xlabel('Time')
    ylabel('Energy')
    native_plot.legend(prop={'size':"x-small"}, loc=4)
    native_plot.subplot(212)
    plot(time, thermal, label='Q')
    native_plot.savefig(figname)
    native_plot.clf()
コード例 #3
0
ファイル: plot_with_units.py プロジェクト: amusecode/amuse
        )
import numpy as np

if __name__ == "__main__":

    # latex_support()

    x = np.pi/20.0 * (range(-10, 10) | units.m)
    y1 = units.MSun.new_quantity(np.sin(x.number))
    y2 = units.MSun.new_quantity(x.number)
    native_plot.subplot(2, 2, 1)
    plot(x, y2, label='model')
    scatter(x, y1, label='data')
    xlabel('x')
    ylabel('mass [$M_\odot$]')  # overrides auto unit!
    native_plot.legend(loc=2)

    x = range(50) | units.Myr
    y1 = quantities.new_quantity(
        np.sin(np.arange(0, 1.5, 0.03)), 1e50*units.erg)
    y2 = -(1e43 | units.J) - y1
    native_plot.subplot(2, 2, 2)
    plot(x, y1, label='$E_\mathrm{kin}$')
    plot(x, y2, label='$E_\mathrm{pot}$')
    xlabel('t')
    ylabel('E')
    native_plot.legend()

    x = range(7) | units.day
    y1 = [0, 4, 2, 3, 2, 5, 1]
    y2 = [3, 0, 2, 2, 3, 0, 4]
コード例 #4
0
import numpy as np


if __name__ == "__main__":

    # latex_support()

    x = np.pi / 20.0 * (list(range(-10, 10)) | units.m)
    y1 = units.MSun.new_quantity(np.sin(x.number))
    y2 = units.MSun.new_quantity(x.number)
    native_plot.subplot(2, 2, 1)
    plot(x, y2, label='model')
    scatter(x, y1, label='data')
    xlabel('x')
    ylabel('mass [$M_\odot$]')  # overrides auto unit!
    native_plot.legend(loc=2)

    x = list(range(50)) | units.Myr
    y1 = quantities.new_quantity(
        np.sin(np.arange(0, 1.5, 0.03)), 1e50 * units.erg)
    y2 = -(1e43 | units.J) - y1
    native_plot.subplot(2, 2, 2)
    plot(x, y1, label='$E_\mathrm{kin}$')
    plot(x, y2, label='$E_\mathrm{pot}$')
    xlabel('t')
    ylabel('E')
    native_plot.legend()

    x = list(range(7)) | units.day
    y1 = [0, 4, 2, 3, 2, 5, 1]
    y2 = [3, 0, 2, 2, 3, 0, 4]