예제 #1
0
    def find_ellipticity(self, color_index = 0, new_figure = False, verbose = False):

        if verbose:
            print("Find ellipticity")
            print("  x_min", self.e_x_i[0], self.mess.s_axis[2][self.e_x_i[0]])
            print("  x_max", self.e_x_i[1], self.mess.s_axis[2][self.e_x_i[1]])
            print("  y_min", self.e_y_i[0], self.mess.s_axis[0][self.e_y_i[0]])
            print("  y_max", self.e_y_i[1], self.mess.s_axis[0][self.e_y_i[1]])

        data = self.mess.s[self.dl_y_i[0]:self.dl_y_i[1], self.dl_x_i[0]:self.dl_x_i[1]]
        x_axis = self.mess.s_axis[2][self.dl_x_i[0]:self.dl_x_i[1]]
        y_axis = self.mess.s_axis[0][self.dl_y_i[0]:self.dl_y_i[1]]

        ma, mi = self.mess.find_z(x_range = [x_axis[0], x_axis[-1]], y_range = [y_axis[0], y_axis[-1]])
        
        V = PL.make_contours_2d(data, zlimit = -1, contours = 14)
        
        if new_figure:
            fig = plt.figure()
            ax1 = fig.add_subplot(111, aspect = "equal")
            cntr = ax1.contour(x_axis, y_axis, data, V, colors = "b")  
            ax1.set_title(self.objectname)
        else:
            fig = plt.figure(1000)
            ax1 = fig.add_subplot(111, aspect = "equal")
            cntr = ax1.contour(x_axis, y_axis, data, V, colors = self.color_array[color_index % len(self.color_array)])  

        self.cf_ble = self.find_peak_center_helper(cntr, mi, ax1)
        X, Y = self.find_ellipticity_helper(cntr, mi, ax1)
        self.e_dia_ble = numpy.max(X) - numpy.min(X)
        self.e_adia_ble = numpy.max(Y) - numpy.min(Y)
        self.e_ellipticity_ble = (self.e_dia_ble**2 - self.e_adia_ble**2) / (self.e_dia_ble**2 + self.e_adia_ble**2) 

        self.cf_esa = self.find_peak_center_helper(cntr, ma, ax1)
        X, Y = self.find_ellipticity_helper(cntr, ma, ax1)
        self.e_dia_esa = numpy.max(X) - numpy.min(X)
        self.e_adia_esa = numpy.max(Y) - numpy.min(Y)
        self.e_ellipticity_esa = (self.e_dia_esa**2 - self.e_adia_esa**2) / (self.e_dia_esa**2 + self.e_adia_esa**2) 
        
        plt.show()
예제 #2
0
def plot_lineshape_overlap(c_array, ax, index = 1, flag_CLS = False, flag_median = False):
    """
    Specialized method to plot the results from the calculation of the tilt.
    
    c_array has two Lineshape objects.
    
    """
    
    
    ax.plot([1500, 2500], [1500, 2500], c = "k")
    
    for i in range(2):
        data = c_array[i].mess.s[c_array[i].plot_y_i[0]:c_array[i].plot_y_i[1], c_array[i].plot_x_i[0]:c_array[i].plot_x_i[1]]
        x_axis = c_array[i].mess.s_axis[2][c_array[i].plot_x_i[0]:c_array[i].plot_x_i[1]]
        y_axis = c_array[i].mess.s_axis[0][c_array[i].plot_y_i[0]:c_array[i].plot_y_i[1]]
        
        V = PL.make_contours_2d(data, zlimit = -1, contours = 14)
        
        ax.contour(x_axis, y_axis, data, V, colors = c_array[i].color_overlap_array[i])
        
    markersize = 8
    linewidth = 3
    
    if flag_CLS:
        
        # plot the minima and maxima of the double lorentzian fits
#        for i in range(2):
#            
           # y = c_array[i].mess.s_axis[0][c_array[i].dl_y_i[0]:c_array[i].dl_y_i[1]]
#            
#            x = c_array[i].dl_ble
#            ax.plot(x, y, ".", c = c_array[i].color_overlap_array[i], markersize = markersize)

#            x = c_array[i].dl_esa
#            ax.plot(x, y, ".", c = c_array[i].color_overlap_array[i], markersize = markersize)
            

        # plot the linear fits of the minima and maxima
        for i in range(2):

            y = [c_array[i].mess.s_axis[0][c_array[i].dl_y_i[0] + c_array[i].l_i[0]], c_array[i].mess.s_axis[0][c_array[i].dl_y_i[0] + c_array[i].l_i[1]]] 

            x = [(y[0] - c_array[i].l_A_ble[0])/c_array[i].l_A_ble[1], (y[1] - c_array[i].l_A_ble[0])/c_array[i].l_A_ble[1]]
            ax.plot(x, y, "-", c = c_array[i].color_overlap_array[i], linewidth = linewidth)
            
#            x = [(y[0] - c_array[i].l_A_esa[0])/c_array[i].l_A_esa[1], (y[1] - c_array[i].l_A_esa[0])/c_array[i].l_A_esa[1]]
#            ax.plot(x, y, "-", c = c_array[i].color_overlap_array[i], linewidth = linewidth)

         
#    if flag_median:
#        
#        for i in range(2): 
#        
#            x_min_i, x_max_i, y_min_i, y_max_i = find_indices(c_array[i].mess.s_axis[2], c_array[i].mess.s_axis[0], c_array[i].sl_x, c_array[i].sl_y)
#            
#            x = c_array[i].mess.s_axis[2][x_min_i:x_max_i]                       
#            y = c_array[i].sl_A[:,1]
#            ax1.plot(x, y, ":", c = c_array[i].color_overlap_array[i])
#

    # plot properties
    ax.set_title("blue:" + c_array[0].objectname + "\nred: " + c_array[1].objectname)