Exemplo n.º 1
0
def uti_plot2d(ar2d,
               x_range,
               y_range,
               labels=('Horizontal Position [m]', 'Vertical Position [m]'),
               units=None):
    """Generate quad mesh plot from given "flattened" array

    :param array ar2d: data points, assuming: ar2d = [curve_1,curve_2,...], where curve_i can be:
                    curve_i = [[y1_i,y2_i,...],[x_min_i,x_max_i,nx_i]] or
                    curve_i = [[y1_i,y2_i,...],[x1_i,x2_i,...]] or
                    curve_i = [[x1_i,y1_i],[x2_i,y2_i],...] 
    :param list x_range: Passed to numpy.linspace(start sequence, stop sequnce, num samples)
    :param list y_range: y axis (same structure as x_range)
    :param tuple labels: [x-axis, y-axis]
    """
    #if '_backend' not in locals(): uti_plot_init() #?
    if (units is not None):
        x_range, x_unit = uti_plot_com.rescale_dim(x_range, units[0])
        y_range, y_unit = uti_plot_com.rescale_dim(y_range, units[1])
        units = [x_unit, y_unit, units[2]]
        strTitle = '' if (len(labels) < 3) else labels[2]
        labels = (labels[0] + ' [' + units[0] + ']',
                  labels[1] + ' [' + units[1] + ']', strTitle)

    _backend.uti_plot2d(ar2d, x_range, y_range, labels)
Exemplo n.º 2
0
def uti_plot2d1d(ar2d, x_range, y_range, x=0, y=0, labels=('Horizontal Position', 'Vertical Position', 'Intensity'), units=None, graphs_joined=True):
    """Generate 2d quad mesh plot from given "flattened" array, and 1d cuts passing through (x, y)

    :param array ar2d: flat 2d array of data points
    :param list x_range: Passed to numpy.linspace(start sequence, stop sequnce, num samples)
    :param list y_range: y axis (same structure as x_range)
    :param x: x value for 1d cut
    :param y: y value for 1d cut
    :param tuple labels: [x-axis, y-axis, z-axis]
    :param tuple units: [x-axis, y-axis, z-axis]
    :param graphs_joined: switch specifying whether the 2d plot and 1d cuts have to be displayed in one panel or separately
    """
    
    #if '_backend' not in locals(): uti_plot_init() #?
    if(units is not None): #checking / re-scaling x, y

        #OC17032019
        xRangeOrig = x_range[1] - x_range[0]
        yRangeOrig = y_range[1] - y_range[0] #AH30082019
        #yStartOrig = y_range[1] - y_range[0]
        
        x_range, x_unit = uti_plot_com.rescale_dim(x_range, units[0])
        y_range, y_unit = uti_plot_com.rescale_dim(y_range, units[1])

        #OC17032019
        if(x != 0): x *= (x_range[1] - x_range[0])/xRangeOrig
        if(y != 0): y *= (y_range[1] - y_range[0])/yRangeOrig
        
        units = [x_unit, y_unit,  units[2]]

        strTitle = labels[2]
        label2D = (labels[0] + ' [' + units[0]+ ']', labels[1] + ' [' + units[1] + ']', strTitle)

        #strTitle = 'At ' + labels[1] + ': ' + str(y)
        strTitle = 'At ' + labels[1] + ': ' + str(round(y, 6)) #OC17032019
        
        if y != 0: strTitle += ' ' + units[1]
        label1X = (labels[0] + ' [' + units[0] + ']', labels[2] + ' [' + units[2] + ']', strTitle)

        #strTitle = 'At ' + labels[0] + ': ' + str(x)
        strTitle = 'At ' + labels[0] + ': ' + str(round(x, 6)) #OC17032019
        
        if x != 0: strTitle += ' ' + units[0]
        label1Y = (labels[1] + ' [' + units[1] + ']', labels[2] + ' [' + units[2] + ']', strTitle)
        
    else: #OC081115
        strTitle = labels[2]
        label2D = (labels[0], labels[1], strTitle)

        strTitle = 'At ' + labels[1] + ': ' + str(y)
        label1X = (labels[0], labels[2], strTitle)

        strTitle = 'At ' + labels[0] + ': ' + str(x)
        label1Y = (labels[1], labels[2], strTitle)

    labels = [label2D, label1X, label1Y]

    _backend.uti_plot2d1d(ar2d, x_range, y_range, x, y, labels, graphs_joined)
def uti_plot2d(ar2d, x_range, y_range, labels=('Horizontal position [m]','Vertical position [m]'), units=None):
    """Generate quad mesh plot from given "flattened" array

    :param array ar2d: data points
    :param list x_range: Passed to numpy.linspace(start sequence, stop sequnce, num samples)
    :param list y_range: y axis (same structure as x_range)
    :param tuple labels: [x-axis, y-axis]
    """
    #if '_backend' not in locals(): uti_plot_init() #?
    if(units != None):
        x_range, x_unit = uti_plot_com.rescale_dim(x_range, units[0])
        y_range, y_unit = uti_plot_com.rescale_dim(y_range, units[1])
        units = [x_unit, y_unit,  units[2]]
        strTitle = '' if(len(labels) < 3) else labels[2]
        labels = (labels[0] + ' [' + units[0]+ ']', labels[1] + ' [' + units[1] + ']', strTitle)

    _backend1.uti_plot2d(ar2d, x_range, y_range, labels)
Exemplo n.º 4
0
def uti_plot2d(ar2d, x_range, y_range, labels=('Horizontal position [m]','Vertical position [m]'), units=None):
    """Generate quad mesh plot from given "flattened" array

    :param array ar2d: data points
    :param list x_range: Passed to numpy.linspace(start sequence, stop sequnce, num samples)
    :param list y_range: y axis (same structure as x_range)
    :param tuple labels: [x-axis, y-axis]
    """
    #if '_backend' not in locals(): uti_plot_init() #?
    if(units != None):
        x_range, x_unit = uti_plot_com.rescale_dim(x_range, units[0])
        y_range, y_unit = uti_plot_com.rescale_dim(y_range, units[1])
        units = [x_unit, y_unit,  units[2]]
        strTitle = '' if(len(labels) < 3) else labels[2]
        labels = (labels[0] + ' [' + units[0]+ ']', labels[1] + ' [' + units[1] + ']', strTitle)

    _backend.uti_plot2d(ar2d, x_range, y_range, labels)
Exemplo n.º 5
0
def uti_plot2d1d(ar2d, x_range, y_range, x=0, y=0, labels=('Horizontal position', 'Vertical position', 'Intensity'), units=None, graphs_joined=True):
    """Generate 2d quad mesh plot from given "flattened" array, and 1d cuts passing through (x, y)

    :param array ar2d: data points
    :param list x_range: Passed to numpy.linspace(start sequence, stop sequnce, num samples)
    :param list y_range: y axis (same structure as x_range)
    :param x: x value for 1d cut
    :param y: y value for 1d cut
    :param tuple labels: [x-axis, y-axis, z-axis]
    :param tuple units: [x-axis, y-axis, z-axis]
    :param graphs_joined: switch specifying whether the 2d plot and 1d cuts have to be displayed in one panel or separately
    """
    #if '_backend' not in locals(): uti_plot_init() #?
    if(units != None): #checking / re-scaling x, y
        x_range, x_unit = uti_plot_com.rescale_dim(x_range, units[0])
        y_range, y_unit = uti_plot_com.rescale_dim(y_range, units[1])
        units = [x_unit, y_unit,  units[2]]

        strTitle = labels[2]
        label2D = (labels[0] + ' [' + units[0]+ ']', labels[1] + ' [' + units[1] + ']', strTitle)

        strTitle = 'At ' + labels[1] + ': ' + str(y)
        if y != 0: strTitle += ' ' + units[1]
        label1X = (labels[0] + ' [' + units[0] + ']', labels[2] + ' [' + units[2] + ']', strTitle)

        strTitle = 'At ' + labels[0] + ': ' + str(x)
        if x != 0: strTitle += ' ' + units[0]
        label1Y = (labels[1] + ' [' + units[1] + ']', labels[2] + ' [' + units[2] + ']', strTitle)
        
    else: #OC081115
        strTitle = labels[2]
        label2D = (labels[0], labels[1], strTitle)

        strTitle = 'At ' + labels[1] + ': ' + str(y)
        label1X = (labels[0], labels[2], strTitle)

        strTitle = 'At ' + labels[0] + ': ' + str(x)
        label1Y = (labels[1], labels[2], strTitle)

    labels = [label2D, label1X, label1Y]

    _backend.uti_plot2d1d(ar2d, x_range, y_range, x, y, labels, graphs_joined)
Exemplo n.º 6
0
def uti_plot1d(ar1d, x_range, labels=('Photon Energy [eV]', 'ph/s/0.1%bw'), units=None):
    """Generate one-dimensional line plot from given array

    :param array ar1d: data points
    :param list x_range: Passed to numpy.linspace(start sequence, stop sequnce, num samples)
    :param tuple labels: [x-axis, y-axis]
    """
    #if '_backend' not in locals(): uti_plot_init() #?
    
    if(units is not None):
        x_range, x_unit = uti_plot_com.rescale_dim(x_range, units[0])
        units = [x_unit, units[1]]
        strTitle = '' if(len(labels) < 3) else labels[2]
        labels = (labels[0] + ' [' + units[0] + ']', labels[1] + ' [' + units[1] + ']', strTitle)

    _backend.uti_plot1d(ar1d, x_range, labels)
def uti_plot1d(ar1d, x_range, labels=('energy [eV]', 'ph/s/0.1%bw'), units=None):
    """Generate one-dimensional line plot from given array

    :param array ar1d: data points
    :param list x_range: Passed to numpy.linspace(start sequence, stop sequnce, num samples)
    :param tuple labels: [x-axis, y-axis]
    """
    #if '_backend' not in locals(): uti_plot_init() #?
    
    if(units != None):
        x_range, x_unit = uti_plot_com.rescale_dim(x_range, units[0])
        units = [x_unit, units[1]]
        strTitle = '' if(len(labels) < 3) else labels[2]
        labels = (labels[0] + ' [' + units[0] + ']', labels[1] + ' [' + units[1] + ']', strTitle)

    #print('*****In uti_plot1d')    
    _backend1.uti_plot1d(ar1d, x_range, labels)