Exemple #1
0
def main_plot_flow_all(hkl='211',sin2psimx=0.5,
                       psi_nbin=1,pmargin=None,iplot_rs=False,
                       path=''):
    """  """
    fns = read(hkl,prefix=path)
    fig = wf(nw=3,nh=1,left=0.2,uw=3.5,
             w0=0,w1=0.3,right=0,iarange=True)
    ax1,ax2,ax3 = fig.axes
    axes_label.__eqv__(ax1,ft=10)
    errors = []
    for i in range(len(fns)):
        fn = fns[i]
        strain_path = fn.split('_')[0]
        untargz(fn)
        model_rs, fwgt, fdsa \
            = rs_ex.ex_consistency(
                sin2psimx=sin2psimx,
                psi_nbin=psi_nbin,
                hkl=hkl,iplot=iplot_rs,
                pmargin=pmargin,path=path)
        fwgt.get_eqv(); fdsa.get_eqv()

        e = find_err(fwgt,fdsa)
        ax3.plot(fwgt.epsilon_vm,e)
        errors.append([fwgt.epsilon_vm,e])

        ax1.plot(fwgt.epsilon_vm,fwgt.sigma_vm,
                 'bx-',label='Weighted Avg', alpha=1.0)
        ax1.plot(fdsa.epsilon_vm,fdsa.sigma_vm,
                 'kx',label='Diff. Stress Analsysis', alpha=1.0)
        ax2.plot(fwgt.sigma[0,0],fwgt.sigma[1,1],'b+')
        ax2.plot(fdsa.sigma[0,0],fdsa.sigma[1,1],'k+')

        ## connector
        npoints = len(fwgt.sigma[0,0])
        wgtx = fwgt.sigma[0,0]; wgty = fwgt.sigma[1,1]
        dsax = fdsa.sigma[0,0]; dsay = fdsa.sigma[1,1]
        for j in range(npoints):
            ax2.plot([wgtx[j],dsax[j]],[wgty[j],dsay[j]],'k-',alpha=0.5)
        plt.show();plt.draw()

    ax1.set_xlim(-0.1,1.1); ax1.set_ylim(-50,700);
    ax2.set_xlim(-10,1000); ax2.set_ylim(-10,1000)
    ax2.set_aspect('equal')
    ax2.set_xlabel(r'$\bar{\Sigma}_{11}$',dict(fontsize=15))
    ax2.set_ylabel(r'$\bar{\Sigma}_{22}$',dict(fontsize=15))
    ax2.locator_params(nbins=3)
    ax2.grid('on'); plt.show()

    fig.savefig('flow_allpaths_%s.pdf'%(hkl))
    plt.close(fig)

    return np.array(errors)[0]
Exemple #2
0
def influence_of_intp(ss=2,bounds=[0,0.5],
                      psi_nbin=13,iplot=False,
                      hkl=None,
                      iscatter=False,iwgt=False,
                      sigma=5e-5,
                      intp_opt=0):
    """
    Parametric study to demonstrate the uncertainty
    for a fixed intp_opt

    Arguments
    =========
    ss       = 2 (step size)
    bounds   = sin2psi bounds
    psi_nbin = Number of psi data points in use
    iplot    = False
    hkl      = None
    iscatter = False
    iwgt     = False
    sigma    = 5e-5
    intp_opt = 0
    """
    from rs import filter_psi2
    from rs_ex import ex_consistency as main
    from MP.mat.mech import find_err

    if iplot:
        from MP.lib import mpl_lib,axes_label
        import matplotlib.pyplot as plt
        wide_fig     = mpl_lib.wide_fig
        deco         = axes_label.__deco__
        fig          = wide_fig(nw=3,nh=1)
        axs          = fig.axes

    ## Use the reduced set over the consistency check
    sf, ig = use_intp_sfig(
        ss=ss,iopt=intp_opt,iplot=False,
        iwgt=False)

    sf_ext = sf.sf.swapaxes(1,-1).swapaxes(-2,-1)[::]*1e6
    ig_ext = ig.ig[::]

    ##
    # Filtering against sin2psi
    sf_ext = filter_psi2(
        obj=sf_ext,sin2psi=sf.sin2psi,
        bounds=bounds)
    ig_ext = filter_psi2(
        obj=ig_ext,sin2psi=sf.sin2psi,
        bounds=bounds)

    ### Reduce binning
    ## consistency check
    rst = main(sin2psimx=bounds[1],
               psi_nbin=psi_nbin,
               sf_ext=sf_ext,ig_ext=ig_ext,
               iplot=iplot,hkl=hkl,
               iscatter=iscatter,
               sigma=sigma,iwgt=iwgt,
               vf_ext=None)

    fw, fd = rst[1], rst[2]

    if iplot:
        axs[0].plot(fw.epsilon_vm,fw.sigma_vm,
                    'b-x',label='Weight Avg.')
        axs[0].plot(fd.epsilon_vm,fd.sigma_vm,
                    'k+',label='Diff Stress')

    if type(ss).__name__=='int':
        x = fd.epsilon_vm[::ss];
        y = fd.sigma_vm[::ss]
    elif type(ss).__name__=='list':
        x = fd.epsilon_vm[ss];
        y = fd.sigma_vm[ss]

    if iplot:
        label='SF/IG acqusition'
        axs[0].plot(x,y,'o',mec='r',mfc='None',
                    alpha=0.8,label=label)
        axs[1].plot(fw.sigma[0,0],fw.sigma[1,1],'b-x')
        axs[1].plot(fd.sigma[0,0],fd.sigma[1,1],'k+')

    npoints = len(fw.sigma[0,0])
    wgtx, wgty = fw.sigma[0,0], fw.sigma[1,1]
    dsax, dsay = fd.sigma[0,0], fd.sigma[1,1]

    if iplot:
        for i in range(npoints):
            axs[1].plot([wgtx[i],dsax[i]],
                        [wgty[i],dsay[i]],
                        'k-',alpha=0.2)

    e = find_err(fw,fd)
    if iplot: axs[2].plot(fw.epsilon_vm, e, 'x')

    if type(ss).__name__=='int' and iplot:
        axs[2].plot(fw.epsilon_vm[::ss],e[::ss],
                    'o',mec='r',mfc='None',label=label)
    elif type(ss).__name__=='list' and iplot:
        axs[2].plot(fw.epsilon_vm[ss],e[ss],
                    'o',mec='r',mfc='None',label=label)

    if type(ss).__name__=='int':    dum=ss
    elif type(ss).__name__=='list': dum =len(ss)

    if iplot:
        axes_label.__eqv__(axs[0],ft=10)
        axs[1].set_aspect('equal')
        axs[1].set_xlabel(r'$\bar{\Sigma}_{11}$',dict(fontsize=15))
        axs[1].set_ylabel(r'$\bar{\Sigma}_{22}$',dict(fontsize=15))
        axs[1].set_ylim(-100,700); axs[1].set_xlim(-100,700)

        axs[0].legend(loc='best',fontsize=10).get_frame().set_alpha(0.5)
        deco(iopt=8,ft=15,ax=axs[2])

        fig.savefig('flow_dd_bin%i_ss%i.pdf'%(psi_nbin,dum))
        plt.close(fig)

    return fw, e
Exemple #3
0
def influence_of_intp(ss=2,bounds=[0,0.5],
                      psi_nbin=13,iplot=False,
                      hkl=None,
                      iscatter=False,iwgt=False,
                      sigma=5e-5,
                      intp_opt=0):
    """
    Parametric study to demonstrate the uncertainty
    for a fixed intp_opt

    Arguments
    =========
    ss       = 2 (step size)
    bounds   = sin2psi bounds
    psi_nbin = Number of psi data points in use
    iplot    = False
    hkl      = None
    iscatter = False
    iwgt     = False
    sigma    = 5e-5
    intp_opt = 0
    """
    from rs import filter_psi2
    from rs_ex import ex_consistency as main
    from MP.mat.mech import find_err

    if iplot:
        from MP.lib import mpl_lib,axes_label
        import matplotlib.pyplot as plt
        wide_fig     = mpl_lib.wide_fig
        deco         = axes_label.__deco__
        fig          = wide_fig(nw=3,nh=1)
        axs          = fig.axes

    ## Use the reduced set over the consistency check
    sf, ig = use_intp_sfig(
        ss=ss,iopt=intp_opt,iplot=False,
        iwgt=False)

    sf_ext = sf.sf.swapaxes(1,-1).swapaxes(-2,-1)[::]*1e6
    ig_ext = ig.ig[::]

    ##
    # Filtering against sin2psi
    sf_ext = filter_psi2(
        obj=sf_ext,sin2psi=sf.sin2psi,
        bounds=bounds)
    ig_ext = filter_psi2(
        obj=ig_ext,sin2psi=sf.sin2psi,
        bounds=bounds)

    ### Reduce binning
    ## consistency check
    rst = main(sin2psimx=bounds[1],
               psi_nbin=psi_nbin,
               sf_ext=sf_ext,ig_ext=ig_ext,
               iplot=iplot,hkl=hkl,
               iscatter=iscatter,
               sigma=sigma,iwgt=iwgt,
               vf_ext=None)

    fw, fd = rst[1], rst[2]

    if iplot:
        axs[0].plot(fw.epsilon_vm,fw.sigma_vm,
                    'b-x',label='Weight Avg.')
        axs[0].plot(fd.epsilon_vm,fd.sigma_vm,
                    'k+',label='Diff Stress')

    if type(ss).__name__=='int':
        x = fd.epsilon_vm[::ss];
        y = fd.sigma_vm[::ss]
    elif type(ss).__name__=='list':
        x = fd.epsilon_vm[ss];
        y = fd.sigma_vm[ss]

    if iplot:
        label='SF/IG acqusition'
        axs[0].plot(x,y,'o',mec='r',mfc='None',
                    alpha=0.8,label=label)
        axs[1].plot(fw.sigma[0,0],fw.sigma[1,1],'b-x')
        axs[1].plot(fd.sigma[0,0],fd.sigma[1,1],'k+')

    npoints = len(fw.sigma[0,0])
    wgtx, wgty = fw.sigma[0,0], fw.sigma[1,1]
    dsax, dsay = fd.sigma[0,0], fd.sigma[1,1]

    if iplot:
        for i in xrange(npoints):
            axs[1].plot([wgtx[i],dsax[i]],
                        [wgty[i],dsay[i]],
                        'k-',alpha=0.2)

    e = find_err(fw,fd)
    if iplot: axs[2].plot(fw.epsilon_vm, e, 'x')

    if type(ss).__name__=='int' and iplot:
        axs[2].plot(fw.epsilon_vm[::ss],e[::ss],
                    'o',mec='r',mfc='None',label=label)
    elif type(ss).__name__=='list' and iplot:
        axs[2].plot(fw.epsilon_vm[ss],e[ss],
                    'o',mec='r',mfc='None',label=label)

    if type(ss).__name__=='int':    dum=ss
    elif type(ss).__name__=='list': dum =len(ss)

    if iplot:
        axes_label.__eqv__(axs[0],ft=10)
        axs[1].set_aspect('equal')
        axs[1].set_xlabel(r'$\bar{\Sigma}_{11}$',dict(fontsize=15))
        axs[1].set_ylabel(r'$\bar{\Sigma}_{22}$',dict(fontsize=15))
        axs[1].set_ylim(-100,700); axs[1].set_xlim(-100,700)

        axs[0].legend(loc='best',fontsize=10).get_frame().set_alpha(0.5)
        deco(iopt=8,ft=15,ax=axs[2])

        fig.savefig('flow_dd_bin%i_ss%i.pdf'%(psi_nbin,dum))
        plt.close(fig)

    return fw, e
Exemple #4
0
def main_plot_flow_all(
        hkl='211',sin2psimx=0.5,psi_nbin=1,
        pmargin=None,iplot_rs=False,
        path=''):
    """
    Arguments
    =========
    hkl='211'
    sin2psimx
    psi_nbin = 1
    pmargin = None
    iplot_rs=False
    path=''
    """
    fns = read(hkl,prefix=path)
    if len(fns)==0:
        raise IOError, 'Check the path, 0 file was found'
    plt.ioff()
    fig = wf(nw=3,nh=1,left=0.2,uw=3.5,
             w0=0,w1=0.3,right=0,iarange=True)
    ax1,ax2,ax3 = fig.axes
    axes_label.__eqv__(ax1,ft=10)
    errors = []
    for i in xrange(len(fns)):
        fn = fns[i]
        strain_path = fn.split('_')[0]
        untargz(fn)
        model_rs, fwgt, fdsa \
            = rs_ex.ex_consistency(
                sin2psimx=sin2psimx,
                psi_nbin=psi_nbin,
                hkl=hkl,iplot=iplot_rs,
                pmargin=pmargin,path=path)
        fwgt.get_eqv(); fdsa.get_eqv()

        e = find_err(fwgt,fdsa)
        ax3.plot(fwgt.epsilon_vm,e)
        errors.append([fwgt.epsilon_vm,e])

        ax1.plot(fwgt.epsilon_vm,fwgt.sigma_vm,
                 'bx-',label='Weighted Avg', alpha=1.0)
        ax1.plot(fdsa.epsilon_vm,fdsa.sigma_vm,
                 'kx',label='Diff. Stress Analsysis', alpha=1.0)
        ax2.plot(fwgt.sigma[0,0],fwgt.sigma[1,1],'b+')
        ax2.plot(fdsa.sigma[0,0],fdsa.sigma[1,1],'k+')

        ## connector
        npoints = len(fwgt.sigma[0,0])
        wgtx = fwgt.sigma[0,0]; wgty = fwgt.sigma[1,1]
        dsax = fdsa.sigma[0,0]; dsay = fdsa.sigma[1,1]
        for j in xrange(npoints):
            ax2.plot([wgtx[j],dsax[j]],[wgty[j],dsay[j]],'k-',alpha=0.5)

    ax1.set_xlim(-0.1,1.1); ax1.set_ylim(-50,700);
    ax2.set_xlim(-10,1000); ax2.set_ylim(-10,1000)
    ax2.set_aspect('equal')
    ax2.set_xlabel(r'$\bar{\Sigma}_{11}$',dict(fontsize=15))
    ax2.set_ylabel(r'$\bar{\Sigma}_{22}$',dict(fontsize=15))
    ax2.locator_params(nbins=3)
    ax2.grid('on'); plt.show()

    plt.ion()
    plt.show();plt.draw()
    fn = 'flow_allpaths_%s.pdf'%(hkl)
    fig.savefig(fn)
    print '%s has been saved.'%fn
    plt.close(fig)

    return np.array(errors)[0]