Exemple #1
0
    def __mode_HV(self, data, allrange, _ar_labels, _ar_units, _xc=0, _yc=0, _graphs_joined=True):
        #Could be moved to uti_plot_com.py (since there is not Matplotlib-specific content)
        #allrange, units = _rescale_range(allrange)
        #allrange, units = _rescale_range(allrange, _ar_units, 0, _xc, _yc)
        allrange, units = rescale_range(allrange, _ar_units, 0, _xc, _yc)

        e0, e1, ne, x0, x1, nx, y0, y1, ny, ec, xc, yc = allrange
        range_x = x0, x1, nx
        range_y = y0, y1, ny
        #print range_x, range_y
        #x = np.linspace(x0, x1, nx)
        #y = np.linspace(y0, y1, ny)
        #ix = np.where(abs(x)==abs(x).min())[0][0]
        #iy = np.where(abs(y)==abs(y).min())[0][0]
        #label2D = ("Horizontal Position, ["+units[1]+"]", "Vertical Position, ["+units[2]+"]")
        strTitle = _ar_labels[3]
        if (ne == 1) and (e0 > 0): strTitle += ' at ' + str(e0) + ' ' + units[0]

        label2D = (_ar_labels[1] + ' [' + units[1]+ ']', _ar_labels[2] + ' [' + units[2] + ']', strTitle)
        #print(label2D)

        #label1H = ("Horizontal Position, ["+units[1]+"]","Ph/s/0.1%BW/mm^2")
        strTitle = 'At ' + _ar_labels[2] + ': ' + str(yc)
        if yc != 0: strTitle += ' ' + units[2]
        label1H = (_ar_labels[1] + ' [' + units[1] + ']', _ar_labels[3] + ' [' + _ar_units[3] + ']', strTitle)

        #label1V = ("Vertical Position, ["+units[2]+"]","Ph/s/0.1%BW/mm^2")
        strTitle = 'At ' + _ar_labels[1] + ': ' + str(xc)
        if xc != 0: strTitle += ' ' + units[1]
        label1V = (_ar_labels[2] + ' [' + units[2] + ']', _ar_labels[3] + ' [' + _ar_units[3] + ']', strTitle)

        #return plot_2D_1D(data, range_x, range_y, [label2D, label1H, label1V], _graphs_joined)
        return self.uti_plot2d1d(data, range_x, range_y, xc, yc, [label2D, label1H, label1V], _graphs_joined)
Exemple #2
0
    def __mode_T(self, data, allrange, _ar_labels, _ar_units, _ec=0, _xc=0, _yc=0):
        #allrange, units = _rescale_range(allrange)
        #allrange, units = _rescale_range(allrange, _ar_units, _ec, _xc, _yc)
        allrange, units = rescale_range(allrange, _ar_units, _ec, _xc, _yc)

        #e0, e1, ne, x0, x1, nx, y0, y1, ny = allrange
        e0, e1, ne, x0, x1, nx, y0, y1, ny, ec, xc, yc = allrange
        #toprint = (e0,e1,units[0], x0,x1,units[1], y0,y1,units[2], data[0]) #squeeze have reduced it to an array with one element.
        toprint = (e0,units[0], x0,units[1], y0,units[2], data[0],units[3]) #squeeze have reduced it to an array with one element.
        #sys.stdout.write('Total Flux for \nE: %f -> %f %s\nX: %f -> %f %s\nY: %f -> %f %s\n is %f Ph/s/0.1%BW' % toprint) 
        sys.stdout.write(_ar_labels[3] + ' for \n' + _ar_labels[0] + ': %f %s\n' + _ar_labels[1] + ': %f %s\n' + _ar_labels[2] + ': %f %s\n is %f %s' % toprint) 
        return None
Exemple #3
0
    def __mode_E(self, data, allrange, _ar_labels, _ar_units):
        #allrange, units = _rescale_range(allrange)
        #allrange, units = _rescale_range(allrange, _ar_units)
        allrange, units = rescale_range(allrange, _ar_units)

        e0, e1, ne, x0, x1, nx, y0, y1, ny, ec, xc, yc = allrange
        range_e = e0, e1, ne
        #label = ("Energy, ["+units[0]+"]","Ph/s/0.1%BW")
        label = (_ar_labels[0] + ' [' + units[0] + ']', _ar_labels[3] + ' [' + _ar_units[3] + ']')
        #fig = self._pl.figure(figsize=(4,4))
        fig = self._pl.figure(figsize=(7,4)) #OC17112017
        self._plot_1D(data,range_e,label,fig)
        return fig
Exemple #4
0
    def __mode_H(self, data, allrange, _ar_labels, _ar_units):
        #allrange, units = _rescale_range(allrange)
        #allrange, units = _rescale_range(allrange, _ar_units)
        allrange, units = rescale_range(allrange, _ar_units)

        #e0, e1, ne, x0, x1, nx, y0, y1, ny = allrange
        e0, e1, ne, x0, x1, nx, y0, y1, ny, ec, xc, yc = allrange
        range_x = x0, x1, nx 
        #label = ("Horizontal Position, ["+units[1]+"]","Ph/s/0.1%BW/mm^2")
        label = (_ar_labels[1] + ' [' + units[1] + ']', _ar_labels[3] + ' [' + _ar_units[3] + ']')
        fig = self._pl.figure(figsize=(4,4))
        self._plot_1D(data, range_x, label, fig)
        return fig
    def __mode_V(self, data, allrange, _ar_labels, _ar_units):
        #allrange, units = _rescale_range(allrange)
        #allrange, units = _rescale_range(allrange, _ar_units)
        allrange, units = uti_plot_com.rescale_range(allrange, _ar_units)

        #e0, e1, ne, x0, x1, nx, y0, y1, ny = allrange
        e0, e1, ne, x0, x1, nx, y0, y1, ny, ec, xc, yc = allrange
        range_y = y0, y1, ny
        #label = ("Vertical Position, ["+units[2]+"]","Ph/s/0.1%BW/mm^2")
        label = (_ar_labels[2] + ' [' + units[2] + ']',
                 _ar_labels[3] + ' [' + _ar_units[3] + ']')
        fig = self._pl.figure(figsize=(4, 4))
        self._plot_1D(data, range_y, label, fig)
        return fig
    def __mode_EHV(self,
                   data,
                   allrange,
                   _ar_labels,
                   _ar_units,
                   _ec,
                   _xc,
                   _yc,
                   _graphs_joined=1):
        #allrange, units = _rescale_range(allrange)
        #allrange, units = _rescale_range(allrange, _ar_units, _ec, _xc, _yc)
        allrange, units = uti_plot_com.rescale_range(allrange, _ar_units, _ec,
                                                     _xc, _yc)

        #e0, e1, ne, x0, x1, nx, y0, y1, ny = allrange
        e0, e1, ne, x0, x1, nx, y0, y1, ny, ec, xc, yc = allrange

        #e = np.linspace(e0, e1, ne)
        #x = np.linspace(x0, x1, nx)
        #y = np.linspace(y0, y1, ny)
        #ie = np.where(data.sum(axis=1)==data.sum(axis=1).max())[0][0]
        #ix = np.where(abs(x)==abs(x).min())[0][0]
        #iy = np.where(abs(y)==abs(y).min())[0][0]

        range_e = e0, e1, ne
        range_x = x0, x1, nx
        range_y = y0, y1, ny

        ie = 0
        if ne > 1:
            if ec > e1: ie = ne - 1
            elif ec > e0:
                eStep = (e1 - e0) / (ne - 1)
                if eStep > 0: ie = int(round((ec - e0) / eStep))
        ix = 0
        if nx > 1:
            if xc > x1: ix = nx - 1
            elif xc > x0:
                xStep = (x1 - x0) / (nx - 1)
                if xStep > 0: ix = int(round((xc - x0) / xStep))
        iy = 0
        if ny > 1:
            if yc > y1: iy = ny - 1
            elif yc > y0:
                yStep = (y1 - y0) / (ny - 1)
                if yStep > 0: iy = int(round((yc - y0) / yStep))

        #label2D = ("Horizontal Position, ["+units[1]+"]", "Vertical Position, ["+units[2]+"]")
        label2D = (_ar_labels[1] + ' [' + units[1] + ']',
                   _ar_labels[2] + ' [' + units[2] + ']')

        #label1E = ("Energy, ["+units[0]+"]","Ph/s/0.1%BW/mm^2")
        label1E = (_ar_labels[0] + ' [' + units[0] + ']',
                   _ar_labels[3] + ' [' + units[3] + ']')

        #label1H = ("Horizontal Position, ["+units[1]+"]","Ph/s/0.1%BW/mm^2")
        label1H = (_ar_labels[1] + ' [' + units[1] + ']',
                   _ar_labels[3] + ' [' + units[3] + ']')

        #label1V = ("Vertical Position, ["+units[2]+"]","Ph/s/0.1%BW/mm^2")
        label1V = (_ar_labels[2] + ' [' + units[2] + ']',
                   _ar_labels[3] + ' [' + units[3] + ']')

        arCutXY = array('d', [0] * nx * ny)
        perY = ne * nx
        i = 0
        for iiy in range(ny):
            perY_iiy = perY * iiy
            for iix in range(nx):
                arCutXY[i] = data[ie + ne * iix + perY_iiy]
                i += 1

        arCutE = array('d', [0] * ne)
        perX_ix = ne * ix
        perY_iy = perY * iy
        for iie in range(ne):
            arCutE[iie] = data[iie + perX_ix + perY_iy]

        arCutX = array('d', [0] * nx)
        for iix in range(nx):
            arCutX[iix] = data[ie + ne * iix + perY_iy]

        arCutY = array('d', [0] * ny)
        for iiy in range(ny):
            arCutY[iiy] = data[ie + perX_ix + perY * iiy]

        #fig = _pl.figure(figsize=(8,8))
        #_plot_2D(data[:,:,ie], range_x, range_y, label2D, fig, 221)
        #_plot_1D(data[ix,iy,:],range_e,label1E,fig,224)
        #_plot_1D(data[ie,:,iy],range_x,label1H,fig,222)
        #_plot_1D(data[:,ix,ie],range_y,label1V,fig,223)

        fig = None
        if _graphs_joined:
            fig = self._pl.figure(figsize=(12, 5))
            self._plot_2D(arCutXY, range_x, range_y, label2D, fig,
                          221)  #showing graphs in one figure
            self._plot_1D(arCutE, range_e, label1E, fig, 222)
            self._plot_1D(arCutX, range_x, label1X, fig, 223)
            self._plot_1D(arCutY, range_y, label1Y, fig, 224)
        else:
            self.uti_plot2d(arCutXY, range_x, range_y, label2D)
            self.uti_plot1d(arCutE, range_e, label1E)
            self.uti_plot1d(arCutX, range_x, label1X)
            self.uti_plot1d(arCutY, range_y, label1Y)
        return self._maybe_savefig(fig)