コード例 #1
0
def plref(X, bands, theme, title="", oxlab=False):
    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")
    fontsize = 18
    matplotlib.rcParams.update({'font.size': fontsize})

    fig = plt.figure(figsize=(8, 5.5))
    ax = fig.add_subplot(111)
    nnl = 1  #len(np.median(bands,axis=1))
    if theme == "3c":
        u, val, normvveg = norm(veg)
        ax.plot(u, val, c="gray", lw=2, label="vegitation (deciduous)")
        u, val, normvsoil = norm(soil)
        ax.plot(u, val, c="gray", lw=2, ls="dashed", label="soil")
        u, val, normvwater = norm(water)
        ax.plot(u, val, c="gray", lw=2, ls="-.", label="water")
    else:
        normvveg = 1.0
        normvsoil = 1.0
        normvwater = 1.0
    fac = 1.0
    mband = np.median(bands, axis=1)
    dband = mband[1] - mband[0]
    if theme == "3c":
        plt.xlim(0.4, 0.9)

        fac0 = fac / np.sum(X[0, :]) / dband / normvveg
        fac1 = fac / np.sum(X[1, :]) / dband / normvsoil
        fac2 = fac / np.sum(X[2, :]) / dband / normvwater
    else:
        plt.xlim(0.3, 0.9)

        try:
            fac0 = fac / np.sum(X[0, :]) / dband
            fac1 = fac / np.sum(X[1, :]) / dband
            fac2 = fac / np.sum(X[2, :]) / dband
            fac3 = fac / np.sum(X[3, :]) / dband
        except:
            print("No 4th comp")

    if theme == "3c":
        plt.plot(np.median(bands, axis=1),
                 X[0, :] * fac0,
                 "o",
                 label="Component 0",
                 color="C2")
        plt.plot(np.median(bands, axis=1),
                 X[1, :] * fac1,
                 "s",
                 label="Component 1",
                 color="C1")
        plt.plot(np.median(bands, axis=1),
                 X[2, :] * fac2,
                 "^",
                 label="Component 2",
                 color="C0")

        try:
            plt.plot(np.median(bands, axis=1),
                     X[3, :] * fac3,
                     "^",
                     label="Component 3",
                     color="C3")
            plt.plot(np.median(bands, axis=1), X[3, :] * fac3, color="C3")
        except:
            print("No 4th comp")

        plt.plot(np.median(bands, axis=1), X[0, :] * fac0, color="C2", lw=2)
        plt.plot(np.median(bands, axis=1), X[1, :] * fac1, color="C1", lw=2)
        plt.plot(np.median(bands, axis=1), X[2, :] * fac2, color="C0", lw=2)
    elif theme == "dscovr":
        #c,o,v,l
        plt.plot(np.median(bands, axis=1),
                 X[0, :] * fac0,
                 "o",
                 label="Component 0",
                 color="gray")
        plt.plot(np.median(bands, axis=1),
                 X[1, :] * fac1,
                 "s",
                 label="Component 1",
                 color="C0")
        plt.plot(np.median(bands, axis=1),
                 X[2, :] * fac2,
                 "^",
                 label="Component 2",
                 color="C2")
        plt.plot(np.median(bands, axis=1),
                 X[3, :] * fac2,
                 "*",
                 label="Component 3",
                 color="C3")

        plt.plot(np.median(bands, axis=1), X[0, :] * fac0, color="gray", lw=2)
        plt.plot(np.median(bands, axis=1), X[1, :] * fac1, color="C0", lw=2)
        plt.plot(np.median(bands, axis=1), X[2, :] * fac2, color="C2", lw=2)
        plt.plot(np.median(bands, axis=1), X[3, :] * fac2, color="C3", lw=2)

    if oxlab:
        plt.axvline(0.688, color="blue", alpha=0.2, lw=5)
        plt.axvline(0.764, color="blue", alpha=0.2, lw=5)


#        plt.text("")
    plt.tick_params(labelsize=16)
    plt.ylabel("Reflection Spectra", fontsize=16)
    plt.xlabel("wavelength [micron]", fontsize=16)
    plt.legend(fontsize=12)
    plt.title(title)
    plt.savefig("ref.pdf", bbox_inches="tight", pad_inches=0.0)
コード例 #2
0
plt.show()
#sys.exit()
## load class map
dataclass = np.load("/home/kawahara/exomap/sot/data/cmap3class.npz")
cmap = dataclass["arr_0"]
npix = len(cmap)
nclass = (len(np.unique(cmap)))
nside = hp.npix2nside(npix)
vals = dataclass["arr_1"]
valexp = dataclass["arr_2"]
print("Nclass=", nclass)

### Set reflectivity
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")

#mean albedo between waves and wavee
#bands=[[0.4,0.5],[0.5,0.6],[0.6,0.7],[0.7,0.8],[0.8,0.9]]#,[0.9,1.0]]

refsurfaces = [water, soil, veg]
malbedo = io_surface_type.set_meanalbedo(0.8, 0.9, refsurfaces, clear_sky)
mmap, Ain, Xin = toymap.make_multiband_map(cmap, refsurfaces, clear_sky, vals,
                                           bands)
ave_band = np.mean(np.array(bands), axis=1)

cc = plt.cm.viridis
hp.mollview(A[:, 0], title="Component 0", flip="geo", cmap=cc)  #,min=0,max=1)

plt.savefig("C0.pdf", bbox_inches="tight", pad_inches=0.0)
コード例 #3
0
import healpy as hp
import sys

## load class map
dataclass=np.load("../../data/cmap3class.npz")
cmap=dataclass["arr_0"]
npix=len(cmap)
nclass=(len(np.unique(cmap)))
nside=hp.npix2nside(npix)
vals=dataclass["arr_1"]
valexp=dataclass["arr_2"]
print("Nclass=",nclass)
# ## Set reflectivity

cloud,cloud_ice,snow_fine,snow_granular,snow_med,soil,veg,ice,water,clear_sky\
=io_refdata.read_refdata("../../../data/refdata")
#mean albedo between waves and wavee
print(io_refdata.get_meanalbedo(veg,0.8,0.9),io_refdata.get_meanalbedo(veg,0.4,0.5))


bands=[[0.4,0.5],[0.5,0.6],[0.6,0.7],[0.7,0.8]]
#bands=[[0.4,0.5],[0.6,0.7],[0.8,0.9]]
#bands=[[0.4,0.5],[0.6,0.7],[0.8,0.9],[1.0,1.1]]
#bands=[[0.4,0.45],[0.45,0.5],[0.5,0.55],[0.55,0.6],[0.6,0.65],\
#       [0.65,0.7],[0.7,0.75],[0.75,0.8],[0.8,0.85],[0.85,0.9]]
if nclass==4:
    refsurfaces=[water,soil,snow_med,veg]
elif nclass==3:
    refsurfaces=[water,soil,veg]
else:
    print("Nclass should be 3 or 4 currently")
コード例 #4
0
ファイル: metric.py プロジェクト: HajimeKawahara/sot
def plref_each(X, bands, ls, lab, symbol=False):
    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)
    u, val, normvsoil = pm.norm(soil)
    u, val, normvwater = pm.norm(water)
    plt.xlim(0.4, 0.9)
    fac = 1.0
    mband = np.median(bands, axis=1)
    dband = mband[1] - mband[0]
    fac0 = fac / np.sum(X[0, :]) / dband / normvveg
    fac1 = fac / np.sum(X[1, :]) / dband / normvsoil
    fac2 = fac / np.sum(X[2, :]) / dband / normvwater
    plt.plot(np.median(bands, axis=1), X[0, :] * fac0, color="C2", lw=2, ls=ls)
    plt.plot(np.median(bands, axis=1), X[1, :] * fac1, color="C1", lw=2, ls=ls)
    plt.plot(np.median(bands, axis=1),
             X[2, :] * fac2,
             color="C0",
             lw=2,
             ls=ls,
             label=lab)
    if symbol:
        plt.plot(np.median(bands, axis=1),
                 X[0, :] * fac0,
                 "o",
                 color="C2",
                 lw=2,
                 ls=ls)
        plt.plot(np.median(bands, axis=1),
                 X[1, :] * fac1,
                 "s",
                 color="C1",
                 lw=2,
                 ls=ls)
        plt.plot(np.median(bands, axis=1),
                 X[2, :] * fac2,
                 "^",
                 color="C0",
                 lw=2,
                 ls=ls)

    plt.tick_params(labelsize=16)
コード例 #5
0
ファイル: plotdirect.py プロジェクト: HajimeKawahara/sot
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()