Ejemplo n.º 1
0
    def test_collimated_source(self):

        #
        #
        #
        a = SourceGridCartesian.initialize_collimated_source(
            real_space=[1., 0.0, 1.0], real_space_points=[100, 1, 100])
        print(a.info())
        beam_shadow3 = Beam3.initialize_from_shadow4_beam(a.get_beam())

        beam = a.get_beam()

        if DO_PLOT:

            from srxraylib.plot.gol import plot_scatter, set_qt
            set_qt()
            plot_scatter(beam.get_column(1), beam.get_column(3))
            import Shadow
            Shadow.ShadowTools.plotxy(beam_shadow3, 1, 3)

        print(beam.info())
Ejemplo n.º 2
0
            write_generic_h5_surface(self.Z_INTERPOLATED.T,
                                     self.y_interpolated,
                                     self.x_interpolated,
                                     filename=filename)
        else:
            write_generic_h5_surface(self.Z_INTERPOLATED,
                                     self.x_interpolated,
                                     self.y_interpolated,
                                     filename=filename)


if __name__ == "__main__":
    from srxraylib.plot.gol import plot_image, set_qt, plot
    import os

    set_qt()

    # o1 = FEA_File.process_file("s4.txt", n_axis_0=301, n_axis_1=51,
    #              filename_out="/home/manuel/Oasys/s4.h5", invert_axes_names=True,
    #              detrend=True, reset_height_method=1, do_plot=False)

    # o1 = FEA_File.process_file("73water_side_cooled_notches_best_LH.txt", n_axis_0=1001, n_axis_1=101,
    #              filename_out="/home/manuel/Oasys/water_side_cooled_notches_best_LH.h5", invert_axes_names=True,
    #              detrend=True, reset_height_method=2,
    #              replicate_raw_data_flag=3,do_plot=False)

    # o1 = FEA_File.process_file("73water_side_cooled_notches_best_LV.txt", n_axis_0=1001, n_axis_1=101,
    #              filename_out="/home/manuel/Oasys/water_side_cooled_notches_best_LV.h5", invert_axes_names=True,
    #              detrend=False, reset_height_method=0,
    #              replicate_raw_data_flag=3,do_plot=False)
Ejemplo n.º 3
0
def plot_ticket_plotxy(tkt,
                       col_h=1,
                       col_v=3,
                       title="",
                       xtitle="",
                       ytitle="",
                       filename="",
                       hfactor=1e4,
                       vfactor=1e4):
    import matplotlib.pylab as plt
    from srxraylib.plot.gol import set_qt

    set_qt()
    cmap = plt.cm.PuBu  # plt.cm.jet # Greys #cm.coolwarm

    fx = 11
    fy = 11
    figure = plt.figure(figsize=(fx, fy))

    left, width = 0.13, 0.61
    bottom, height = 0.09, 0.61
    bottom_h = left_h = left + width + 0.02
    rect_scatter = [left, bottom, width, height]
    rect_histx = [left, bottom_h, width, 0.2]
    rect_histy = [left_h, bottom, 0.2, height]

    #
    # main plot
    #
    axScatter = figure.add_axes(rect_scatter)

    axScatter.set_xlabel(xtitle, fontsize=20)
    axScatter.set_ylabel(ytitle, fontsize=20)

    axScatter.axis(xmin=hfactor * tkt["xrange"][0],
                   xmax=hfactor * tkt["xrange"][1])
    axScatter.axis(ymin=vfactor * tkt["yrange"][0],
                   ymax=vfactor * tkt["yrange"][1])

    # axScatter.set_aspect(1.0)

    axScatter.pcolormesh(hfactor * tkt["bin_h_edges"],
                         vfactor * tkt["bin_v_edges"],
                         tkt["histogram"].T,
                         cmap=cmap)

    axScatter.tick_params(labelsize=24)

    # histograms
    #
    axHistx = figure.add_axes(rect_histx, sharex=axScatter)
    axHisty = figure.add_axes(rect_histy, sharey=axScatter)

    tmp_h_b = []
    tmp_h_h = []
    for s, t, v in zip(hfactor * tkt["bin_h_left"],
                       hfactor * tkt["bin_h_right"], tkt["histogram_h"]):
        tmp_h_b.append(s)
        tmp_h_h.append(v)
        tmp_h_b.append(t)
        tmp_h_h.append(v)
        tmp_v_b = []
        tmp_v_h = []
    for s, t, v in zip(vfactor * tkt["bin_v_left"],
                       vfactor * tkt["bin_v_right"], tkt["histogram_v"]):
        tmp_v_b.append(s)
        tmp_v_h.append(v)
        tmp_v_b.append(t)
        tmp_v_h.append(v)

    axHistx.plot(tmp_h_b, tmp_h_h)
    axHisty.plot(tmp_v_h, tmp_v_b)

    # supress ordinates labels ans ticks
    axHistx.get_yaxis().set_visible(False)
    axHisty.get_xaxis().set_visible(False)

    # supress abscissas labels (keep ticks)
    for tl in axHistx.get_xticklabels():
        tl.set_visible(False)
    for tl in axHisty.get_yticklabels():
        tl.set_visible(False)

    if title != None:
        axHistx.set_title(title, fontsize=20)

    if filename != "":
        plt.savefig(filename)
        print("File written to disk: %s" % filename)

    plt.show()
    return tkt