Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Roberto Tonini
PyBetUnrest
Commits
55c06215
Commit
55c06215
authored
Feb 18, 2022
by
Roberto Tonini
Browse files
Updated functions' names in alphabeta.py and their calls in betunrest.py
parent
025704cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/alphabeta.py
View file @
55c06215
...
...
@@ -10,17 +10,17 @@ This file is part of PyBetEF.
"""
def
calc
M
onitoring
P
rob
(
par_th1
,
par_th2
,
par_rel
,
par_val
,
par_wei
,
sample
,
nmix
,
anomaly_pars
):
def
calc
_m
onitoring
_p
rob
(
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
=
calc
A
nomaly
D
egree
(
par_th1
,
par_th2
,
par_rel
,
par_val
)
tmp
=
calc
_a
nomaly
_d
egree
(
par_th1
,
par_th2
,
par_rel
,
par_val
)
anDegTot
=
np
.
sum
(
np
.
array
(
tmp
)
*
np
.
array
(
par_wei
))
probM
,
aveM
=
sampling
M
onitoring
(
anDegTot
,
sample
,
nmix
,
a
,
b
,
l
)
#probM, aveM = sampling
M
onitoringOLD(anDegTot, sample, nmix)
probM
,
aveM
=
sampling
_m
onitoring
(
anDegTot
,
sample
,
nmix
,
a
,
b
,
l
)
#probM, aveM = sampling
_m
onitoring
_
OLD(anDegTot, sample, nmix)
return
probM
,
aveM
...
...
@@ -39,7 +39,7 @@ def mixing(postBG, postM, sample, nmix):
return
pp
def
sampling
M
onitoring
(
anDegTot
,
sample
,
nmix
,
a
,
b
,
l
):
def
sampling
_m
onitoring
(
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
sampling
M
onitoringOLD
(
anDegTot
,
sample
,
nmix
):
def
sampling
_m
onitoring
_
OLD
(
anDegTot
,
sample
,
nmix
):
"""
Sampling the monitored parameter with a given degree of anomaly
...
...
@@ -76,7 +76,7 @@ def samplingMonitoringOLD(anDegTot, sample, nmix):
def
calc
A
nomaly
D
egree
(
th1
,
th2
,
rel
,
v
):
def
calc
_a
nomaly
_d
egree
(
th1
,
th2
,
rel
,
v
):
"""
Calculation of the Degree of Anomaly
"""
...
...
@@ -125,7 +125,7 @@ def calcAnomalyDegree(th1, th2, rel, v):
def
make
A
lpha16
(
n
,
p
,
l
,
pd
):
def
make
_a
lpha16
(
n
,
p
,
l
,
pd
):
"""
Calculate alpha values for nodes 1 to 6
...
...
@@ -147,7 +147,7 @@ def makeAlpha16(n, p, l, pd):
def
theoretical
A
verage
(
a
):
def
theoretical
_a
verage
(
a
):
"""
"""
if
(
np
.
size
(
a
)
<=
2
):
...
...
@@ -157,7 +157,7 @@ def theoreticalAverage(a):
return
ave
def
mixing
A
verage
(
ave_longterm
,
ave_monitoring
,
weight
):
def
mixing
_a
verage
(
ave_longterm
,
ave_monitoring
,
weight
):
"""
"""
...
...
src/betunrest.py
View file @
55c06215
...
...
@@ -674,13 +674,13 @@ class BetFrame(wx.Frame):
# Node Unrest
if
(
nodes
>
0
):
node
=
"Unrest"
alpha_unrest
=
ab
.
make
A
lpha16
(
2
,
self
.
p1
,
self
.
l1
,
self
.
d1
)
alpha_unrest
=
ab
.
make
_a
lpha16
(
2
,
self
.
p1
,
self
.
l1
,
self
.
d1
)
posterior
=
np
.
random
.
dirichlet
(
alpha_unrest
,
sample
).
transpose
()
aveLT
=
ab
.
theoretical
A
verage
(
alpha_unrest
)
aveLT
=
ab
.
theoretical
_a
verage
(
alpha_unrest
)
if
(
monitoring
):
tmp
=
ab
.
calc
A
nomaly
D
egree
(
par_th1
[
node
],
par_th2
[
node
],
par_rel
[
node
],
par_val
[
node
])
tmp
=
ab
.
calc
_a
nomaly
_d
egree
(
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
.
mixing
A
verage
(
aveLT
,
aveM
,
DegUnrest
))
pp_con_ave
.
append
(
ab
.
mixing
_a
verage
(
aveLT
,
aveM
,
DegUnrest
))
else
:
DegUnrest
=
0
...
...
@@ -711,15 +711,15 @@ class BetFrame(wx.Frame):
# Node Magmatic
if
(
nodes
>
1
):
node
=
"Magmatic"
alpha_magma
=
ab
.
make
A
lpha16
(
2
,
self
.
p2
,
self
.
l2
,
self
.
d2
)
alpha_magma
=
ab
.
make
_a
lpha16
(
2
,
self
.
p2
,
self
.
l2
,
self
.
d2
)
posterior
=
np
.
random
.
dirichlet
(
alpha_magma
,
sample
).
transpose
()
aveLT
=
ab
.
theoretical
A
verage
(
alpha_magma
)
aveLT
=
ab
.
theoretical
_a
verage
(
alpha_magma
)
if
(
monitoring
and
node
in
list
(
par_name
.
keys
())):
probM
,
aveM
=
ab
.
calc
M
onitoring
P
rob
(
par_th1
[
node
],
par_th2
[
node
],
probM
,
aveM
=
ab
.
calc
_m
onitoring
_p
rob
(
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
.
mixing
A
verage
(
aveLT
,
aveM
,
DegUnrest
))
pp_con_ave
.
append
(
ab
.
mixing
_a
verage
(
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
.
make
A
lpha16
(
2
,
self
.
p3
,
self
.
l3
,
self
.
d3
)
alpha_magma_eru
=
ab
.
make
_a
lpha16
(
2
,
self
.
p3
,
self
.
l3
,
self
.
d3
)
posterior
=
np
.
random
.
dirichlet
(
alpha_magma_eru
,
sample
).
transpose
()
aveLT
=
ab
.
theoretical
A
verage
(
alpha_magma_eru
)
aveLT
=
ab
.
theoretical
_a
verage
(
alpha_magma_eru
)
if
(
monitoring
and
node
in
list
(
par_name
.
keys
())):
probM
,
aveM
=
ab
.
calc
M
onitoring
P
rob
(
par_th1
[
node
],
par_th2
[
node
],
probM
,
aveM
=
ab
.
calc
_m
onitoring
_p
rob
(
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
.
mixing
A
verage
(
aveLT
,
aveM
,
DegUnrest
))
pp_con_ave
.
append
(
ab
.
mixing
_a
verage
(
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
.
make
A
lpha16
(
nvents
,
self
.
p4
,
self
.
l4
,
self
.
d4
)
alpha4
=
ab
.
make
_a
lpha16
(
nvents
,
self
.
p4
,
self
.
l4
,
self
.
d4
)
posterior
=
np
.
random
.
dirichlet
(
alpha4
,
sample
).
transpose
()
aveLT
=
ab
.
theoretical
A
verage
(
alpha4
)
aveLT
=
ab
.
theoretical
_a
verage
(
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
.
mixing
A
verage
(
aveLT
,
aveM
,
nmix4
/
float
(
sample
)))
pp_con_ave
.
append
(
ab
.
mixing
_a
verage
(
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
.
make
A
lpha16
(
nsizes
,
self
.
p5
[
i
,:],
alpha5
[
i
]
=
ab
.
make
_a
lpha16
(
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
.
theoretical
A
verage
(
alpha5
[
ind4
[
i
]])
aveLT
[
i
,:]
=
ab
.
theoretical
_a
verage
(
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
.
make
A
lpha16
(
2
,
self
.
p_hydro
,
alpha_hydro
=
ab
.
make
_a
lpha16
(
2
,
self
.
p_hydro
,
self
.
l_hydro
,
self
.
d_hydro
)
posterior
=
np
.
random
.
dirichlet
(
alpha_hydro
,
sample
).
transpose
()
aveLT
=
ab
.
theoretical
A
verage
(
alpha_hydro
)
aveLT
=
ab
.
theoretical
_a
verage
(
alpha_hydro
)
if
(
monitoring
and
node
in
list
(
par_name
.
keys
())):
probM
,
aveM
=
ab
.
calc
M
onitoring
P
rob
(
par_th1
[
node
],
par_th2
[
node
],
probM
,
aveM
=
ab
.
calc
_m
onitoring
_p
rob
(
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
.
mixing
A
verage
(
aveLT
,
aveM
,
DegUnrest
))
pp_con_ave
.
append
(
ab
.
mixing
_a
verage
(
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
.
make
A
lpha16
(
2
,
self
.
p_hydro_eru
,
alpha_hydro_eru
=
ab
.
make
_a
lpha16
(
2
,
self
.
p_hydro_eru
,
self
.
l_hydro_eru
,
self
.
d_hydro_eru
)
posterior
=
np
.
random
.
dirichlet
(
alpha_hydro_eru
,
sample
).
transpose
()
aveLT
=
ab
.
theoretical
A
verage
(
alpha_hydro_eru
)
aveLT
=
ab
.
theoretical
_a
verage
(
alpha_hydro_eru
)
if
(
monitoring
and
node
in
list
(
par_name
.
keys
())):
probM
,
aveM
=
ab
.
calc
M
onitoring
P
rob
(
par_th1
[
node
],
par_th2
[
node
],
probM
,
aveM
=
ab
.
calc
_m
onitoring
_p
rob
(
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
.
mixing
A
verage
(
aveLT
,
aveM
,
DegUnrest
))
pp_con_ave
.
append
(
ab
.
mixing
_a
verage
(
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
.
make
A
lpha16
(
nvents
,
self
.
p4hyd
,
self
.
l4hyd
,
self
.
d4hyd
)
alpha_vent
=
ab
.
make
_a
lpha16
(
nvents
,
self
.
p4hyd
,
self
.
l4hyd
,
self
.
d4hyd
)
posterior
=
np
.
random
.
dirichlet
(
alpha_vent
,
sample
).
transpose
()
aveLT
=
ab
.
theoretical
A
verage
(
alpha_vent
)
aveLT
=
ab
.
theoretical
_a
verage
(
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
.
mixing
A
verage
(
aveLT
,
aveM
,
nmix4
/
float
(
sample
)))
pp_con_ave
.
append
(
ab
.
mixing
_a
verage
(
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
.
make
A
lpha16
(
2
,
self
.
p_hydro_eru_size
,
alpha_hydro_eru_size
=
ab
.
make
_a
lpha16
(
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
.
theoretical
A
verage
(
alpha_hydro_eru
)
aveLT
=
ab
.
theoretical
_a
verage
(
alpha_hydro_eru
)
if
(
monitoring
and
node
in
list
(
par_name
.
keys
())):
probM
,
aveM
=
ab
.
calc
M
onitoring
P
rob
(
par_th1
[
node
],
par_th2
[
node
],
probM
,
aveM
=
ab
.
calc
_m
onitoring
_p
rob
(
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
.
mixing
A
verage
(
aveLT
,
aveM
,
DegUnrest
))
pp_con_ave
.
append
(
ab
.
mixing
_a
verage
(
aveLT
,
aveM
,
DegUnrest
))
else
:
pp_con_ave
.
append
(
aveLT
)
pp_hydro_eru_size
=
posterior
.
transpose
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment