Пример #1
0
def eem(multi_xas, name):
    start_time = time.time()

    # matplotlib.rcParams['figure.figsize'] = (14, 10)

    name = name.upper()
    if name == "SDD1":
        intensity = multi_xas.sdd1
        # intensity = np.array(intensity)
    elif name == "SDD2":
        intensity = multi_xas.sdd2
        # intensity = np.array(intensity)
    elif name == "SDD3":
        intensity = multi_xas.sdd3
        # intensity = np.array(intensity)
    elif name == "SDD4":
        intensity = multi_xas.sdd4
        # intensity = np.array(intensity)
    else:
        return "Invalid name for the intensity of EEM"

    energy_array = np.array(multi_xas.energy)
    num_of_points = len(energy_array)
    num_of_emission_bins = len(intensity[0])

    bin_num_for_x = np.zeros(shape=(num_of_points, num_of_emission_bins))
    for i in range(num_of_points):
        bin_num_for_x[i].fill(energy_array[i])

    bin_num_for_y = np.zeros(shape=(num_of_points, num_of_emission_bins))
    bin_num_for_y[0:] = np.arange(10, (num_of_emission_bins + 1) * 10, 10)

    v_max = max(intensity[0])
    for i in range(1, num_of_points):
        temp_max = max(intensity[i])
        if temp_max > v_max:
            v_max = temp_max
    # print ("v_max: ", v_max)

    intensity = np.array(intensity)
    plotview = NXPlotView()
    plotview.figure.clf()
    ax = plotview.figure.gca()
    ax.axes.get_xaxis().set_visible(True)
    ax.axes.get_yaxis().set_visible(True)
    # print("--- %s seconds ---" % (time.time() - start_time))
    ax.scatter(bin_num_for_x,
               bin_num_for_y,
               c=intensity,
               s=7,
               linewidths=0,
               vmax=v_max,
               vmin=0)
    print("--- %s seconds ---" % (time.time() - start_time))
    ax.set_xlabel('Incident Energy (eV)')
    ax.set_ylabel('Emission Energy (eV)')
    ax.set_title("Excitation Emission Matrix")
    plotview.grid()
    plotview.draw()
    print("--- %s seconds ---" % (time.time() - start_time))
Пример #2
0
    def summary_plot(self, name):
        start_time = time.time()
        # matplotlib.rcParams['figure.figsize'] = (13, 10)

        # select intensity
        name = name.upper()
        if name == "TEY":
            intensity = self.tey
        elif name == "I0" or name == "IO":
            intensity = self.i0
        elif name == "DIODE" or name == "PD1":
            intensity = self.diode
        elif name == "PFY_SDD1":
            intensity = self.pfy_sdd1
        elif name == "PFY_SDD2":
            intensity = self.pfy_sdd2
        elif name == "PFY_SDD3":
            intensity = self.pfy_sdd3
        elif name == "PFY_SDD4":
            intensity = self.pfy_sdd4
        else:
            return "Invalid name for the intensity of summary plot"

        total_cscan_num = len(self.energy)
        # print (total_cscan_num)

        # show the plot in Nexpy, similar to figure.show()
        plotview = NXPlotView()

        # setup the size of figure and pop-up window
        plotview.setMinimumHeight(200)
        if total_cscan_num > 10:
            ratio = total_cscan_num / 10
        else:
            ratio = 1
        plotview.resize(700, 280 * ratio)
        plotview.figure.clf()

        # setup axis
        ax = plotview.figure.gca()
        ax.axes.get_xaxis().set_visible(True)
        ax.axes.get_yaxis().set_visible(True)

        print("--- %s seconds ---" % (time.time() - start_time))

        energy_tuple = np.array(self.energy[0][:])
        intensity_tuple = np.array(intensity[0][:])
        scan_num_tuple = np.zeros(len(self.energy[0]))
        scan_num_tuple.fill(1)

        # prepare data as tuples for x, y, and color of scatter plot
        for i in range(1, total_cscan_num):
            scan_num_list = np.zeros(len(self.energy[i]))
            scan_num_list.fill(i + 1)
            scan_num_tuple = np.concatenate([scan_num_tuple, scan_num_list])
            energy_tuple = np.concatenate(
                [energy_tuple, np.array(self.energy[i][:])])
            intensity_tuple = np.concatenate(
                [intensity_tuple, np.array(intensity[i][:])])
            # comment out the old way to generate scatter plot
            #plt.scatter(self.energy[i][:], scan_num_list, c=intensity[i][:], s=140, linewidths=0, marker='s')

        # print("--- %s seconds ---" % (time.time() - start_time))
        # main function call to generate color scatter plot
        ax.scatter(energy_tuple,
                   scan_num_tuple,
                   c=intensity_tuple,
                   s=140,
                   linewidths=0,
                   marker='s')
        # this locator puts ticks at regular intervals
        loc = plticker.MultipleLocator(base=1.0)
        # set regular ticks interval
        ax.yaxis.set_major_locator(loc)
        # set the limitation of y axis
        ax.set_ylim(ymin=0, ymax=total_cscan_num + 1)
        # manipulate the ytick labels
        t = np.arange(len(self.selected_scan_entry)) + 1.0
        ax.set_yticks(t)
        ax.set_yticklabels(self.selected_scan_entry)
        # add title of the figure
        ax.set_title("Summary Plot (Intensity: %s)" % (name))
        # add labels for x and y axis
        ax.set_xlabel('Incident Energy(eV)')
        ax.set_ylabel('Scan Entry')
        # set limit of y axis
        print("selected_scan_entry: ", self.selected_scan_entry)

        plotview.grid(True)
        plotview.draw()
        print("--- %s seconds ---" % (time.time() - start_time))