Пример #1
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)

        labels = [label2D, label1X, label1Y]

    _backend.uti_plot2d1d(ar2d, x_range, y_range, x, y, labels, graphs_joined)
Пример #2
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)
Пример #3
0
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)
    
    _backend.uti_plot1d(ar1d, x_range, labels)