def KelinCompare(expt, savedata=False):
    proj = 'TTGM-{}_FS19SS6'.format(expt)
    key = n.genfromtxt('../ExptSummary.dat', delimiter=',')
    alpha = key[key[:, 0] == expt, 3].ravel()
    dr = n.genfromtxt('../{}/disp-rot.dat'.format(proj), delimiter=',')[:, 5]
    d = n.load(
        '../{}/IncrementalAnalysis/NewFilterPassingPoints_3med.npy'.format(
            proj))
    mnmx = d[..., 17].min(axis=1), d[..., 17].max(axis=1)
    cols = {4: (0, 1), 1: (2, 3), 5: (4, 5)}
    s = read_excel('../Misc/KelinSim.xlsx', parse_cols=cols[expt]).values
    if savedata:
        n.savetxt('KelinCompare_Expt-{}.dat'.format(expt),
                  X=n.c_[dr, d[..., 17].mean(axis=1), mnmx[0], mnmx[1]],
                  fmt="%.6f",
                  delimiter=',')
        n.savetxt('KelinCompare_Expt-{}_kel.dat'.format(expt),
                  X=s,
                  fmt="%.6f",
                  delimiter=',')
    p.style.use('mysty')
    fig, ax = p.subplots()
    p.fill_between(dr, mnmx[0], mnmx[1], alpha=0.1, color='C0')
    p.plot(dr, mnmx[1], 'C0', label='Exp')
    p.plot(dr, mnmx[0], 'C0')
    p.plot(dr, d[:, :, 17].mean(axis=1), '--', color='C0')
    p.plot(s[:, 0], s[:, 1], 'C1', lw=2, label='Anal Anis')
    ax.axis(xmin=0, ymin=0)
    ax.set_xlabel('$\\Phi$')
    ax.set_ylabel('e$_\\mathsf{e}$')
    f.ezlegend(ax,
               loc=2,
               title='TTGM-{}\n$\\alpha$ = {:g}'.format(expt, alpha[0]))
    f.myax(ax)
    return fig, ax
def CornerFailure(max=False, mean=True, constit='vm'):
    key = n.genfromtxt('../ExptSummary.dat', delimiter=',')
    key = key[(key[:, 3] != 0)]
    key = key[key[:, 3].argsort()]
    corneralphas = n.unique(key[n.in1d(key[:, 1], [1, 2])][:, 3])
    ex, extype = key[:, :2].astype(int).T
    failz = n.genfromtxt('./failstns.dat', delimiter='\t')

    columnmapper = {'vm': [0, 6], 'h8': [1, 7], 'anis': [2, 8]}
    triaxmapper = {'vm': 2, 'h8': 3, 'anis': 4}
    marker = ['C0s', 'C1o', 'C2^']
    label = [
        '$\\Sigma=\\alpha\\mathcal{T}$', '$\\Sigma\\rightarrow\\mathcal{{T}}$',
        '$\\mathcal{{T}}\\rightarrow\\Sigma$'
    ]
    do = False

    p.style.use('mysty')
    fig, ax = p.subplots()
    lines = []
    for k, (x, xt, a) in enumerate(zip(ex, extype, key[:, 3])):
        triax = failz[failz[:, 0] == x, triaxmapper[constit]]
        proj = 'TTGM-{}_FS19SS6'.format(x)
        # [0-5]Mean VM-H8-Anis-de00-01-00, [6-11]Max VM-H8-Anis-de00-01-00, [12-13]Mean, max Classic LEp
        e = n.genfromtxt(
            '../{}/IncrementalAnalysis/NewFilterResults_3med.dat'.format(proj),
            delimiter=',')[-1]
        c1, c2 = columnmapper[constit.lower()]
        if a not in corneralphas:
            if mean: ax.plot(triax, e[c1], 'C0s', alpha=0.35)
            if max: ax.plot(triax, e[c2], 'C0s', alpha=0.35)
        else:
            if len(lines) == 3:
                lines = []
                do = True
            if mean:
                lines.extend(
                    ax.plot(triax,
                            e[c1],
                            marker[xt],
                            label=[label[xt] if do else ''][0]))
            if max:
                lines.extend(
                    ax.plot(triax,
                            e[c2],
                            marker[xt],
                            label=[label[xt] if do else ''][0]))

    f.ezlegend(ax, markers=True, loc=3)
    ax.axis(xmin=0, ymin=0, ymax=1.65)
    ax.set_xlabel('$\\sigma_{\\mathsf{m}}/\\sigma_{\\mathsf{e}}$')
    ax.set_ylabel('$\\mathsf{e}^{\\mathsf{p}}_{\\mathsf{e}}$')
    f.eztext(
        ax, 'Al-6061-T6\n{}\n{}'.format(
            constit.upper(),
            'Mean' * mean + '\n' * (max & mean) + 'Max' * max), 'ur')
    f.myax(ax)
def slowplots():
    '''
    Some old plots that take a long time to plot that I don't find useful anymore
    '''
    
    # Let's see if old-style calc last stage max is in the new 
    # datasetmaxloc = n.nonzero( (A[:,0] == maxij[-1,0]) & (A[:,1] == maxij[-1,1]) )[0]
    oldmaxloc = n.nonzero( (A[:,0] == maxij[-1,0]) & (A[:,1] == maxij[-1,1]) )[0]
    # And calcualte the new maxloc
    newmaxloc = n.argmax(de[-1, :, 3])
    
    p.style.use('mysty')
    fig1 = p.figure()
    ax1 = fig1.add_subplot(111)
    for i in de[:,:,3].T:
        p.plot(dr, i, 'C1', alpha=0.1)
    p.plot(dr, de[:,:,3].mean(axis=1),'C0', label='Increm. Mean')
    p.plot(dr, dmean, 'C2', label='Old Mean')
    p.plot(dr, dmax, 'C3', label='Old Max')
    if len(oldmaxloc) == 1:
        p.plot(dr, de[:,oldmaxloc,3], 'C4', label='Old Max Pt')
        if oldmaxloc[0] != newmaxloc:
            p.plot(dr, de[:,newmaxloc,3], 'C5', label='New Max Pt')
        else:
            f.eztext(ax1, 'Old pMax pt is same\nas new max pt.', 'ul')
    else:
        p.plot(dr, de[:,newmaxloc,3], 'C5', label='New Max Pt')
        f.eztext(ax1, 'Old Max Pt is not\nin the new dataset', 'ul')
    p.xlabel(xlab)
    p.ylabel('$\\mathsf{e}_\\mathsf{e}$')
    ax1.axis(xmin=0)
    f.myax(p.gca())
    f.ezlegend(p.gca())
    p.savefig('../{}/IncrementalAnalysis/IncrementalAnalysis1.png'.format(pname), dpi=125)

    # Epsilon v gamma
    fig2 = p.figure()
    ax2 = fig2.add_subplot(111)
    for gam, eps in zip(-2*de[:,:,1].T, de[:,:,2].T):
        ax2.plot(gam, eps, 'C1', alpha=0.05)
    ax2.plot(-2*de[:,:,1].mean(axis=1), de[:,:,2].mean(axis=1), label='Mean', zorder=50)
    if len(oldmaxloc) == 1:
        ax2.plot(-2*de[:,oldmaxloc,1], de[:,oldmaxloc,2], label='Old Max Pt')
        if oldmaxloc[0] != newmaxloc:
            ax2.plot(-2*de[:,newmaxloc,1], de[:,newmaxloc,2], label='New Max Pt')
    else:
        ax2.plot(-2*de[:,newmaxloc,1], de[:,newmaxloc,2], label='New Max Pt')
    ax2.set_xlabel('$\\mathsf{2e}_{\\theta\\mathsf{x}}$')
    ax2.set_ylabel('$\\mathsf{e}_\\mathsf{x}$')
    ax2.axis(xmin=0, ymin=0)
    f.myax(ax2)
    f.ezlegend(ax2)
    fig2.savefig('../{}/IncrementalAnalysis/IncrementalAnalysis2.png'.format(pname), dpi=125)
def NewOldMax(expt, mode=None):
    '''
    Plots the STK16 max point and the new max point eeq vs rot
    Can plot either Total or incremental method of calculation
    '''
    proj = 'TTGM-{}_FS19SS6'.format(expt)
    dr = n.genfromtxt('../{}/disp-rot.dat'.format(proj), delimiter=',')[:, 5]
    oldmax = n.genfromtxt('../{}/MaxPt.dat'.format(proj), delimiter=',')[:, 10]
    oldmax_incr = n.genfromtxt(
        '../{}/IncrementalAnalysis/OldFilteringResults.dat'.format(proj),
        delimiter=',',
        usecols=(10))
    maxi, maxj = n.genfromtxt('../{}/max.dat'.format(proj), delimiter=',')[-1,
                                                                           -2:]
    # [0]Index_x [1]Index_y [2,3,4]Undef_X,Y,Z inches
    # [5,6,7]Def_X,Y,Z inches [8,9,10,11]DefGrad (11 12 21 22)
    # [12,13,14,15,16,17] e00, e01, e11, eeqVM, eeqH8, eeqAnis
    D = n.load(
        '../{}/IncrementalAnalysis/NewFilterPassingPoints_3med.npy'.format(
            proj))
    locmax = D[-1, :, 15].argmax()

    p.style.use('mysty')
    fig, ax = p.subplots()
    if mode != 'Total':
        ax.plot(dr,
                oldmax_incr,
                label='STK16 ({:.0f},{:.0f})'.format(maxi, maxj),
                zorder=10)
        ax.plot(dr,
                D[:, locmax, 15],
                label='New ({:.0f},{:.0f})'.format(*D[-1, locmax, :2]))
        title = 'TTGM-{} Max Incr. Values'.format(expt)
    else:
        ax.plot(dr,
                oldmax,
                label='STK16 ({:.0f},{:.0f})'.format(maxi, maxj),
                zorder=10)
        # [0-5]Mean VM-H8-Anis-de00-01-00, [6-11]Max VM-H8-Anis-de00-01-00, [12-13]Mean, max Classic LEp
        h = n.genfromtxt(
            '../{}/IncrementalAnalysis/NewFilterResults_3med.dat'.format(proj),
            delimiter=',',
            usecols=(13, ))
        ax.plot(dr, h, label='New ({:.0f},{:.0f})'.format(*D[-1, locmax, :2]))
        title = 'TTGM-{} Max Total Stn'.format(expt)

    ax.set_xlabel('$\\Phi$')
    ax.set_ylabel('e$_\\mathsf{e}$')
    ax.axis(xmin=0, ymin=0)
    f.ezlegend(ax, title=title, loc=2)
    f.myax(ax)

    return None
def PlotOldMaxTraceBack(expt):
    '''
    Plots the STK16 max point eeq vs rot and its increm. ex vs 2eqx
    
    '''
    p.style.use('mysty')
    fig, ax = p.subplots()
    labs = [
        'Avg_AllPass', 'Avg_P2P', 'LastMax_TraceBk', 'Max_EachStgP2P',
        'LastMax_Trace_Nbhd', 'Avg_P2P_PassOnly'
    ]
    alpha = [1, 1, 1, .5, 1, 1]
    ls = ['-', '--', '-', '-', '--', '-', '--']
    proj = 'TTGM-{}_FS19SS6'.format(expt)
    dmean = n.genfromtxt('../{}/mean.dat'.format(proj))[:, -1]
    dmax = n.genfromtxt('../{}/MaxPt.dat'.format(proj), delimiter=',')[:, 10]
    # [0-4]AvgF-Passing-VM-H8-de00-01-11, [5-9]PassingP2P-VM-H8, [10-14]MaxPtTracedBack-VM-H8,
    # [15-19]MaxPtEachStage-VM-H8, [20-24]MaxPtTrace/NbhdFavg, [25-29]
    X = n.genfromtxt(
        '../{}/IncrementalAnalysis/OldFilteringResults.dat'.format(proj),
        delimiter=',')
    if expt in ['18', 18]:
        dr = n.genfromtxt('../{}/disp-rot.dat'.format(proj), delimiter=',')[:,
                                                                            4]
        xlab = '$\\delta/\\mathsf{L}$'
    else:
        dr = n.genfromtxt('../{}/disp-rot.dat'.format(proj), delimiter=',')[:,
                                                                            5]
        xlab = '$\\Phi$'
    for i in [2]:
        ax.plot(dr, X[:, i * 5], label='Incremental\nTracedBack')
    ax.plot(dr, dmax, label='STK16')
    ax.set_xlabel(xlab)
    ax.set_ylabel('e$_\\mathsf{e}$')
    f.ezlegend(ax, loc=2, title='TTGM-{} Max Values'.format(expt))
    ax.axis(xmin=0, ymin=0)
    f.myax(ax)

    fig2, ax2 = p.subplots()
    ax2.plot(-2 * X[:, 13], X[:, 14])
    ax2.set_xlabel('2e$_{\\theta\\mathsf{x}}$')
    ax2.set_ylabel('e$_\\mathsf{xx}$')
    f.eztext(ax2, 'TTGM-{} Max Values'.format(expt), 'ul')
    f.myax(ax2)
    p.show()
def SetStrainpaths(Mean=True, Max=False):
    '''
    Plot axial vs shear strain (mean or max) for all expts)
    '''
    ex = n.genfromtxt('../ExptSummary.dat', delimiter=',')
    ex = ex[ex[:, 3].argsort()][::-1]
    ex = ex[(ex[:, 3] != 0)]
    alp = ex[:, 3]
    ex = ex[:, 0].astype(int)
    p.style.use('mysty')
    fig, ax = p.subplots()
    for k, (x, a) in enumerate(zip(ex, alp)):
        proj = 'TTGM-{}_FS19SS6'.format(x)
        LL = n.genfromtxt('../{}/prof_stages.dat'.format(proj),
                          delimiter=',',
                          dtype=int)[3]
        # [0-5]Mean VM-H8-Anis-de00-01-00, [6-11]Max VM-H8-Anis-de00-01-00, [12-13]Mean, max Classic LEp
        D = n.genfromtxt(
            '../{}/IncrementalAnalysis/NewFilterResults_3med.dat'.format(proj),
            delimiter=',')
        D[:, [4, 10]] *= -1
        if n.isnan(a):
            a = '$\\infty$'
        line, = p.plot(D[:, 4], D[:, 5], label='{}'.format(a))
        LLmark, = p.plot(D[LL, 4], D[LL, 5], 'rs')
        if Max:
            maxline, = p.plot(D[:, 10],
                              D[:, 11],
                              color=line.get_color(),
                              alpha=0.3)
            maxmark, = p.plot(D[LL, 10], D[LL, 11], 'rs', alpha=0.3)
        if not Mean:
            maxline.set_alpha(1)
            maxmark.set_alpha(1)
            maxline.set_label(line.get_label())
            line.remove()
            LLmark.remove()
    ax.axis(xmin=-.02, ymin=0)
    ax.set_xlabel('e$_{\\theta\\mathsf{x}}$')
    ax.set_ylabel('e$_\\mathsf{xx}$')
    f.ezlegend(ax,
               title='Mean' * Mean + '\n' * (Max & Mean) + 'Max' * Max,
               loc=0)
    f.myax(ax)
    p.show()
def PlotAllEeqRot(expt=24, ij=None, kelin=False):
    '''
    Plots every maxima's eeq vs rot
    '''
    proj = 'TTGM-{}_FS19SS6'.format(expt)
    dr = n.genfromtxt('../{}/disp-rot.dat'.format(proj), delimiter=',')[:, 5]
    # [0]Index_x [1]Index_y [2,3,4]Undef_X,Y,Z inches
    # [5,6,7]Def_X,Y,Z inches [8,9,10,11]DefGrad (11 12 21 22)
    # [12,13,14,15,16,17] e00, e01, e11, eeqVM, eeqH8, eeqAnis
    d = n.load(
        '../{}/IncrementalAnalysis/NewFilterPassingPoints_3med.npy'.format(
            proj))
    locmax = d[-1, :, 15].argmax()
    p.style.use('mysty')
    fig, ax = p.subplots()
    p.plot(dr, d[:, :, 15], alpha=0.2)
    p.plot(dr,
           d[:, locmax, 15],
           'k',
           label='Max ({},{})'.format(*d[-1, locmax, :2].astype(int)))
    p.plot(dr, d[:, :, 15].mean(axis=1), 'k--', label='Mean')
    if ij is not None:
        try:
            loc = n.nonzero((d[-1, :, 0] == ij[0])
                            & (d[-1, :, 1] == ij[1]))[0][0]
            p.plot(dr, d[:, loc, 15], 'r', label='({},{})'.format(*ij))
        except IndexError:
            d = n.load(
                '../{}/IncrementalAnalysis/PointsInLastWithStrains.npy'.format(
                    proj))
            loc = n.nonzero((d[0, :, 0] == ij[0])
                            & (d[0, :, 1] == ij[1]))[0][0]
            ee = []
            for i in range(d.shape[0]):
                ee.append(d[i, loc, 15])
            p.plot(dr, ee, 'r', label='({},{}) (no pass)'.format(*ij))
    if kelin and (expt in [1, 4, 5]):
        cols = {4: (0, 1), 1: (2, 3), 5: (4, 5)}
        s = read_excel('../Misc/KelinSim.xlsx', parse_cols=cols[expt]).values
        p.plot(s[:, 0], s[:, 1], 'b', label='Anal Anis')
    ax.axis(xmin=0, ymin=0)
    ax.set_xlabel('$\\Phi$')
    ax.set_ylabel('e$_\\mathsf{e}$')
    f.ezlegend(ax, loc=2, hl=2, title='TTGM-{}'.format(expt))
    f.myax(ax)
def YldLocusPlot():
    p.style.use('mysty')
    fig = p.figure(figsize=(8, 8))
    ax = fig.add_axes([.125, .125, .75, .75])
    anx, any = CalContour(close=True).T
    hx, hy = CalContour(coefs=1, a=8, close=True).T
    vx, vy = CalContour(coefs=1, a=2, close=True).T
    ax.plot(vx, vy, label='VM')
    ax.plot(hx, hy, label='H8')
    ax.plot(anx, any, label='Anis')
    ax.plot([0, 1.2], [0, 1.2], 'k--', alpha=0.2)
    ax.set_xlabel('$\\tau_\\mathsf{x}/\\tau_o$')
    ax.set_ylabel('yo')
    ax.set_ylabel('$\\frac{\\tau_\\theta}{\\tau_o}$')
    import figfun as f
    f.ezlegend(ax, loc=2)
    ax.set_title("Kelin's Calibration")
    f.myax(ax, autoscale=.9)
def PlotAllOldFilters(expt):
    p.style.use('mysty-sub')
    labs = [
        'Avg_AllPass', 'Avg_P2P', 'LastMax_TraceBk', 'Max_EachStgP2P',
        'LastMax_Trace_Nbhd', 'Avg_P2P_PassOnly'
    ]
    alpha = [1, 1, 1, .5, 1, 1]
    ls = ['-', '--', '-', '-', '--', '-', '--']
    proj = 'TTGM-{}_FS19SS6'.format(expt)
    dmean = n.genfromtxt('../{}/mean.dat'.format(proj))[:, -1]
    dmax = n.genfromtxt('../{}/MaxPt.dat'.format(proj))[:, 10]
    X = n.genfromtxt(
        '../{}/IncrementalAnalysis/OldFilteringResults.dat'.format(proj),
        delimiter=',')
    if expt in ['18', 18]:
        dr = n.genfromtxt('../{}/disp-rot.dat'.format(proj), delimiter=',')[:,
                                                                            4]
        xlab = '$\\delta/\\mathsf{L}$'
    else:
        dr = n.genfromtxt('../{}/disp-rot.dat'.format(proj), delimiter=',')[:,
                                                                            5]
        xlab = '$\\Phi$'
    fig, ax1, ax2 = f.make21()
    for i in [0, 1, 5]:
        ax1.plot(dr, X[:, i * 5], label=labs[i], alpha=alpha[i], ls=ls[i])
    ax1.plot(dr, dmean, 'k--', label='Old')
    ax1.set_xlabel(xlab)
    ax1.set_ylabel('e$_\\mathsf{e}$')
    f.ezlegend(ax1, loc=2, title='Mean Values')
    ax1.axis(xmin=0, ymin=0)
    f.myax(ax1)

    for i in [2, 3, 4]:
        ax2.plot(dr, X[:, i * 5], label=labs[i], alpha=alpha[i], ls=ls[i])
    ax2.plot(dr, dmax, 'k--', label='Old')
    ax2.set_xlabel(xlab)
    ax2.set_ylabel('e$_\\mathsf{e}$')
    f.ezlegend(ax2, loc=2, title='Max Values')
    ax2.axis(xmin=0, ymin=0)
    f.myax(ax2)
    p.show()
def SetStrainpaths(Mean=True,
                   Max=False,
                   corners=False,
                   corneronly=False,
                   export=False):
    '''
    Plot axial vs shear strain (mean or max) for all expts)
    '''
    key = n.genfromtxt('../ExptSummary.dat', delimiter=',')
    if corneronly:
        corners = True
        corneralphas = n.unique(key[n.in1d(key[:, 1], [1, 2])][:, 3])
        key = key[n.in1d(key[:, 3], corneralphas)]
    if not corners:
        key = key[key[:, 1] == 0]
    key = key[key[:, 3].argsort()][::-1]
    key = key[(key[:, 3] != 0)]
    alp = key[:, 3]
    ex = key[:, 0].astype(int)
    extype = key[:, 1].astype(int)
    p.style.use('mysty')
    fig, ax = p.subplots()
    for k, (x, a, xt) in enumerate(zip(ex, alp, extype)):
        proj = 'TTGM-{}_FS19SS6'.format(x)
        LL = n.genfromtxt('../{}/prof_stages.dat'.format(proj),
                          delimiter=',',
                          dtype=int)[3]
        # [0-5]Mean VM-H8-Anis-de00-01-00, [6-11]Max VM-H8-Anis-de00-01-00, [12-13]Mean, max Classic LEp
        D = n.genfromtxt(
            '../{}/IncrementalAnalysis/NewFilterResults_3med.dat'.format(proj),
            delimiter=',')
        D[:, [4, 10]] *= -1
        labeladd = [
            '', '($\\Sigma\\rightarrow\\mathcal{{T}}$)',
            '($\\mathcal{{T}}\\rightarrow\\Sigma$)'
        ]
        if n.isnan(a):
            label = '$\\infty$'
        else:
            label = '{}'.format(a) + labeladd[xt]
        line, = p.plot(D[:, 4], D[:, 5], label=label)
        LLmark, = p.plot(D[LL, 4], D[LL, 5], 'rs')
        if Max:
            maxline, = p.plot(D[:, 10],
                              D[:, 11],
                              color=line.get_color(),
                              alpha=0.3)
            maxmark, = p.plot(D[LL, 10], D[LL, 11], 'rs', alpha=0.3)
        if not Mean:
            maxline.set_alpha(1)
            maxmark.set_alpha(1)
            maxline.set_label(line.get_label())
            line.remove()
            LLmark.remove()
        if export:
            if k == 0:
                import pandas as pd
                fid = pd.ExcelWriter('StrainPaths.xlsx')
                LLdat = n.empty((len(ex), D.shape[1] + 3))
                header = "MeanVM,H8,Anis,e11,e12,e22,MaxVM,H8,Anis,e11,e12,e22,MeanClasscLEp,MaxLEp".split(
                    ',')
            pd.DataFrame(D).to_excel(fid,
                                     sheet_name='Exp{} _ {}'.format(x, a),
                                     index=False,
                                     header=header)
            LLdat[k] = n.hstack(([x, a, xt], D[LL]))

    if export:
        pd.DataFrame(LLdat).to_excel(fid,
                                     sheet_name='LL',
                                     index=False,
                                     header=["Exp", "Alpha",
                                             "ExpType"].extend(header))
        fid.save()

    ax.axis(xmin=-.02, ymin=0)
    ax.set_xlabel('e$_{\\theta\\mathsf{x}}$')
    ax.set_ylabel('e$_\\mathsf{xx}$')
    f.ezlegend(ax,
               title='Mean' * Mean + '\n' * (Max & Mean) + 'Max' * Max,
               loc=0)
    f.myax(ax)
    p.show()
def PlotStrainPaths(expt, ij=None, stndef=None, eq=False):
    '''
    Plots all new passing points incr. strain paths.
    Also highlights the max and mean.
    if ij is not None, then it will plot a given ij point's path
    '''
    proj = 'TTGM-{}_FS19SS6'.format(expt)
    # [0]Index_x [1]Index_y [2,3,4]Undef_X,Y,Z inches
    # [5,6,7]Def_X,Y,Z inches [8,9,10,11]DefGrad (11 12 21 22)
    # [12,13,14,15,16,17] e00, e01, e11, eeqVM, eeqH8, eeqAnis
    d = n.load(
        '../{}/IncrementalAnalysis/NewFilterPassingPoints_3med.npy'.format(
            proj))
    maxloc = d[-1, :, 15].argmax()
    maxij = d[-1, maxloc, :2].astype(int)
    # [0-5]Mean VM-H8-Anis-de00-01-11, [6-11]Max VM-H8-Anis-de00-01-00, [12-13]Mean, max Classic LEp
    maxp = n.genfromtxt(
        '../{}/IncrementalAnalysis/NewFilterResults_3med.dat'.format(proj),
        delimiter=',')
    p.style.use('mysty')
    fig, ax = p.subplots()
    if expt in [18, '18']:
        col = 12
    else:
        col = 13
    if ij is not None:
        loc = n.nonzero((d[-1, :, 0] == ij[0]) & (d[-1, :, 1] == ij[1]))[0][0]
    if stndef not in ['Haltom', 'Aramis']:
        if eq == True:
            # Plots hoops strain vs gamma instead
            d[:, :, 12:15] = d[:, :, [14, 13, 12]]
            maxp[:, [5, 10]] = maxp[:, [2, 7]]
        [
            p.plot(-2 * d[:, i, col], d[:, i, 14], alpha=0.3)
            for i in range(d.shape[1])
        ]
        p.plot(-2 * maxp[:, col - 3],
               maxp[:, 11],
               'k',
               label='Max ({},{})'.format(*maxij))
        p.plot(-2 * maxp[:, col - 9], maxp[:, 5], 'k--', label='Mean')
        if ij is not None:
            p.plot(-2 * d[:, loc, col],
                   d[:, loc, 14],
                   'r',
                   label='{:.0f},{:.0f}'.format(*ij))
    elif stndef == 'Haltom':
        [
            p.plot(-n.arctan2(d[:, i, 9], d[:, i, 11]),
                   d[:, i, 11] - 1,
                   alpha=0.5) for i in range(d.shape[1])
        ]
        p.plot(-n.arctan2(d[:, maxloc, 9], d[:, maxloc, 11]),
               d[:, maxloc, 11] - 1,
               'k',
               label='Max ({},{})'.format(*maxij))
        p.plot(-n.arctan2(d[:, :, 9], d[:, :, 11]).mean(axis=1),
               d[:, :, 11].mean(axis=1) - 1,
               'k--',
               label='Mean')
        if ij is not None:
            p.plot(-n.arctan2(d[:, loc, 9], d[:, loc, 11]),
                   d[:, loc, 11] - 1,
                   'r',
                   label='{:.0f},{:.0f}'.format(*ij))
    elif stndef == 'Aramis':
        tempG = n.empty(d.shape[:2])
        tempNEy = n.empty_like(tempG)
        for i in range(d.shape[1]):
            lep, NEx, NExy, NEy = LEp(d[:, i, 8], d[:, i, 9], d[:, i, 10],
                                      d[:, i, 11], True)
            NEx -= 1
            NEy -= 1
            G = -n.arctan(NExy / (1 + NEx)) - n.arctan(NExy / (1 + NEy))
            tempG[:, i] = G
            tempNEy[:, i] = NEy
            p.plot(G, NEy, alpha=0.5)
        p.plot(tempG[:, maxloc],
               tempNEy[:, maxloc],
               'k',
               label='Max ({},{})'.format(*maxij))
        p.plot(tempG.mean(axis=1), tempNEy.mean(axis=1), 'k--', label='Mean')
        if ij is not None:
            p.plot(tempG[:, loc],
                   tempNEy[:, loc],
                   'r',
                   label='{:.0f},{:.0f}'.format(*ij))
    if expt not in [18, '18', 31, '31']:
        p.axis(xmin=0, ymin=0)
    ax.set_xlabel('2e$_{\\theta\\mathsf{x}}$')
    ax.set_ylabel('e$_\\mathsf{xx}$')
    f.ezlegend(ax, loc=2, hl=2, title='TTGM-{}'.format(expt))
    f.myax(ax)
    p.show()
    return fig, ax
                  sheetname='FailureStrain',
                  index_col='Expt')

x[0] = read_excel('../../../../AAA_TensionTorsion/TT2_SetData.xlsx',
                  sheetname='FailureStrain',
                  index_col='Expt')
x[0].drop(17, inplace=True)

fig, ax1, ax2 = f.make21()

labs = ['GM', 'TT2'][::-1]
marks = 'o', '^'
for k, d in enumerate(x):
    ax1.plot(d.Triax.values, d['VM-Mean'].values, marks[k], label=labs[k])
    ax2.plot(d.Triax.values, d['VM-Max'].values, marks[k], label=labs[k])

ax1.set_ylabel('$\\bar{e}_e^f$')
ax2.set_ylabel('$e_e^f$')
f.eztext(ax1, 'Mean', 'ur')
f.eztext(ax2, 'Max', 'ur')

for ax in [ax1, ax2]:
    f.eztext(ax, '3D DIC\nAl 6061-T6', 'll')
    f.ezlegend(ax, markers=True)
    ax.set_xlabel('$\\sigma_m/\\sigma_e$')
    ax.axis([0, 0.6, 0, 1.8])
    f.myax(ax)

p.savefig('CompareGMTT2.png', dpi=125)
p.show()
    def fun(b, a):
        return wrapped(a, b)

    for j, i in enumerate(als):
        #betas[j,z] = so.newton(fun,1,args=(i,))
        betas[j, z] = so.brentq(fun, 0.3, 1, args=(i, ))

import figfun as f
p.style.use('mysty')
fig, ax = p.subplots()
for i in range(z + 1):
    label = labels[i].upper() + '\n$\\beta_\\infty$={:.2f}'.format(betas[-1,
                                                                         i])
    p.plot(als[:-1], betas[:-1, i], label=label)

p.xlabel('$\\alpha$')
p.ylabel('$\\beta$')
f.ezlegend(ax)
f.eztext(ax, 'Al 6061-T6\n$\\mathsf{d}\\epsilon_\\mathsf{11}=\\mathsf{0}$',
         'ur')
f.myax(ax)
p.savefig('PlaneStn_YldFun.pdf')
p.show()

n.savetxt('PlaneStn_YldFun.dat',
          fmt='%.6f',
          delimiter=',',
          X=n.c_[als, betas],
          header='[0]Alpha, [1]VM, [2]H8, [3]Anis')
예제 #14
0
fig, ax1, ax2 = f.make12()

α = n.empty(1000)
α[:-50] = n.linspace(0.0, 8, 950)
α[-50:] = n.linspace(8, 20, 50)
η = α / n.sqrt(12 + 3 * α**2)

ax1.plot(η,
         plot_HC(res.x, α, constit),
         label=('{}\n$\\sigma_c$,a,c\n' + '{:.3f}\n' * 3).format(
             constit, *res.x))
ax1.plot(d.Triax, sts, 'o')
ax1.set_xlabel('$\\sigma_m/\\sigma_e$')
ax1.set_ylabel('$\\sigma_e^f$')
f.ezlegend(ax1)

eef_pred = interp1d(mat[:, 1], mat[:, 0], fill_value='extrapolate').__call__(
    plot_HC(res.x, α, constit))
ax2.plot(η, eef_pred)
ax2.axis([0, .6, 0, 2])
ax2.set_xlabel('$\\sigma_m/\\sigma_e$')
ax2.set_ylabel('$e_e^f$')
ax2.plot(d.Triax, d.efmn, 'o')

[f.myax(x) for x in (ax1, ax2)]

fig.savefig('Failure_HC_{}'.format(constit), dpi=125)

# First load up the failure data
p.figure()
    'Avg_AllPass', 'Avg_P2P', 'LastMax_TraceBk', 'Max_EachStgP2P',
    'LastMax_Trace_Nbhd', 'Avg_P2P_PassOnly'
]
alpha = [1, 1, 1, .5, 1, 1]
ls = ['-', '--', '-', '-', '--', '-', '--']

dmean = n.genfromtxt('../{}/mean.dat'.format(proj))[:, -1]
dmax = n.genfromtxt('../{}/MaxPt.dat'.format(proj))[:, 10]

fig, ax1, ax2 = f.make21()
for i in [0, 1, 5]:
    ax1.plot(dr, X[:, i * 5], label=labs[i], alpha=alpha[i], ls=ls[i])
ax1.plot(dr, dmean, 'k--', label='Old')
ax1.set_xlabel(xlab)
ax1.set_ylabel('e$_\\mathsf{e}$')
f.ezlegend(ax1, loc=2, title='Mean Values')
ax1.axis(xmin=0, ymin=0)
f.myax(ax1)

for i in [2, 3, 4]:
    ax2.plot(dr, X[:, i * 5], label=labs[i], alpha=alpha[i], ls=ls[i])
ax2.plot(dr, dmax, 'k--', label='Old')
ax2.set_xlabel(xlab)
ax2.set_ylabel('e$_\\mathsf{e}$')
f.ezlegend(ax2, loc=2, title='Max Values')
ax2.axis(xmin=0, ymin=0)
f.myax(ax2)

p.savefig('../{0}/IncrementalAnalysis/OldFilteringResults.png'.format(proj),
          dpi=125)
p.close()