Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sebastian Heimann
grond
Commits
092f75f3
Commit
092f75f3
authored
Nov 24, 2017
by
Marius Isken
Browse files
Merge branch 'python3' of gitext.gfz-potsdam.de:heimann/grond into python3
parents
2f543386
93c3c59c
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/core.py
View file @
092f75f3
...
...
@@ -19,7 +19,8 @@ from .solvers.base import SolverConfig
from
.targets.base
import
TargetGroup
from
.analysers.base
import
AnalyserConfig
from
.listeners
import
TerminalListener
from
.meta
import
Path
,
HasPaths
,
expand_template
,
xjoin
,
GrondError
,
Notifier
from
.meta
import
Path
,
HasPaths
,
expand_template
,
xjoin
,
GrondError
,
\
Notifier
,
Forbidden
logger
=
logging
.
getLogger
(
'grond.core'
)
guts_prefix
=
'grond'
...
...
@@ -268,6 +269,8 @@ def bootstrap_outliers(problem, misfits, std_factor=1.0):
Identify bootstrap configurations performing bad in global configuration
'''
raise
Exception
(
'this function is broken'
)
gms
=
problem
.
global_misfits
(
misfits
)
ibests
=
[]
...
...
@@ -370,7 +373,7 @@ def harvest(rundir, problem=None, nbest=10, force=False, weed=0):
if
weed
!=
3
:
for
ibootstrap
in
range
(
config
.
solver_config
.
nbootstrap
):
bms
=
problem
.
bootstrap_misfits
(
misfits
,
ibootstrap
,
config
.
solver_config
.
nbootstrap
)
misfits
,
config
.
solver_config
.
nbootstrap
,
ibootstrap
)
isort
=
num
.
argsort
(
bms
)
ibests_list
.
append
(
isort
[:
nbest
])
ibests
.
append
(
isort
[
0
])
...
...
@@ -463,7 +466,7 @@ def check(
x
=
problem
.
preconstrain
(
x
)
break
except
Exceptio
n
:
except
Forbidde
n
:
pass
sources
.
append
(
problem
.
get_source
(
x
))
...
...
src/plot.py
View file @
092f75f3
...
...
@@ -200,7 +200,7 @@ def draw_sequence_figures(model, plt, misfit_cutoff=None, sort_by='misfit'):
bounds
=
problem
.
get_parameter_bounds
()
if
ndep
>
0
:
bounds
=
num
.
vstack
((
bounds
,
problem
.
get_dependant_bounds
()))
bounds
=
num
.
concatenate
((
bounds
,
problem
.
get_dependant_bounds
()))
xref
=
problem
.
get_xref
()
...
...
@@ -361,13 +361,16 @@ def draw_jointpar_figures(
msize
=
1.5
problem
=
model
.
problem
solver
=
model
.
config
.
solver_config
if
not
problem
:
return
[]
xs
=
model
.
xs
bounds
=
num
.
vstack
(
(
problem
.
get_parameter_bounds
(),
problem
.
get_dependant_bounds
()))
bounds
=
num
.
concatenate
((
problem
.
get_parameter_bounds
(),
problem
.
get_dependant_bounds
()))
for
ipar
in
range
(
problem
.
ncombined
):
par
=
problem
.
combined
[
ipar
]
lo
,
hi
=
bounds
[
ipar
]
...
...
@@ -380,7 +383,8 @@ def draw_jointpar_figures(
xref
=
problem
.
get_xref
()
if
ibootstrap
is
not
None
:
gms
=
problem
.
bootstrap_misfits
(
model
.
misfits
,
ibootstrap
)
gms
=
problem
.
bootstrap_misfits
(
model
.
misfits
,
solver
.
nbootstrap
,
ibootstrap
)
else
:
gms
=
problem
.
global_misfits
(
model
.
misfits
)
...
...
@@ -827,7 +831,7 @@ def draw_bootstrap_figure(model, plt):
ibests
=
[]
for
ibootstrap
in
range
(
solver
.
nbootstrap
):
bms
=
problem
.
bootstrap_misfits
(
model
.
misfits
,
i
bootstrap
,
solver
.
n
bootstrap
)
model
.
misfits
,
solver
.
n
bootstrap
,
i
bootstrap
)
isort_bms
=
num
.
argsort
(
bms
)[::
-
1
]
ibests
.
append
(
isort_bms
[
-
1
])
...
...
@@ -1211,7 +1215,7 @@ def draw_fits_figures(ds, model, plt):
nframes
=
len
(
targets
)
nx
=
int
(
math
.
ceil
(
math
.
sqrt
(
nframes
)))
ny
=
int
(
(
nframes
-
1
)
/
/
nx
+
1
)
ny
=
(
nframes
-
1
)
/
nx
+
1
nxmax
=
4
nymax
=
4
...
...
@@ -1605,8 +1609,9 @@ def draw_location_figure(model, plt):
axes_dn
=
fig
.
add_subplot
(
2
,
2
,
2
)
axes_ed
=
fig
.
add_subplot
(
2
,
2
,
3
)
bounds
=
num
.
vstack
(
(
problem
.
get_parameter_bounds
(),
problem
.
get_dependant_bounds
()))
bounds
=
num
.
concatenate
((
problem
.
get_parameter_bounds
(),
problem
.
get_dependant_bounds
()))
gms
=
problem
.
global_misfits
(
model
.
misfits
)
...
...
@@ -1876,8 +1881,9 @@ class SolverPlot(object):
self
.
bcolors
=
colors
.
hsv_to_rgb
(
hsv
[
num
.
newaxis
,
:,
:])[
0
,
:,
:]
bounds
=
self
.
problem
.
get_parameter_bounds
()
\
+
self
.
problem
.
get_dependant_bounds
()
bounds
=
num
.
concatenate
((
problem
.
get_parameter_bounds
(),
problem
.
get_dependant_bounds
()))
self
.
xlim
=
fixlim
(
*
xpar
.
scaled
(
bounds
[
ixpar
]))
self
.
ylim
=
fixlim
(
*
ypar
.
scaled
(
bounds
[
iypar
]))
...
...
@@ -1931,8 +1937,9 @@ class SolverPlot(object):
ps
=
core
.
excentricity_compensated_probabilities
(
xhist
[
chains_i
[
j
,
:],
:],
local_sxs
[
jchoice
],
2.
)
bounds
=
self
.
problem
.
get_parameter_bounds
()
+
\
self
.
problem
.
get_dependant_bounds
()
bounds
=
num
.
concatenate
((
self
.
problem
.
get_parameter_bounds
(),
self
.
problem
.
get_dependant_bounds
()))
x
=
num
.
linspace
(
bounds
[
self
.
ixpar
][
0
],
bounds
[
self
.
ixpar
][
1
],
nx
)
...
...
src/problems/base.py
View file @
092f75f3
...
...
@@ -286,8 +286,7 @@ class Problem(Object):
else
:
self
.
raise_invalid_norm_exponent
()
def
bootstrap_misfit
(
self
,
ms
,
ns
,
ibootstrap
=
None
,
nbootstraps
=
None
):
# Should this be nbootstrap?
def
bootstrap_misfit
(
self
,
ms
,
ns
,
nbootstrap
,
ibootstrap
=
None
):
exp
,
root
=
self
.
get_norm_functions
()
w
=
self
.
get_target_weights
()
*
self
.
inter_group_weights
(
ns
)
...
...
@@ -296,14 +295,14 @@ class Problem(Object):
num
.
nansum
(
exp
(
w
*
ms
[
num
.
newaxis
,
:]),
axis
=
1
)
/
num
.
nansum
(
exp
(
w
*
ns
[
num
.
newaxis
,
:]),
axis
=
1
))
w
*=
self
.
get_bootstrap_weights
(
ibootstrap
)
w
*=
self
.
get_bootstrap_weights
(
nbootstrap
,
ibootstrap
)
return
root
(
num
.
nansum
(
exp
(
w
*
ms
))
/
num
.
nansum
(
exp
(
w
*
ns
)))
def
bootstrap_misfits
(
self
,
misfits
,
i
bootstrap
,
n
bootstrap
s
):
def
bootstrap_misfits
(
self
,
misfits
,
n
bootstrap
,
i
bootstrap
=
None
):
exp
,
root
=
self
.
get_norm_functions
()
w
=
self
.
get_bootstrap_weights
(
nbootstrap
s
,
ibootstrap
)[
num
.
newaxis
,
:]
*
\
nbootstrap
,
ibootstrap
)[
num
.
newaxis
,
:]
*
\
self
.
get_target_weights
()[
num
.
newaxis
,
:]
*
\
self
.
inter_group_weights2
(
misfits
[:,
:,
1
])
...
...
src/problems/double_dc.py
View file @
092f75f3
...
...
@@ -66,7 +66,6 @@ class DoubleDCProblem(Problem):
dependants
=
[]
distance_min
=
Float
.
T
(
default
=
0.0
)
nbootstrap
=
Int
.
T
(
default
=
100
)
def
get_source
(
self
,
x
):
d
=
self
.
get_parameter_dict
(
x
)
...
...
src/solvers/highscore.py
View file @
092f75f3
...
...
@@ -292,7 +292,7 @@ def solve(problem,
return
gm
=
problem
.
global_misfit
(
ms
,
ns
)
bms
=
problem
.
bootstrap_misfit
(
ms
,
ns
)
bms
=
problem
.
bootstrap_misfit
(
ms
,
ns
,
nbootstrap
)
chains_m
[
0
,
nlinks
]
=
gm
chains_m
[
1
:,
nlinks
]
=
bms
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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