예제 #1
0
 def _plot_group_flux(self, e_g, phi_g):
     fig = plt.figure(figsize=(12, 8))
     plt.loglog(*stair_step(e_g, phi_g), figure=fig)
     plt.title("Flux vs Energy in")
     plt.xlabel('E [MeV]')
     plt.ylabel('Flux [N/cm$^2\cdot$s]')
     plt.savefig("flux")
     plt.close()
예제 #2
0
파일: test_bins.py 프로젝트: rwcarlsen/pyne
def test_stair_step():
    x = [0.1, 1.0, 10.0, 100.0]
    y = [2.0, 3.0, 4.0]

    xobs, yobs = bins.stair_step(x, y)
    xexp = [0.1, 1.0, 1.0, 10.0, 10.0, 100.0]
    yexp = [2.0, 2.0, 3.0, 3.0,  4.0,  4.0]

    assert_equal(len(xobs), len(yobs))
    assert_equal(len(yobs), 2 * len(y))
    assert_array_almost_equal(xobs, xexp)
    assert_array_almost_equal(yobs, yexp)
예제 #3
0
    def _plot_group_flux(self, e_g, phi_g):
        """Plot the group flux output by OpenMC and save plot to file.

        Parameters
        ----------
        e_g : array
            Energy bins
        phi_g : array
            Flux values
        """
        fig = plt.figure(figsize=(12, 8))
        plt.loglog(*stair_step(e_g, phi_g), figure=fig)
        plt.title("Flux vs Energy in")
        plt.xlabel('E [MeV]')
        plt.ylabel('Flux [N/cm$^2\cdot$s]')
        plt.savefig("flux")
        plt.close()
예제 #4
0
def stairstep_plot(energy, data, data_name):
    # Munge the data into a plotable form
    x, y = stair_step(energy, data)

    # Create a plot data obect and give it this data
    pd = ArrayPlotData()
    pd.set_data("index", x)
    pd.set_data("value", y)

    # Create the plot
    plot = Plot(pd)
    plot.plot(("index", "value"),
              type="line",
              marker="circle",
              index_sort="ascending",
              color="red",
              marker_size=3,
              bgcolor="white")

    # Tweak some of the plot properties
    plot.title = data_name
    plot.line_width = 0.5
    plot.padding = 100

    plot.x_axis.title = "Energy [MeV]"
    plot.x_axis.title_font = "Roman 16"
    plot.x_axis.tick_label_font = "Roman 12"
        
    plot.y_axis.title = "Data"
    plot.y_axis.title_font = "Roman 16"
    plot.y_axis.tick_label_font = "Roman 12"

    plot.index_scale = 'log'
    plot.value_scale = 'log'

    # Attach some tools to the plot
    plot.tools.append(PanTool(plot))
    zoom = ZoomTool(component=plot, tool_mode="box", always_on=False)
    plot.overlays.append(zoom)
   
    return plot