コード例 #1
0
ファイル: load.py プロジェクト: lavanova/esc499_thesis
def load(rfl, testper = 0.08, verbose = 0, traindataname = 'traindata', testdataname = 'testdata'):
    a = []
    for rfn in rfl:
        b = readraytracerout(rfn, verbose = verbose, indice = [2,3,4,5,6])
        if a == []:
            a = b
        else:
            a = np.append(a,b,axis=0)

    # inputs
    ty = a[:,1]
    ty1 = ty + 15
    ty2 = 15 - ty
    tz = a[:,2]
    rx = a[:,3]
    ry = a[:,4]
    ry1 = ry + 15
    ry2 = 15 - ry
    rz = a[:,5]
    # +2 relationship
    y = a[:,10] # result in dB
    muB = a[:,12]
    muS = a[:,13]
    stdB = a[:,14]
    stdS = a[:,15]
    width = a[:,16]

    dg = np.sqrt( (ty - ry) ** 2 + (tz-rz) ** 2 + rx ** 2)
    dl = np.sqrt( (ty1 - ry1) ** 2 + (tz-rz) ** 2 + rx ** 2 )
    dr = np.sqrt( (ty2 - ry2) ** 2 + (tz-rz) ** 2 + rx ** 2 )
    lty1, lty2, lry1, lry2 = np.log10([ty1,ty2,ry1,ry2])
    ltz, lrz, lrx, ldg, ldl, ldr = np.log10([tz,rz,rx,dg,dl,dr])
    muB = np.log10(muB)
    muS = np.log10(muS)
    width = np.log10(width)

    #[lty1,lty2,lrx,ltz,lry1,lry2,lrz,ldg,ldl,ldr, muB,muS,stdB,stdS]

    #normalize([lty1,lty2,lrx,ltz,lry1,lry2,lrz,ldg,ldl,ldr, muB,muS,stdB,stdS])
    x = np.stack((lty1,lty2,lrx,ltz,lry1,lry2,lrz,ldg,ldl,ldr, muB,muS,stdB,stdS))

    x = x.T
    y = -y

    xtrain, ytrain, xtest, ytest = seperate_test_set(x,y,testper)
    traindata = mydata(xtrain,ytrain,traindataname)
    testdata = mydata(xtest,ytest,testdataname)
    print("LOAD: Training data size is: ", ytrain.size)
    print("LOAD: Testing data size is: ", ytest.size)
    print("LOAD: One sample of the data is:\n")
    print(str(xtrain[10]) + '      '   + str(ytrain[10]))

    traindata.save()
    testdata.save()
    print("LOAD: Saved traindata to ./data/" + traindataname)
    print("LOAD: Saved testdata to ./data/" + testdataname)
    return 0
コード例 #2
0
ファイル: load.py プロジェクト: lavanova/esc499_thesis
def load5in(rfl,
            testper=0.08,
            verbose=0,
            traindataname='traindata',
            testdataname='testdata'):
    a = []
    for rfn in rfl:
        a = readraytracerout(rfn, verbose=verbose)
    h1r = a[:, 2]  # height of the source
    d = a[:, 3]  # distance
    h2r = a[:, 5]  # height of the receiver
    y = a[:, 8]  # result in dB

    #d = np.sqrt(d*d+(h1-h2)*(h1-h2))
    d = np.log10(d)
    h1 = np.log10(h1r)
    h2 = np.log10(h2r)

    #normalize everything
    dmean = np.mean(d)
    h1mean = np.mean(h1)
    h2mean = np.mean(h2)
    h1rmean = np.mean(h1r)
    h2rmean = np.mean(h2r)

    dstd = np.std(d)
    h1std = np.std(h1)
    h2std = np.std(h2)
    h1rstd = np.std(h1r)
    h2rstd = np.std(h2r)

    # correct variance:
    # d = (d - dmean) / dstd
    # h1 = (h1 - h1mean) / h1std
    # h2 = (h2 - h2mean) / h2std
    # h1r = (h1r - h1rmean) / h1rstd
    # h2r = (h2r - h2rmean) / h2rstd

    #x = np.stack((h1,h2,d))
    x = np.stack((h1, h2, d, h1r, h2r))
    exp1 = 40 * d - 20 * h1 - 20 * h2
    x = x.T
    y = -y

    xtrain, ytrain, xtest, ytest = seperate_test_set(x, y, testper)
    traindata = mydata(xtrain, ytrain, traindataname)
    testdata = mydata(xtest, ytest, testdataname)
    print("LOAD: Training data size is: ", ytrain.size)
    print("LOAD: Testing data size is: ", ytest.size)
    print("LOAD: One sample of the data is:\n")
    print(str(xtrain[1]) + '      ' + str(ytrain[1]))

    traindata.save()
    testdata.save()
    print("LOAD: Saved traindata to ./data/" + traindataname)
    print("LOAD: Saved testdata to ./data/" + testdataname)
    return 0
コード例 #3
0
ファイル: load.py プロジェクト: lavanova/esc499_thesis
def load(rfl,
         testper=0.08,
         verbose=0,
         traindataname='traindata',
         testdataname='testdata'):
    a = []
    for rfn in rfl:
        a = readraytracerout(rfn, verbose=verbose)
    h1 = a[:, 2]  # height of the source
    d = a[:, 3]  # distance
    h2 = a[:, 5]  # height of the receiver
    y = a[:, 8]  # result in dB

    if verbose:
        freq = a[:, -3]
        epsilon = a[:, -2]
        sigma = a[:, -1]

    d = np.sqrt(d * d + (h1 - h2) * (h1 - h2))
    d = np.log10(d)
    h1 = np.log10(h1)
    h2 = np.log10(h2)

    dstd = np.std(d)
    h1std = np.std(h1)
    h2std = np.std(h2)
    print("Std. of d is: ", dstd)
    print("Std. of h1 is: ", h1std)
    print("Std. of h2 is: ", h2std)
    # correct variance:
    h1cor = dstd / h1std
    h2cor = dstd / h2std
    #h1 = h1*h1cor
    #h2 = h2*h2cor

    exp1 = 40 * d - 20 * h1 - 20 * h2

    x = np.stack((h1, h2, d))
    #x = np.stack((h1,h2,d))
    x = x.T
    y = -y

    xtrain, ytrain, xtest, ytest = seperate_test_set(x, y, testper)
    traindata = mydata(xtrain, ytrain, traindataname)
    testdata = mydata(xtest, ytest, testdataname)
    print("LOAD: Training data size is: ", ytrain.size)
    print("LOAD: Testing data size is: ", ytest.size)
    print("LOAD: One sample of the data is:\n")
    print(str(xtrain[1:10]) + '      ' + str(ytrain[1]))

    traindata.save()
    testdata.save()
    print("LOAD: Saved traindata to ./data/" + traindataname)
    print("LOAD: Saved testdata to ./data/" + testdataname)
    return 0
コード例 #4
0
ファイル: load.py プロジェクト: lavanova/esc499_thesis
def load(rfl,
         testper=0.08,
         verbose=0,
         traindataname='traindata',
         testdataname='testdata'):
    a = []
    for rfn in rfl:
        a = readraytracerout(rfn, verbose=verbose)

    # inputs
    ty = a[:, 1]
    ty1 = ty + 15
    ty2 = 15 - ty
    tz = a[:, 2]
    rx = a[:, 3]
    ry = a[:, 4]
    ry1 = ry + 15
    ry2 = 15 - ry
    rz = a[:, 5]

    dg = np.sqrt((ty - ry)**2 + (tz - rz)**2 + rx**2)
    dl = np.sqrt((ty1 - ry1)**2 + (tz - rz)**2 + rx**2)
    dr = np.sqrt((ty2 - ry2)**2 + (tz - rz)**2 + rx**2)

    lty1, lty2, lry1, lry2 = np.log10([ty1, ty2, ry1, ry2])
    ltz, lrz, lrx, ldg, ldl, ldr = np.log10([tz, rz, rx, dg, dl, dr])

    # outputs
    y = a[:, 10]

    # normalize
    #means, stds = normalize([lty1,lty2,lrx,ltz,lry1,lry2,lrz,ldg,ldl,ldr])
    x = np.stack((lty1, lty2, lrx, ltz, lry1, lry2, lrz, ldg, ldl, ldr))

    #x = np.stack((h1,h2,d))
    x = x.T
    y = -y

    xtrain, ytrain, xtest, ytest = seperate_test_set(x, y, testper)
    traindata = mydata(xtrain, ytrain, traindataname)
    testdata = mydata(xtest, ytest, testdataname)
    print("LOAD: Training data size is: ", ytrain.size)
    print("LOAD: Testing data size is: ", ytest.size)
    print("LOAD: One sample of the data is:\n")
    print(str(xtrain[1]) + '      ' + str(ytrain[1]))

    traindata.save()
    testdata.save()
    print("LOAD: Saved traindata to ./data/" + traindataname)
    print("LOAD: Saved testdata to ./data/" + testdataname)
    return 0
コード例 #5
0
    result = mlp3L('model3L0',testmode = 1, mlp_ninput = 10, epochs = 10000, breaklim = 18, plot = 0,
    mlp_learning_rate = 0.06, traindata = 'uctrainsetr1', testdata = dataname,
    plotrangel = 150, plotrangeh = 200, mlp_nbatchs = 5,
    mlp_nhidden1 = 50, mlp_nhidden2=30, mlp_nhidden3=20, plotTitle = '900MHz urban canyon model', normalize = True);
    # linear fit
    #print(result[0])
    combined = list(zip(xlist, result[0]))
    combined.sort()
    xlist, result[0] = zip(*combined)

    # get raytracer result
    xray = dump_main(rxfn = 'ucpl_rx_pts.txt', txfn = 'ucpl_tx_pts.txt',
    envfn = 'env_urbancanyon.txt', ty = ty, tz = tz, ry = ry, rz = rz)
    execute_main()
    a = readraytracerout('plresult', verbose=0)
    yray = -a[:,11]

    combined = list(zip(xray, yray))
    combined.sort()
    xray, yray = zip(*combined)


    regr = linear_model.LinearRegression()
    regr.fit(xlist, result[0])
    yfit = regr.predict(xlist)
    plt.suptitle('Urban canyon path loss curve')
    plt.xlabel('log10(x)')
    plt.ylabel('negative signal strength in db')
    plt.plot(xlist,result[0],'b',xlist,yfit,'y',xray,yray,'r')
    plt.legend(['Predicted','Linear fit','Raytracer'])