Commit 55c06215 authored by Roberto Tonini's avatar Roberto Tonini
Browse files

Updated functions' names in alphabeta.py and their calls in betunrest.py

parent 025704cc
......@@ -10,17 +10,17 @@ This file is part of PyBetEF.
"""
def calcMonitoringProb(par_th1, par_th2, par_rel,
par_val, par_wei, sample, nmix, anomaly_pars):
def calc_monitoring_prob(par_th1, par_th2, par_rel,
par_val, par_wei, sample, nmix, anomaly_pars):
"""
"""
a = anomaly_pars[0]
b = anomaly_pars[1]
l = anomaly_pars[2]
tmp = calcAnomalyDegree(par_th1, par_th2, par_rel, par_val)
tmp = calc_anomaly_degree(par_th1, par_th2, par_rel, par_val)
anDegTot = np.sum(np.array(tmp)*np.array(par_wei))
probM, aveM = samplingMonitoring(anDegTot, sample, nmix, a, b, l)
#probM, aveM = samplingMonitoringOLD(anDegTot, sample, nmix)
probM, aveM = sampling_monitoring(anDegTot, sample, nmix, a, b, l)
#probM, aveM = sampling_monitoring_OLD(anDegTot, sample, nmix)
return probM, aveM
......@@ -39,7 +39,7 @@ def mixing(postBG, postM, sample, nmix):
return pp
def samplingMonitoring(anDegTot, sample, nmix, a, b, l):
def sampling_monitoring(anDegTot, sample, nmix, a, b, l):
"""
Sampling the monitored parameter with a given degree of anomaly
......@@ -53,7 +53,7 @@ def samplingMonitoring(anDegTot, sample, nmix, a, b, l):
def samplingMonitoringOLD(anDegTot, sample, nmix):
def sampling_monitoring_OLD(anDegTot, sample, nmix):
"""
Sampling the monitored parameter with a given degree of anomaly
......@@ -76,7 +76,7 @@ def samplingMonitoringOLD(anDegTot, sample, nmix):
def calcAnomalyDegree(th1, th2, rel, v):
def calc_anomaly_degree(th1, th2, rel, v):
"""
Calculation of the Degree of Anomaly
"""
......@@ -125,7 +125,7 @@ def calcAnomalyDegree(th1, th2, rel, v):
def makeAlpha16(n, p, l, pd):
def make_alpha16(n, p, l, pd):
"""
Calculate alpha values for nodes 1 to 6
......@@ -147,7 +147,7 @@ def makeAlpha16(n, p, l, pd):
def theoreticalAverage(a):
def theoretical_average(a):
"""
"""
if (np.size(a) <= 2):
......@@ -157,7 +157,7 @@ def theoreticalAverage(a):
return ave
def mixingAverage(ave_longterm, ave_monitoring, weight):
def mixing_average(ave_longterm, ave_monitoring, weight):
"""
"""
......
......@@ -674,13 +674,13 @@ class BetFrame(wx.Frame):
# Node Unrest
if (nodes > 0):
node = "Unrest"
alpha_unrest = ab.makeAlpha16(2, self.p1, self.l1, self.d1)
alpha_unrest = ab.make_alpha16(2, self.p1, self.l1, self.d1)
posterior = np.random.dirichlet(alpha_unrest, sample).transpose()
aveLT = ab.theoreticalAverage(alpha_unrest)
aveLT = ab.theoretical_average(alpha_unrest)
if (monitoring):
tmp = ab.calcAnomalyDegree(par_th1[node], par_th2[node],
par_rel[node], par_val[node])
tmp = ab.calc_anomaly_degree(par_th1[node], par_th2[node],
par_rel[node], par_val[node])
DegUnrest = 1 - np.prod(1.0-np.array(tmp))
print("Degree of Unrest: {0}".format(DegUnrest))
......@@ -696,7 +696,7 @@ class BetFrame(wx.Frame):
tmp = np.transpose(np.vstack((pp_yes,pp_no)))
pp_unrest = np.random.permutation(tmp)
pp_con_ave.append(ab.mixingAverage(aveLT, aveM, DegUnrest))
pp_con_ave.append(ab.mixing_average(aveLT, aveM, DegUnrest))
else:
DegUnrest = 0
......@@ -711,15 +711,15 @@ class BetFrame(wx.Frame):
# Node Magmatic
if (nodes > 1):
node = "Magmatic"
alpha_magma = ab.makeAlpha16(2, self.p2, self.l2, self.d2)
alpha_magma = ab.make_alpha16(2, self.p2, self.l2, self.d2)
posterior = np.random.dirichlet(alpha_magma, sample).transpose()
aveLT = ab.theoreticalAverage(alpha_magma)
aveLT = ab.theoretical_average(alpha_magma)
if (monitoring and node in list(par_name.keys())):
probM, aveM = ab.calcMonitoringProb(par_th1[node], par_th2[node],
probM, aveM = ab.calc_monitoring_prob(par_th1[node], par_th2[node],
par_rel[node], par_val[node],
par_wei[node], sample, nmix, anPars)
pp_magma = ab.mixing(posterior, probM, sample, nmix)
pp_con_ave.append(ab.mixingAverage(aveLT, aveM, DegUnrest))
pp_con_ave.append(ab.mixing_average(aveLT, aveM, DegUnrest))
else:
pp_con_ave.append(aveLT)
pp_magma = posterior.transpose()
......@@ -737,15 +737,15 @@ class BetFrame(wx.Frame):
# Node Magmatic Eruption
if (nodes > 2):
node = "Magmatic Eruption"
alpha_magma_eru = ab.makeAlpha16(2, self.p3, self.l3, self.d3)
alpha_magma_eru = ab.make_alpha16(2, self.p3, self.l3, self.d3)
posterior = np.random.dirichlet(alpha_magma_eru, sample).transpose()
aveLT = ab.theoreticalAverage(alpha_magma_eru)
aveLT = ab.theoretical_average(alpha_magma_eru)
if (monitoring and node in list(par_name.keys())):
probM, aveM = ab.calcMonitoringProb(par_th1[node], par_th2[node],
probM, aveM = ab.calc_monitoring_prob(par_th1[node], par_th2[node],
par_rel[node], par_val[node],
par_wei[node], sample, nmix, anPars)
pp_magma_eru = ab.mixing(posterior, probM, sample, nmix)
pp_con_ave.append(ab.mixingAverage(aveLT, aveM, DegUnrest))
pp_con_ave.append(ab.mixing_average(aveLT, aveM, DegUnrest))
else:
pp_con_ave.append(aveLT)
pp_magma_eru = posterior.transpose()
......@@ -765,9 +765,9 @@ class BetFrame(wx.Frame):
else:
ind4 = [int(nodes_flag[3]-1)]
alpha4 = ab.makeAlpha16(nvents, self.p4, self.l4, self.d4)
alpha4 = ab.make_alpha16(nvents, self.p4, self.l4, self.d4)
posterior = np.random.dirichlet(alpha4, sample).transpose()
aveLT = ab.theoreticalAverage(alpha4)
aveLT = ab.theoretical_average(alpha4)
if (monitoring):
nmix4 = int(min(DegUnrest,0.5)*sample)
if (not os.path.isfile(ventMagMon)):
......@@ -796,7 +796,7 @@ class BetFrame(wx.Frame):
aveM = alpha4M/np.sum(alpha4M)
probM = np.random.dirichlet(alpha4M, nmix4)
pp_vent = ab.mixing(posterior, probM, sample, nmix4)
pp_con_ave.append(ab.mixingAverage(aveLT, aveM, nmix4/float(sample)))
pp_con_ave.append(ab.mixing_average(aveLT, aveM, nmix4/float(sample)))
else:
pp_con_ave.append(aveLT)
pp_vent = posterior.transpose()
......@@ -819,7 +819,7 @@ class BetFrame(wx.Frame):
alpha5 = [0]*(nvents)
for i in range(nvents):
alpha5[i] = ab.makeAlpha16(nsizes, self.p5[i,:],
alpha5[i] = ab.make_alpha16(nsizes, self.p5[i,:],
self.l5[i],
self.d5[i,:])
posterior = np.random.dirichlet(alpha5[i], sample)
......@@ -839,7 +839,7 @@ class BetFrame(wx.Frame):
aveLT = np.zeros((len(ind4),nsizes))
for i in range(len(ind4)):
aveLT[i,:] = ab.theoreticalAverage(alpha5[ind4[i]])
aveLT[i,:] = ab.theoretical_average(alpha5[ind4[i]])
pp5cond = np.zeros((sample,nsizes))
for j in range(nsizes):
......@@ -874,17 +874,17 @@ class BetFrame(wx.Frame):
# Node Hydrotermal
if (nodes > 2):
node = "Hydrothermal"
alpha_hydro = ab.makeAlpha16(2, self.p_hydro,
alpha_hydro = ab.make_alpha16(2, self.p_hydro,
self.l_hydro,
self.d_hydro)
posterior = np.random.dirichlet(alpha_hydro, sample).transpose()
aveLT = ab.theoreticalAverage(alpha_hydro)
aveLT = ab.theoretical_average(alpha_hydro)
if (monitoring and node in list(par_name.keys())):
probM, aveM = ab.calcMonitoringProb(par_th1[node], par_th2[node],
probM, aveM = ab.calc_monitoring_prob(par_th1[node], par_th2[node],
par_rel[node], par_val[node],
par_wei[node], sample, nmix, anPars)
pp_hydro = ab.mixing(posterior, probM, sample, nmix)
pp_con_ave.append(ab.mixingAverage(aveLT, aveM, DegUnrest))
pp_con_ave.append(ab.mixing_average(aveLT, aveM, DegUnrest))
else:
pp_con_ave.append(aveLT)
pp_hydro = posterior.transpose()
......@@ -898,17 +898,17 @@ class BetFrame(wx.Frame):
# Node Hydrotermal Eruption
if (nodes > 3):
node = "Hydrothermal Eruption"
alpha_hydro_eru = ab.makeAlpha16(2, self.p_hydro_eru,
alpha_hydro_eru = ab.make_alpha16(2, self.p_hydro_eru,
self.l_hydro_eru,
self.d_hydro_eru)
posterior = np.random.dirichlet(alpha_hydro_eru, sample).transpose()
aveLT = ab.theoreticalAverage(alpha_hydro_eru)
aveLT = ab.theoretical_average(alpha_hydro_eru)
if (monitoring and node in list(par_name.keys())):
probM, aveM = ab.calcMonitoringProb(par_th1[node], par_th2[node],
probM, aveM = ab.calc_monitoring_prob(par_th1[node], par_th2[node],
par_rel[node], par_val[node],
par_wei[node], sample, nmix, anPars)
pp_hydro_eru = ab.mixing(posterior, probM, sample, nmix)
pp_con_ave.append(ab.mixingAverage(aveLT, aveM, DegUnrest))
pp_con_ave.append(ab.mixing_average(aveLT, aveM, DegUnrest))
else:
pp_con_ave.append(aveLT)
pp_hydro_eru = posterior.transpose()
......@@ -927,9 +927,9 @@ class BetFrame(wx.Frame):
else:
ind4 = [int(nodes_flag[4]-1)]
alpha_vent = ab.makeAlpha16(nvents, self.p4hyd, self.l4hyd, self.d4hyd)
alpha_vent = ab.make_alpha16(nvents, self.p4hyd, self.l4hyd, self.d4hyd)
posterior = np.random.dirichlet(alpha_vent, sample).transpose()
aveLT = ab.theoreticalAverage(alpha_vent)
aveLT = ab.theoretical_average(alpha_vent)
if (monitoring):
nmix4 = int(min(DegUnrest,0.5)*sample)
......@@ -959,7 +959,7 @@ class BetFrame(wx.Frame):
aveM = alpha4M/np.sum(alpha4M)
probM = np.random.dirichlet(alpha4M, nmix4)
pp_vent = ab.mixing(posterior, probM, sample, nmix4)
pp_con_ave.append(ab.mixingAverage(aveLT, aveM, nmix4/float(sample)))
pp_con_ave.append(ab.mixing_average(aveLT, aveM, nmix4/float(sample)))
else:
pp_con_ave.append(aveLT)
pp_vent = posterior.transpose()
......@@ -981,17 +981,17 @@ class BetFrame(wx.Frame):
# Node Hydrotermal Eruption Style
if (nodes > 5):
node = "Hydrothermal Eruption Style"
alpha_hydro_eru_size = ab.makeAlpha16(2, self.p_hydro_eru_size,
alpha_hydro_eru_size = ab.make_alpha16(2, self.p_hydro_eru_size,
self.l_hydro_eru_size,
self.d_hydro_eru_size)
posterior = np.random.dirichlet(alpha_hydro_eru_size, sample).transpose()
aveLT = ab.theoreticalAverage(alpha_hydro_eru)
aveLT = ab.theoretical_average(alpha_hydro_eru)
if (monitoring and node in list(par_name.keys())):
probM, aveM = ab.calcMonitoringProb(par_th1[node], par_th2[node],
probM, aveM = ab.calc_monitoring_prob(par_th1[node], par_th2[node],
par_rel[node], par_val[node],
par_wei[node], sample, nmix, anPars)
pp_hydro_eru_size = ab.mixing(posterior, probM, sample, nmix)
pp_con_ave.append(ab.mixingAverage(aveLT, aveM, DegUnrest))
pp_con_ave.append(ab.mixing_average(aveLT, aveM, DegUnrest))
else:
pp_con_ave.append(aveLT)
pp_hydro_eru_size = posterior.transpose()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment