Beispiel #1
0
def plot_time_param(
    time_list, param_list, x_label=None, y_label=None, x_rotation=False
):
    """
    Plots a parameter against time.

    `Quantity` type is supported.

    Parameters
    ----------
    time_list: Time
        list of times
    param_list : ndarray or list
        list of parameter values on the y axis
    x_label : str
        X axis label
    y_label : str
        Y axis label
    x_rotation : bool
        True rotates the X axis labels by 90 deg (useful for ISOT dates)

    """

    quantity_support()
    time_support(format="isot")

    fig1, ax1 = plt.subplots(figsize=(12, 8), dpi=100)

    # default with grid
    format_axis_with_grid(ax1, x_label, y_label, x_rotation)

    # plot the data and show the plot
    ax1.plot(time_list, param_list)

    plt.show()
Beispiel #2
0
def plot_runtimes(cases, title, logscale_plot=True):
    """Plots the runtimes."""
    quantity_support()
    time_support()

    fig, ax = plt.subplots()

    # ax.grid()
    # ax.xaxis.set_major_formatter(FormatStrFormatter("% 3.3f"))
    # ax.yaxis.set_major_formatter(FormatStrFormatter("% 3.3f"))
    plt.title(f"Runtime Analysis\n({title})")
    ax.set_ylabel("Runtime (s)")

    if logscale_plot:
        ax.set_yscale("log")

    fig.set_size_inches(8, 6)

    # generate data lists
    names = [case for case in cases]
Beispiel #3
0
def plot_pos_diff(cases, title, logscale_plot=True):
    """Plots the pos difference."""
    quantity_support()
    time_support()

    fig, ax = plt.subplots()

    ax.grid()
    # ax.xaxis.set_major_formatter(FormatStrFormatter("% 3.3f"))
    # ax.yaxis.set_major_formatter(FormatStrFormatter("% 3.3f"))
    plt.title(f"Position Difference Variation\n({title})")
    ax.set_xlabel("Time (days)")
    ax.set_ylabel("Pos Diff (m)")

    if logscale_plot:
        ax.set_yscale("log")

    fig.set_size_inches(8, 6)

    for case in cases:
        if logscale_plot:
            # Make sure everything is positive for plotting
            ax.plot(
                cases[case]["time_list"].to(u.day),
                np.abs(cases[case]["pos_diff_list"]),
                label=case,
            )
        else:
            ax.plot(
                cases[case]["time_list"].to(u.day),
                cases[case]["pos_diff_list"],
                label=case,
            )

    ax.legend()
    plt.show()
Beispiel #4
0
def plot_energy_diff(cases, title, logscale_plot=True):
    """Plots the energy difference."""
    quantity_support()
    time_support()

    fig, ax = plt.subplots()

    ax.grid()
    # ax.xaxis.set_major_formatter(FormatStrFormatter("% 3.3f"))
    # ax.yaxis.set_major_formatter(FormatStrFormatter("% 3.3f"))
    plt.title(f"Specific Energy Evolution wrt. Initial State\n({title})")
    ax.set_xlabel("Time (days)")
    ax.set_ylabel("Specific Energy Diff (m^2/s^2)")

    if logscale_plot:
        ax.set_yscale("log")

    fig.set_size_inches(8, 6)

    for case in cases:
        if logscale_plot:
            # Make sure everything is positive for plotting
            ax.plot(
                cases[case]["time_list"].to(u.day),
                np.abs(cases[case]["energy_diff_list"]),
                label=case,
            )
        else:
            ax.plot(
                cases[case]["time_list"].to(u.day),
                cases[case]["energy_diff_list"],
                label=case,
            )

    plt.legend()
    plt.show()
Beispiel #5
0
from utilipy.imports import conf
from utilipy.utils import make_help_function

##############################################################################
# IMPORTS

if float(astropy.__version__[:3]) > 4.1:
    from astropy.modeling import custom_model

    __all__ += ("custom_model", )

##############################################################################
# Cleaning Up

# astropy changes to matplotlib
quantity_support()
time_support()

##############################################################################
# Printing Information

astropy_imports_help = make_help_function("astropy",
                                          __doc__,
                                          look_for="Routine Listings")

if conf.verbose_imports:
    astropy_imports_help()

##############################################################################
# END