示例#1
0
def draw_L(type_dist):
    numHorSec = 48
    noBins = 50
    bins = np.linspace(-13, 20, noBins + 1)  #divide N scale
    logPoints = np.linspace(0, 4, numHorSec)  #divide Lmax scale
    Z = []  #no.hits 2D array - we draw this

    horSec = np.linspace(0, 4, numHorSec)
    glajenje = 0.2
    '''
    for fileNo in horSec:

        array = readData("inf"+str(fileNo))
        Z+=array
    '''
    Z = readData("infL" + str(horSec[-1]))
    Z = list(filter(lambda x: x <= np.random.normal(9.5, glajenje), Z))
    #out = fl.gaussian_filter(Z, 1)

    nV, binsV, patchesV = plt.hist(Z, 200)

    out = fl.gaussian_filter(nV, 2)

    m = np.where(out == out.max())
    m1 = binsV[m][0]

    Z = [10**x for x in Z]
    avg = sum(Z) / len(Z)
    mediana = np.median(Z)

    #print('Največja verjetnost: L = '+ str(10**m1))
    #print("Povprečje: L = " + str(10 ** avg))
    plt.cla()
    plt.plot(binsV[0:-1], out, 'red')
    plt.ylabel('frequency')
    plt.xlabel('Log(L)')
    #plt.legend(loc=1)
    plt.title('Model 3 L(N), last slice, median: ' +
              str(np.round(mediana, 2)) + " avg: " + str(np.round(avg, 2)))
    #plt.annotate('max', (m1, 0), annotation_clip=False)
    #plt.axvline(m1, color ='r', alpha = 0.5)
    #plt.axvline(avg, color='r', alpha=0.5)
    plt.show()
示例#2
0
def draw_L(type_dist):
    numHorSec = 48
    noBins = 50
    bins = np.linspace(-13, 20, noBins + 1)  #devide N scale
    logPoints = np.linspace(0, 4, numHorSec)  #devide Lmax scale
    Z = []  #no.hits 2D array - we draw this

    horSec = np.linspace(0, 4, numHorSec)

    #for fileNo in horSec:

    array = readData("inf_l_" + str(horSec[-1]))
    Z += array

    #out = fl.gaussian_filter(Z, 1)

    median = 10**np.median(Z)

    print("Median: " + str(median))

    nV, binsV, patchesV = plt.hist(Z, 200)

    # out = fl.gaussian_filter(nV, 2)

    m = np.where(nV == nV.max())
    m1 = binsV[m][0]
    Z1 = [10**i for i in Z]
    avg = sum(Z1) / len(Z1)

    print('Največja verjetnost: L = ' + str(10**m1))
    print("Povprečje: L = " + str(avg))
    plt.cla()
    plt.plot(binsV[0:-1], nV, 'red')
    plt.ylabel('frequency')
    plt.xlabel('Log(L)')
    #plt.legend(loc=1)
    plt.title('Model 1, L(N). Median: {0}, average: {1}'.format(
        round(median, 2), round(avg, 2)))
    #plt.annotate('max', (m1, 0), annotation_clip=False)
    #plt.axvline(m1, color ='r', alpha = 0.5)
    #plt.axvline(avg, color='r', alpha=0.5)
    plt.show()
示例#3
0
from mpl_toolkits.mplot3d import Axes3D
#import scipy.ndimage.filters as fl
#from libraries.StandardizeDistribution import StandardizeDistributionW

numHorSec = 20
noBins = 50

bins = np.linspace(-2, 5, noBins + 1)  #devide N scale

horSec = np.linspace(2, 10, numHorSec)  # devide Lmax scale
Z = [None] * numHorSec  # no.hits 2D array - we draw this
i = 0

# go through the files
for fileNo in horSec:
    array = readData("/inf" + str(fileNo.round(11)))
    # array = array[0:4664]
    #array = list(filter(lambda x: 0 <= x < 4, array))
    Z[i], _ = np.histogram(array, bins)
    # Z[i] = np.multiply(Z[i], 2.0/float(fileNo), out=Z[i], casting="unsafe")    # decay factor is 2/fileNo = 2/maxL
    i += 1

X, Y = np.meshgrid(bins[0:-1], horSec)

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

X = np.array(X)
Y = np.array(Y)
Z = np.array(Z)
示例#4
0
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import scipy.ndimage.filters as fl
from libraries.StandardizeDistribution import StandardizeDistributionW

i = 0
numHorSec = 48
noBins = 100
bins = np.linspace(0, 10**(4), noBins + 1)  #devide N scale
horSec = np.linspace(2, 10, numHorSec)  # devide Lmax scale
Z = [None] * numHorSec  # no.hits 2D array - we draw this

# go through the files
for fileNo in horSec:
    array = readData("/inf" + str(fileNo))
    # array = array[0:4664]
    array = [10**i for i in filter(lambda x: 4 > x > i, array)]
    Z[i], _ = np.histogram(array, bins)
    # Z[i] = np.multiply(Z[i], 2.0/float(fileNo), out=Z[i], casting="unsafe")    # decay factor is 2/fileNo = 2/maxL

X, Y = np.meshgrid(bins[0:-1], horSec)

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

X = np.array(X)
Y = np.array(Y)
Z = np.array(Z)

# saveData(Z, "no_hits")   old
示例#5
0
if True:
    bin_no = 100
    start = 0
    end = 10000

    fixed_n = [1, 10, 100, 1000, 10000]
    colors = ['tab:blue', 'tab:orange', 'tab:green', 'tab:red', 'tab:purple']

    bounds = [500000, 50000, 500000, 5000000, 50000000]

    bounds = list(map(lambda x: x / 2, bounds))

    bins = np.linspace(start, end, bin_no)

    for i, maxN in enumerate(fixed_n):
        array = readData("inf_l_" + str(maxN))
        array = list(map(lambda x: 10**x, array))
        med = np.median(array)
        std = np.std(array)
        title = 'N = {:5}, median = {:8.0f}'.format(fixed_n[i], med)
        # plt.figure(title)
        plt.subplot(2, 3, i + 1)
        plt.title(title)
        bins = np.linspace(0, bounds[i], bin_no)
        # y, bins = np.histogram(array, )
        y, bins = np.histogram(array, bins=bins)
        #y = plt.hist(array, bins=bins, color=colors[i])
        y = y / max(y)
        # adj_bins = bins + (bins[1] - bins[0]) / 2
        # ax = plt.subplot(111)
        plt.plot(bins[:-1], y, colors[i])
示例#6
0
from libraries.IO import readData
from libraries.IO import saveData
from matplotlib import cm
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import scipy.ndimage.filters as fl
from libraries.StandardizeDistribution import StandardizeDistributionW

numHorSec = 20
start = 0
end = -4
noBins = 100
range_bin = (start, 10**end)

array = readData("/N_Sandberg_no_cut")

# val, edges = np.histogram(array, bins, range)
n, bins, patches = plt.hist(array, noBins, range_bin)

plt.title("No cut, range: " + str(start) + " - " + str(10**end) +
          " bin size: " + str(bins[1] - bins[0]))
plt.xlabel("N")
plt.ylabel("log(maxL)")
plt.show()

print("done")
示例#7
0
from mpl_toolkits.mplot3d import Axes3D
import scipy.ndimage.filters as fl
from libraries.StandardizeDistribution import StandardizeDistributionW
from numpy.random import randn
from scipy.ndimage import gaussian_filter

numHorSec = 48
# numHorSec = 5
noBins = 60
bins = np.linspace(-3, 11, noBins + 1)
horSec = np.linspace(2, 10, numHorSec)
Z = [None] * numHorSec
i = 0

for fileNo in horSec:
    array = readData("inf_loguniform_" + str(fileNo))
    #array = list(filter(lambda x: 0 <= x, array))
    Z[i], _ = np.histogram(array, bins)
    print(str(int(10**fileNo)) + " - " + str(bins[np.argmax(Z[i])]))
    i += 1

#Z = gaussian_filter(Z, sigma=1)

X, Y = np.meshgrid(bins[0:-1], horSec)
X = np.array(X)
Y = np.array(Y)
Z = np.array(Z)

#Z = np.flip(Z, 0)
#horSec = horSec[::-1]
# fig = plt.figure()
示例#8
0
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import scipy.ndimage.filters as fl
from libraries.StandardizeDistribution import StandardizeDistributionW

numHorSec = 48
#numHorSec = 5
noBins = 60
bins = np.linspace(-2, 13, noBins + 1)
bins = np.linspace(0, 10**13, noBins + 1)
horSec = np.linspace(0, 4, numHorSec)
Z = [None] * numHorSec
i = 0

for fileNo in horSec:
    array = readData("inf_l_" + str(fileNo))

    Z[i], _ = np.histogram(array, bins)
    # Z[i] = np.multiply(Z[i], 2.0/float(fileNo), out=Z[i], casting="unsafe")    # decay factor is 2/fileNo = 2/maxL
    #print(np.argmax(Z[0]))
    print(str(int(10**fileNo)) + " - " + str(bins[np.argmax(Z[i])]))
    i += 1

Z = 10**Z
X, Y = np.meshgrid(bins[0:-1], horSec)

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

X = np.array(X)
Y = np.array(Y)
示例#9
0
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import scipy.ndimage.filters as fl
from libraries.StandardizeDistribution import StandardizeDistributionW

numHorSec = 48
#numHorSec = 5
noBins = 60
bins = np.linspace(-2, 13, noBins + 1)
horSec = np.linspace(0, 4, numHorSec)
Z = [None] * numHorSec
i = 0

for fileNo in horSec:
    array = readData("infL" + str(fileNo))
    Z[i], _ = np.histogram(array, bins)
    # Z[i] = np.multiply(Z[i], 2.0/float(fileNo), out=Z[i], casting="unsafe")    # decay factor is 2/fileNo = 2/maxL
    #print(np.argmax(Z[0]))
    print(str(int(10**fileNo)) + " - " + str(bins[np.argmax(Z[i])]))
    i += 1

X, Y = np.meshgrid(bins[0:-1], horSec)

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

X = np.array(X)
Y = np.array(Y)
Z = np.array(Z)