Example #1
0
# ======================================
# Evaluate Bassetti-Erskine
# ======================================
E_x, E_y = E_complex(Xgrid.T, Ygrid.T, sx, sy, 1)
E_mag = np.sqrt(E_x**2 + E_y**2)

# ======================================
# Evaluate 2D Circular Gaussian
# ======================================
new = np.abs(invlaw(Xgrid.T, Ygrid.T, 1))

# ======================================
# Plot Basetti-Erskine
# ======================================
im = sm.imshow(E_mag, ax=ax[0, 0], vmin=0, vmax=np.max(new))
sm.addlabel(ax=ax[0, 0], toplabel='Elliptical Field Magnitude')

# ======================================
# Plot 2D Circular Gaussian
# ======================================
im = sm.imshow(new, ax=ax[0, 1], vmin=0, vmax=np.max(new))
sm.addlabel(ax=ax[0, 1], toplabel='Circular Field Magnitude', xlabel='x', ylabel='y')

# ======================================
# Plot Field Strength Differences
# ======================================
im = sm.imshow(E_mag-new, ax=ax[0, 2], cmap='bwr', vmin=-0.04, vmax=0.04)
sm.addlabel(ax=ax[0, 2], toplabel='Field Magnitude Difference', xlabel='x', ylabel='y')

# ======================================
# Plot differences in major, minor axes
Example #2
0
def plotfit(
        x                      ,
        y                      ,
        beta                   ,
        X                      ,
        top      = None        ,
        bottom   = 'Arbitrary' ,
        figpath  = None        ,
        error    = None        ,
        figlabel = None        ,
        axes     = None        ,
        fontsize = None        ,
        **kwargs
        ):
    """
    .. deprecated:: 0.0.0

    I'm not really sure what this function does, but it's not referenced anywhere else.
    """
    # ======================================
    # Set up PDF saving
    # ======================================
    # print axes
    # if axes is None:
    #     if not (figlabel == None):
    #         fig = _mt.figure(figlabel)
    #     else:
    #         fig = _plt.figure()
    #     axes=fig.add_subplot(1, 1, 1)
    # else:
    #     pass
    #     # fig = axes.get_figure()

    # Convert from meters to um
    y_data_mm_sq = y * 1e6
    y_fit_mm_sq = _np.dot(X, beta) * 1e6
    # error_mm_sq = error * 1e6

    # =================================================
    # VARIANCE FITS
    # =================================================
    # Plot data with error bars
    # axes.errorbar(x, y_data_mm_sq, error_mm_sq, fmt='.-')
    # axes.plot(x, y_data_mm_sq, 'o-', **kwargs)

    # Plot fits
    # axes.plot(x, y_fit_mm_sq, '-', **kwargs)

    # =================================================
    # SIGMA FITS
    # =================================================
    # Plot data with error bars
    # axes.errorbar(x, y_data_mm_sq, error_mm_sq, fmt='.-')
    axes.plot(x, _np.sqrt(y_data_mm_sq)*1e3, 'o-', **kwargs)

    # Plot fits
    axes.plot(x, _np.sqrt(y_fit_mm_sq)*1e3, '-', **kwargs)

    # _mt.addlabel(top, bottom, '$\sigma_x^2$ [mm$^2$]')
    if fontsize is None:
        axes.legend(['Measured Slices', 'Fit to Measurement'])
    else:
        axes.legend(['Measured Slices', 'Fit to Measurement'], fontsize=fontsize)
    _sm.addlabel(axes=axes, xlabel='Slice Energy [GeV]', ylabel='Slice Spot Size $\\sigma_x$ [$\\mu$m]', toplabel=top)
    # if fig is not None:
    #         fig.tight_layout()

    # if not (figpath == None):
    #         _mt.graphics.savefig(figlabel, figpath)

    return axes