Ejemplo n.º 1
0
def plotrefdepx(axfiles, lam):
    bands = read_data.getband()
    fontsize = 18
    matplotlib.rcParams.update({'font.size': fontsize})
    fig = plt.figure(figsize=(7, 3))
    ax = fig.add_subplot(111)
    lss = ["dashed", "dashed", "dashed", "solid", "solid", "dotted", "dotted"]
    for i in [0, 4, 6]:
        axfile = axfiles[i]
        A, X, resall = read_data.readax(axfile)
        print(lam[i])
        plref_each(X, bands, lss[i], "$\lambda_X=10^{" + str((lam[i])) + "}$")
    plt.ylabel("Unmixed Spectra", fontsize=16)
    plt.xlabel("wavelength [micron]", fontsize=16)
    plt.legend(fontsize=13)
    plt.savefig("refdep.pdf", bbox_inches="tight", pad_inches=0.0)
    plt.show()
Ejemplo n.º 2
0
def plot_rega(axfiles):
    NN = 2435 * 7.
    #    NN=1
    lcmean = 107.40646786191814
    mrarr = []
    mrsaarr = []
    likarr = []
    detxn = []
    for i, axfile in enumerate(axfiles):
        A, X, resall = read_data.readax(axfile)
        Aclass = diffclass.mclassmap(A)
        mr = diffclass.classdif(Aclass)
        AFnorm = np.sqrt(np.sum(A * A))
        mrarr.append(mr)
        likarr.append(resall[-1][1])
        Xn = np.copy(X)
        for k in range(0, np.shape(X)[0]):
            Xn[k, :] = X[k, :] / np.sum(X[k, :])
        detxn.append(np.linalg.det(np.dot(Xn, Xn.T)))  #/10**lam[i])

    likarr = np.array(likarr)
    detxn = np.array(detxn)

    fontsize = 18
    matplotlib.rcParams.update({'font.size': fontsize})
    fig = plt.figure(figsize=(7, 5))
    ax = fig.add_subplot(211)
    ax.plot(10**lam, np.sqrt(likarr / NN) / lcmean, "o", color="C0")
    ax.plot(10**lam, np.sqrt(likarr / NN) / lcmean, color="C0")
    plt.xscale("log")
    plt.ylabel("mean residual")
    ax = fig.add_subplot(212)
    plt.xscale("log")
    #    plt.yscale("log")
    #    ax.plot(10**lam,(absa),"o",)
    ax.plot(10**lam, (detxn), "o", color="C0")
    ax.plot(10**lam, (detxn), color="C0")
    plt.ylabel("$\det{(\hat{X} \hat{X}^T)}$")
    plt.xlabel("$\lambda_A$")
    plt.savefig("regad.pdf", bbox_inches="tight", pad_inches=0.1)
    plt.show()
Ejemplo n.º 3
0
def plotrefdirect(axfiles, lam):
    bands = read_data.getband()
    fontsize = 18
    matplotlib.rcParams.update({'font.size': fontsize})
    fig = plt.figure(figsize=(8, 5.5))
    ax = fig.add_subplot(111)
    cloud, cloud_ice, snow_fine, snow_granular, snow_med, soil, veg, ice, water, clear_sky = io_refdata.read_refdata(
        "/home/kawahara/exomap/sot/data/refdata")
    nnl = 1  #len(np.median(bands,axis=1))
    u, val, normvveg = pm.norm(veg)
    #    ax.plot(u,val,c="gray",lw=2,label="vegitation (deciduous)")
    ax.plot(u, val, c="gray", lw=2)
    u, val, normvsoil = pm.norm(soil)
    ax.plot(u, val, c="gray", lw=2, ls="dashed")
    #    ax.plot(u,val,c="gray",lw=2,ls="dashed",label="soil")
    u, val, normvwater = pm.norm(water)
    ax.plot(u, val, c="gray", lw=2, ls="-.")

    #    ax.plot(u,val,c="gray",lw=2,ls="-.",label="water")

    lss = ["dashed", "solid", "dotted", "dashdot"]
    sy = [False, True, False]
    for i in range(0, 3):
        axfile = axfiles[i]
        A, X, resall = read_data.readax(axfile)
        mmrsa = mrsa.mrsa_meanX(X)
        print(mmrsa)
        print(lam[i])

        metric.plref_each(X,
                          bands,
                          lss[i],
                          "$\lambda_X=10^{" + str(int(lam[i])) + "}$",
                          symbol=sy[i])
    plt.ylim(0, 0.6)
    plt.ylabel("Unmixed Spectra", fontsize=16)
    plt.xlabel("wavelength [micron]", fontsize=16)
    plt.legend(fontsize=13)
    plt.savefig("refdirect.pdf", bbox_inches="tight", pad_inches=0.0)
    plt.show()
Ejemplo n.º 4
0
#        ax.plot(pred[:,i])
    plt.savefig("lc.pdf", bbox_inches="tight", pad_inches=0.0)
    plt.show()

if __name__ == '__main__':
    import sys
    #    axfile="npz/T116/T116_L2-VRLD_A-2.0X4.0j99000.npz"
    #    theme="dscovr"
    theme = "3c"
    axfile = sys.argv[1]
    try:
        title = sys.argv[2]
    except:
        title = ""
    A, X, resall = read_data.readax(axfile)
    lcmean = 105.45194310301967
    lcsig = lcmean * 0.01
    print("Ln L=", resall[-1, :] / (2 * lcsig * lcsig))
    print("AIC=", 2 * resall[-1, :] / (2 * lcsig * lcsig) + 2 * (3072 * 3))

    sys.exit()
    bands = read_data.getband()
    #    bands=[[0.388,0.388],[0.443,0.443],[0.552,0.552],[0.680,0.680],[0.688,0.688],[0.764,0.764],[0.779,0.779]] #DSCOVR

    #    showpred(A,X)
    #    sys.exit()

    fontsize = 18
    matplotlib.rcParams.update({'font.size': fontsize})
    title = ""
Ejemplo n.º 5
0
    unwrap=np.array(unwrap).T
    print(np.shape(unwrap))
    return unwrap

def projpc(Xin,Xp):
    pc1=Xp[0,:]
    pc2=Xp[1,:]
    xpc1=np.dot(Xin,pc1)
    xpc2=np.dot(Xin,pc2)
    return xpc1,xpc2

if __name__=='__main__':
    import sys
    axfile="npz/T215/T215_N3_L2-VRDet_A-1.0X2.0j100000.npz"

    A,X,resall=read_data.readax(axfile)
    W=np.load("w512.npz")["arr_0"]
    WA=np.dot(W,A)
    lcall=np.load("lcallN0.01.npz")["arr_0"]

   
    for i in range(0,np.shape(lcall)[1]):
        lcall[:,i]=lcall[:,i]/np.sum(WA,axis=1)
#        lcall[:,i]=lcall[:,i]/np.sum(Ad,axis=1)

    pca = PCA(n_components=2)
    pca.fit(lcall) #x(k,l)
    Xp=((pca.components_))
    xpc1,xpc2=projpc(X,Xp)
    lcpc1,lcpc2=projpc(lcall,Xp)
Ejemplo n.º 6
0
def plot_regx(axfiles):
    NN = 512 * 10
    lcmean = 105.70907195459881

    mrarr = []
    likarr = []
    detx = []
    detxn = []
    absa = []
    cpr = []
    for i, axfile in enumerate(axfiles):
        A, X, resall = read_data.readax(axfile)
        Aclass = diffclass.mclassmap(A)
        mr = diffclass.classdif(Aclass)
        cpr.append(mr)

        mmrsa = mrsa.mrsa_meanX(X)
        print("mmrsa=", mmrsa)
        AFnorm = np.sqrt(np.sum(A * A))
        mrarr.append(mmrsa)
        likarr.append(resall[-1][1])
        absa.append(resall[-1][2])
        Xn = np.copy(X)
        for k in range(0, np.shape(X)[0]):
            Xn[k, :] = X[k, :] / np.sum(X[k, :])
        detxn.append(np.linalg.det(np.dot(Xn, Xn.T)))  #/10**lam[i])
        detx.append(np.linalg.det(np.dot(X, X.T)))  #/10**lam[i])

        print(lam[i], resall[-1][1], AFnorm, mmrsa)
    likarr = np.array(likarr)
    absa = np.array(absa)
    detx = np.array(detx)
    detxn = np.array(detxn)
    cpr = np.array(cpr)

    fontsize = 18
    matplotlib.rcParams.update({'font.size': fontsize})
    fig = plt.figure(figsize=(7, 9))
    ax = fig.add_subplot(411)
    ax.plot(10**lam, np.sqrt(likarr / NN) / lcmean, "o", color="C0")
    ax.plot(10**lam, np.sqrt(likarr / NN) / lcmean, color="C0")
    plt.ylabel("mean residual")
    plt.xscale("log")
    ax = fig.add_subplot(412)
    plt.xscale("log")
    #    plt.yscale("log")
    #    ax.plot(10**lam,(absa),"o",)
    ax.plot(10**lam, (detxn), "o", color="C0")
    ax.plot(10**lam, (detxn), color="C0")
    #    ax.plot(10**lam,(detxn)*1000,color="C0")
    plt.ylabel("$\det{(\hat{X} \hat{X}^T)}$")
    #    plt.ylabel("$\det{({X} {X}^T)}$")

    #    plt.ylabel("$||D - W A X||_F^2$")
    ax = fig.add_subplot(413)
    ax.plot(10**lam, mrarr, "o", color="C1")
    ax.plot(10**lam, mrarr, color="C1")
    plt.xscale("log")
    plt.ylabel("$\overline{MRSA}$")
    plt.ylim(0.03, 0.1)

    ax = fig.add_subplot(414)

    ax.plot(10**lam, cpr, "o", color="C1")
    ax.plot(10**lam, cpr, color="C1")
    plt.xscale("log")
    plt.ylabel("CPR")
    plt.xlabel("$\lambda_X$")
    plt.savefig("regx.pdf", bbox_inches="tight", pad_inches=0.1)
    plt.show()