示例#1
0
def plot_reaction_rate_burning_rate(df_rate):
    fig, ax = pplot.subplots(aspect=(4, 3), axwidth=4)
    c1 = pplot.scale_luminance('cerulean', 0.5)
    c2 = pplot.scale_luminance('red', 0.5)
    df_rate.sort_values(by="time", inplace=True)

    lns1 = ax.plot(df_rate["time"],
                   df_rate["vol_averaged_reaction_rate"],
                   color=c1,
                   label="Reaction rate")

    max_rate = df_rate["vol_averaged_reaction_rate"].max()
    ax.format(xlabel="Time (s)",
              ylabel="Volume-Averaged coke reaction rate (kg/m$^3$/s)",
              ycolor=c1,
              ylim=(-1, max_rate * 1.1))

    ax2 = ax.twinx()
    lns2 = ax2.plot(df_rate["time"],
                    df_rate["burning_fraction"] * 100,
                    color=c2,
                    linestyle="--",
                    label="Conversion")
    ax2.format(xlabel="Time (s)",
               ylabel="Conversion (%)",
               ycolor=c2,
               ylim=(-1, 100))

    lns = lns1 + lns2
    labs = [l.get_label() for l in lns]
    ax.legend(lns, labs, loc="upper right", fancybox=True)

    return ax, ax2, fig
示例#2
0
def plot_transverse_averages(transverse_data_folder, time):
    df_transverse = pd.read_csv(
        os.path.join(transverse_data_folder, f"{time}.csv"))
    fig, ax = plt.subplots()
    c1 = pplot.scale_luminance('cerulean', 0.5)
    c2 = pplot.scale_luminance('red', 0.5)
    ax.plot(df_transverse["x"], df_transverse["O2Conc"], color=c1)
    ax.set_xlabel("X (m)")
    ax.set_ylabel("Tranversely Averaged O$_2$ mole concentration (mol/m$^3$)",
                  color=c1)
    ax.tick_params(axis='y', colors=c1)

    ax2 = ax.twinx()
    ax2.plot(df_transverse["x"], df_transverse["T"], color=c2)
    ax2.set_ylabel("Tranversely Averaged Temperature (K)", color=c2)
    ax2.tick_params(axis='y', colors=c2)

    fig.tight_layout()
    return ax, ax2, fig
示例#3
0
# like `~matplotlib.axes.Axes.set_xticks` and
# `~matplotlib.axes.Axes.set_yticks`). See
# `~proplot.axes.CartesianAxes.format` and `~proplot.constructor.Locator` for
# details.
#
# To generate lists of tick locations, we recommend using ProPlot's
# `~proplot.utils.arange` function -- it’s basically an *endpoint-inclusive*
# version of `numpy.arange`, which is usually what you'll want in this
# context.

# %%
import proplot as plot
import numpy as np
state = np.random.RandomState(51423)
plot.rc.update(
    facecolor=plot.scale_luminance('powderblue', 1.15),
    linewidth=1, fontsize=10,
    color='dark blue', suptitlecolor='dark blue',
    titleloc='upper center', titlecolor='dark blue', titleborder=False,
)
fig, axs = plot.subplots(nrows=8, axwidth=5, aspect=(8, 1), share=0)
axs.format(suptitle='Tick locators demo')

# Step size for tick locations
axs[0].format(
    xlim=(0, 200), xminorlocator=10, xlocator=30,
    title='MultipleLocator'
)

# Specific list of locations
axs[1].format(
示例#4
0
def plot_O2_flux_reaction_rate(df_O2_flux_at_inlet,
                               df_rate,
                               pixelResolution,
                               sampling_rate=5,
                               ylim=(1e-9, 1e-4),
                               ls=13,
                               ts=11):
    MCoke = 12
    MO2 = 32
    df_O2_flux_at_inlet["diffusive_flux"] = np.array(
        df_O2_flux_at_inlet["O2_diffusive_Fluxs"])
    df_O2_flux_at_inlet["advective_flux"] = np.array(
        df_O2_flux_at_inlet["O2_adv_flux_by_deltaX"]) * pixelResolution
    df_O2_flux_at_inlet["total_flux"] = df_O2_flux_at_inlet[
        "diffusive_flux"] + df_O2_flux_at_inlet["advective_flux"]

    df_O2_flux_at_inlet["diffusion flux"] = df_O2_flux_at_inlet[
        "diffusive_flux"] / df_O2_flux_at_inlet["total_flux"]
    df_O2_flux_at_inlet["advection flux"] = df_O2_flux_at_inlet[
        "advective_flux"] / df_O2_flux_at_inlet["total_flux"]

    c1 = pplot.scale_luminance('cerulean', 0.5)
    c2 = pplot.scale_luminance('red', 0.5)

    fig, axs = pplot.subplots(ncols=1, nrows=2, aspect=(4, 3), \
        axwidth=4,hspace=(0),sharey=0,sharex=3)

    ax1 = axs[0]

    ax1.plot(df_O2_flux_at_inlet["time"],
             df_O2_flux_at_inlet["diffusive_flux"],
             color=c1,
             label="Diffusion Flux",
             linestyle="-.")
    ax1.plot(df_O2_flux_at_inlet["time"],
             df_O2_flux_at_inlet["advective_flux"],
             color=c1,
             label="Advection Flux",
             linestyle="--")
    ax1.plot(df_O2_flux_at_inlet["time"],
             df_O2_flux_at_inlet["total_flux"],
             color=c1,
             label="Total Flux",
             linestyle="-")
    ax1.format(xlabel="Time (s)",
               ylim=ylim,
               yformatter='sci',
               yscale='log',
               ylabel="O$_2$ flux at inlet (kg/s)",
               ycolor=c1)
    ax1.legend(loc="best", ncols=1, fancybox=True)
    ax2 = ax1.twinx()
    df_sampling = df_rate[df_rate.index % sampling_rate == 0]

    ax2.scatter(df_sampling["time"],
                df_sampling["total_reaction_rate"] / MCoke * MO2 *
                pixelResolution * pixelResolution,
                label="Total O$_2$ Reaction Rate",
                color=c2)
    ax2.format(xlabel="Time (s)",
               ylim=ylim,
               yformatter='sci',
               yscale='log',
               ylabel='O$_2$ reaction rate within domain (kg/s)',
               ycolor=c2)

    df_sampling = df_O2_flux_at_inlet[df_O2_flux_at_inlet.index %
                                      sampling_rate == 0]
    df_sampling.reset_index(drop=True, inplace=True)
    df_ratios = df_sampling[["diffusion flux", "advection flux"]]
    ax3 = axs[1]
    ax3.format(ylim=(0, 1.1))
    ax3.set_ylabel(ylabel="Percentage of different O$_2$ fluxes", labelpad=20)
    num = df_sampling.shape[0]
    maxTime = df_sampling["time"].iloc[-1]
    ax3.bar(df_sampling["time"],
            df_ratios,
            stacked=True,
            cycle='Blues',
            legend='ur',
            edgecolor='blue9',
            width=maxTime / (num * 1.2))

    axs = [ax1, ax2, ax3]
    for ax in axs:
        ax.tick_params(labelsize=ts)
        ax.yaxis.label.set_size(ls)
    ax3.xaxis.label.set_size(ls)
    # ax3.yaxis.label.set_labelpad(10)
    return ax1, ax2, fig
示例#5
0
import proplot as pplot  # there are some nice colormaps in the proplot package
import concurrent.futures
import argparse
import json
import math
import traceback
import tracemalloc

# mpl.rcParams['font.family'] = 'Helvetica', #default font family
mpl.rcParams['mathtext.fontset'] = 'cm'  #font for math
C_GREEN = fg('green')
C_RED = fg('red')
C_BLUE = fg('blue')
C_DEFAULT = attr('reset')

c1 = pplot.scale_luminance('cerulean', 0.5)
c2 = pplot.scale_luminance('red', 0.5)


def use_paper_style(mpl, fontsize=9):
    mpl.rcParams['axes.titlesize'] = fontsize
    mpl.rcParams['axes.labelsize'] = fontsize
    mpl.rcParams['xtick.labelsize'] = fontsize
    mpl.rcParams['ytick.labelsize'] = fontsize
    mpl.rcParams['legend.fontsize'] = fontsize
    mpl.rcParams['axes.titlesize'] = fontsize
    mpl.rcParams['axes.titlesize'] = fontsize


def read_postProcess_csv_data(postProcessDir, timeName):
    fileName = f"{timeName}.csv"
示例#6
0
文件: stats.py 项目: lukelbd/proplot
x = state.normal(size=(N, ))
y = state.normal(size=(N, ))
bins = pplt.arange(-3, 3, 0.25)

# Histogram with marginal distributions
fig, axs = pplt.subplots(ncols=2, refwidth=2.3)
axs.format(abc='A.',
           abcloc='l',
           titleabove=True,
           ylabel='y axis',
           suptitle='Histograms with marginal distributions')
colors = ('indigo9', 'red9')
titles = ('Group 1', 'Group 2')
for ax, which, color, title in zip(axs, 'lr', colors, titles):
    ax.hist2d(x,
              y,
              bins,
              vmin=0,
              vmax=10,
              levels=50,
              cmap=color,
              colorbar='b',
              colorbar_kw={'label': 'count'})
    color = pplt.scale_luminance(color, 1.5)  # histogram colors
    px = ax.panel(which, space=0)
    px.histh(y, bins, color=color, fill=True, ec='k')
    px.format(grid=False, xlocator=[], xreverse=(which == 'l'))
    px = ax.panel('t', space=0)
    px.hist(x, bins, color=color, fill=True, ec='k')
    px.format(grid=False, ylocator=[], title=title, titleloc='l')
示例#7
0
    yformatter='none',
)

# Shifted hue
N = 50
fmt = pplt.SimpleFormatter()
marker = 'o'
for shift in (0, -60, 60):
    x, y = state.rand(2, N)
    color = pplt.shift_hue('grass', shift)
    axs[0].scatter(x, y, marker=marker, c=color, legend='b', label=fmt(shift))

# Scaled luminance
for scale in (0.2, 1, 2):
    x, y = state.rand(2, N)
    color = pplt.scale_luminance('bright red', scale)
    axs[1].scatter(x, y, marker=marker, c=color, legend='b', label=fmt(scale))

# Scaled saturation
for scale in (0, 1, 3):
    x, y = state.rand(2, N)
    color = pplt.scale_saturation('ocean blue', scale)
    axs[2].scatter(x, y, marker=marker, c=color, legend='b', label=fmt(scale))

# %% [raw] raw_mimetype="text/restructuredtext"
# .. _ug_colors_cmaps:
#
# Colors from colormaps
# ---------------------
#
# If you want to draw an individual color from a colormap or a color cycle,