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
Sebastian Heimann
grond
Commits
42ff724e
Commit
42ff724e
authored
Mar 01, 2017
by
Marius Isken
Browse files
wip
parent
d3e359fd
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
src/baraddur/css/site.css
View file @
42ff724e
...
@@ -29,26 +29,37 @@ This is the parent `<div>` that contains the menu and the content area.
...
@@ -29,26 +29,37 @@ This is the parent `<div>` that contains the menu and the content area.
padding-left
:
0
;
padding-left
:
0
;
}
}
#layout
.active
#menu
{
#layout
.active
#menu
{
left
:
15
0px
;
left
:
20
0px
;
width
:
15
0px
;
width
:
20
0px
;
}
}
#layout
.active
.menu-link
{
#layout
.active
.menu-link
{
left
:
15
0px
;
left
:
20
0px
;
}
}
/*
/*
The content `<div>` is where all your content goes.
The content `<div>` is where all your content goes.
*/
*/
.footer
{
div
.footer
{
margin
:
3
3em
;
margin
:
1em
0em
;
padding
:
1
0em
;
padding
:
0em
0em
;
margin-bottom
:
0px
;
line-height
:
3em
;
line-height
:
3em
;
text-align
:
center
;
text-align
:
center
;
color
:
#999
;
color
:
#999
;
background-color
:
#fbfbfb
;
background-color
:
#fbfbfb
;
border-top
:
1px
solid
#e8e8e8
;
border-top
:
1px
solid
#e8e8e8
;
position
:
absolute
;
bottom
:
0px
;
left
:
0px
;
font-size
:
80%
;
}
#menu
div
.footer
a
{
color
:
white
;
border
:
none
;
padding
:
0.6em
0.6em
0.6em
0.6em
;
letter-spacing
:
.15em
;
}
}
}
.header
{
.header
{
...
@@ -90,8 +101,8 @@ appears on the left side of the page.
...
@@ -90,8 +101,8 @@ appears on the left side of the page.
*/
*/
#menu
{
#menu
{
margin-left
:
-
15
0px
;
/* "#menu" width */
margin-left
:
-
20
0px
;
/* "#menu" width */
width
:
15
0px
;
width
:
20
0px
;
position
:
fixed
;
position
:
fixed
;
top
:
0
;
top
:
0
;
left
:
0
;
left
:
0
;
...
@@ -107,6 +118,7 @@ appears on the left side of the page.
...
@@ -107,6 +118,7 @@ appears on the left side of the page.
color
:
#999
;
color
:
#999
;
border
:
none
;
border
:
none
;
padding
:
0.6em
0
0.6em
0.6em
;
padding
:
0.6em
0
0.6em
0.6em
;
letter-spacing
:
.15em
;
}
}
/*
/*
...
@@ -152,6 +164,10 @@ appears on the left side of the page.
...
@@ -152,6 +164,10 @@ appears on the left side of the page.
#menu
.pure-menu-heading
{
#menu
.pure-menu-heading
{
font-size
:
110%
;
font-size
:
110%
;
margin
:
0
;
margin
:
0
;
letter-spacing
:
.4em
;
padding
:
.5em
0em
;
width
:
200px
;
text-align
:
center
;
}
}
/* -- Dynamic Button For Responsive Menu -------------------------------------*/
/* -- Dynamic Button For Responsive Menu -------------------------------------*/
...
@@ -223,21 +239,21 @@ Hides the menu at `48em`, but modify this based on your app's needs.
...
@@ -223,21 +239,21 @@ Hides the menu at `48em`, but modify this based on your app's needs.
}
}
#layout
{
#layout
{
padding-left
:
15
0px
;
/* left col width "#menu" */
padding-left
:
20
0px
;
/* left col width "#menu" */
left
:
0
;
left
:
0
;
}
}
#menu
{
#menu
{
left
:
15
0px
;
left
:
20
0px
;
}
}
.menu-link
{
.menu-link
{
position
:
fixed
;
position
:
fixed
;
left
:
15
0px
;
left
:
20
0px
;
display
:
none
;
display
:
none
;
}
}
#layout
.active
.menu-link
{
#layout
.active
.menu-link
{
left
:
15
0px
;
left
:
20
0px
;
}
}
}
}
...
@@ -250,6 +266,6 @@ Hides the menu at `48em`, but modify this based on your app's needs.
...
@@ -250,6 +266,6 @@ Hides the menu at `48em`, but modify this based on your app's needs.
*/
*/
#layout
.active
{
#layout
.active
{
position
:
relative
;
position
:
relative
;
left
:
15
0px
;
left
:
20
0px
;
}
}
}
}
src/baraddur/problem.yaml
deleted
100644 → 0
View file @
d3e359fd
This diff is collapsed.
Click to expand it.
src/baraddur/server.py
View file @
42ff724e
...
@@ -3,10 +3,11 @@ import grond
...
@@ -3,10 +3,11 @@ import grond
import
os.path
as
op
import
os.path
as
op
import
logging
import
logging
import
numpy
as
num
import
numpy
as
num
import
socket
from
collections
import
OrderedDict
from
collections
import
OrderedDict
from
pyrocko.guts
import
Object
,
Bool
,
String
,
Int
from
pyrocko.guts
import
Object
,
Bool
,
String
,
Int
,
List
from
tornado.web
import
RequestHandler
,
StaticFileHandler
from
tornado.web
import
RequestHandler
,
StaticFileHandler
from
tornado
import
gen
from
tornado
import
gen
...
@@ -20,6 +21,9 @@ from bokeh.models import ColumnDataSource
...
@@ -20,6 +21,9 @@ from bokeh.models import ColumnDataSource
from
bokeh
import
layouts
from
bokeh
import
layouts
from
bokeh.plotting
import
figure
from
bokeh.plotting
import
figure
logging
.
basicConfig
(
level
=
logging
.
INFO
)
logger
=
logging
.
getLogger
(
'grond.baraddur'
)
def
makeColorGradient
(
misfits
,
fr
=
1.
,
fg
=
.
5
,
fb
=
1.
,
def
makeColorGradient
(
misfits
,
fr
=
1.
,
fg
=
.
5
,
fb
=
1.
,
pr
=
0
,
pg
=
2.5
,
pb
=
4
):
pr
=
0
,
pg
=
2.5
,
pb
=
4
):
...
@@ -108,7 +112,8 @@ class Parameters(BaraddurRequestHandler):
...
@@ -108,7 +112,8 @@ class Parameters(BaraddurRequestHandler):
fig
.
scatter
(
'n'
,
par
.
name
,
fig
.
scatter
(
'n'
,
par
.
name
,
source
=
self
.
source
,
alpha
=
.
4
)
source
=
self
.
source
,
alpha
=
.
4
)
plots
.
append
(
fig
)
plots
.
append
(
fig
)
plots
+=
([
None
]
*
(
self
.
ncols
-
(
len
(
plots
)
%
self
.
ncols
)))
plots
+=
[
None
]
*
(
self
.
ncols
-
(
len
(
plots
)
%
self
.
ncols
))
print
plots
grid
=
layouts
.
gridplot
(
grid
=
layouts
.
gridplot
(
plots
,
plots
,
...
@@ -161,33 +166,76 @@ class Summary(BaraddurRequestHandler):
...
@@ -161,33 +166,76 @@ class Summary(BaraddurRequestHandler):
problem
=
self
.
config
.
problem
)
problem
=
self
.
config
.
problem
)
class
MainHandler
(
BaraddurRequestHandler
):
class
Targets
(
BaraddurRequestHandler
):
class
TargetContributionPlot
(
BaraddurBokehHandler
):
def
modify_document
(
self
,
doc
):
self
.
nmodels
=
0
self
.
source
=
ColumnDataSource
()
self
.
update_contributions
()
plot
=
figure
(
webgl
=
True
,
x_axis_label
=
'Iteration #'
,
y_axis_label
=
'Misfit'
)
doc
.
add_root
(
plot
)
doc
.
add_periodic_callback
(
self
.
update_contributions
,
1e3
)
@
gen
.
coroutine
def
update_contributions
(
self
):
mx
,
misfits
=
grond
.
core
.
load_problem_data
(
self
.
config
.
rundir
,
self
.
config
.
problem
,
skip_models
=
self
.
nmodels
)
print
misfits
new_nmodels
=
mx
.
shape
[
0
]
# self.source.stream(dict(m=misfits[:, :, 0],
# n=num.arange(new_nmodels,
# dtype=num.int) +
# self.nmodels + 1))
self
.
nmodels
+=
new_nmodels
bokeh_handlers
=
{
'contribution_plot'
:
TargetContributionPlot
}
@
gen
.
coroutine
@
gen
.
coroutine
def
get
(
self
):
def
get
(
self
):
self
.
render
(
'index.html'
,
self
.
render
(
'targets.html'
,
pages
=
pages
)
contribution_plot
=
autoload_server
(
None
,
url
=
'/contribution_plot'
),
pages
=
pages
,
problem
=
self
.
config
.
problem
)
pages
=
OrderedDict
([
pages
=
OrderedDict
([
(
'Summary'
,
Summary
),
(
'Status'
,
Status
),
(
'Status'
,
Status
),
(
'Parameters'
,
Parameters
),
(
'Parameters'
,
Parameters
),
(
'Summary'
,
Summary
),
(
'Targets'
,
Targets
),
(
'Sequences'
,
MainHandler
),
])
])
class
BaraddurConfig
(
Object
):
class
BaraddurConfig
(
Object
):
rundir
=
String
.
T
()
rundir
=
String
.
T
(
help
=
'Grond rundir.'
)
template_path
=
String
.
T
(
template_path
=
String
.
T
(
default
=
'tpl'
,
default
=
'templates'
,
optional
=
True
)
optional
=
True
,
help
=
'Baraddur templates.'
)
debug
=
Bool
.
T
(
debug
=
Bool
.
T
(
default
=
True
,
default
=
True
,
optional
=
True
)
optional
=
True
)
hosts
=
List
.
T
(
String
.
T
(),
default
=
[
'*'
],
optional
=
True
,
help
=
'List of allowed hosts.'
)
port
=
Int
.
T
(
port
=
Int
.
T
(
default
=
8080
,
default
=
8080
,
optional
=
True
)
optional
=
True
,
help
=
'Port to listen on.'
)
@
property
@
property
def
problem
(
self
):
def
problem
(
self
):
...
@@ -197,16 +245,30 @@ class BaraddurConfig(Object):
...
@@ -197,16 +245,30 @@ class BaraddurConfig(Object):
class
Baraddur
(
BokehServer
):
class
Baraddur
(
BokehServer
):
def
__init__
(
self
,
rundir
=
None
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
rundir
=
None
,
*
args
,
**
kwargs
):
self
.
config
=
BaraddurConfig
(
rundir
=
rundir
)
self
.
config
=
BaraddurConfig
(
rundir
=
rundir
)
port_offset
=
0
BokehServer
.
__init__
(
while
True
:
self
,
try
:
self
.
get_bokeh_apps
(),
BokehServer
.
__init__
(
io_loop
=
tornado
.
ioloop
.
IOLoop
.
current
(),
self
,
extra_patterns
=
self
.
get_tornado_handlers
(),
self
.
get_bokeh_apps
(),
hosts
=
'*.*.*.*'
)
io_loop
=
tornado
.
ioloop
.
IOLoop
.
current
(),
extra_patterns
=
self
.
get_tornado_handlers
(),
port
=
self
.
config
.
port
+
port_offset
,
host
=
self
.
config
.
hosts
)
break
except
socket
.
error
as
se
:
if
se
.
errno
==
98
and
port_offset
<
50
:
# Port in use
port_offset
+=
1
logger
.
info
(
'Port %d in use, bailing to %d'
%
(
self
.
config
.
port
+
port_offset
-
1
,
self
.
config
.
port
+
port_offset
))
else
:
raise
se
logger
.
info
(
'Created Baraddur server on http://localhost:%d'
%
(
self
.
port
))
tornado_app
=
self
.
_tornado
tornado_app
=
self
.
_tornado
tornado_app
.
listen
(
8080
)
tornado_app
.
settings
[
'template_path'
]
=
self
.
config
.
template_path
tornado_app
.
settings
[
'template_path'
]
=
self
.
config
.
template_path
if
self
.
config
.
debug
:
if
self
.
config
.
debug
:
...
@@ -218,14 +280,7 @@ class Baraddur(BokehServer):
...
@@ -218,14 +280,7 @@ class Baraddur(BokehServer):
from
tornado
import
autoreload
from
tornado
import
autoreload
autoreload
.
start
()
autoreload
.
start
()
console
=
logging
.
StreamHandler
()
logging
.
getLogger
(
''
).
setLevel
(
logging
.
DEBUG
)
console
.
setLevel
(
logging
.
DEBUG
)
formatter
=
logging
.
Formatter
(
'%(name)-12s: %(levelname)-8s %(message)s'
)
console
.
setFormatter
(
formatter
)
rootLogger
=
logging
.
getLogger
(
''
)
rootLogger
.
addHandler
(
console
)
rootLogger
.
setLevel
(
logging
.
DEBUG
)
def
get_bokeh_apps
(
self
):
def
get_bokeh_apps
(
self
):
bokeh_apps
=
{}
bokeh_apps
=
{}
...
...
src/baraddur/t
pl/index
.html
→
src/baraddur/t
emplates/base
.html
View file @
42ff724e
...
@@ -32,6 +32,9 @@
...
@@ -32,6 +32,9 @@
{% end %}
{% end %}
</ul>
</ul>
<div
class=
"sidebar footer pure-u-1"
>
<i>
The earthquake buster
</i><br>
<a
href=
"http://pyrocko.org"
class=
"pure-button pure-button-primary"
target=
"_blank"
>
pyrocko.org
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
...
@@ -40,9 +43,6 @@
...
@@ -40,9 +43,6 @@
<h1
class=
"content-subhead"
>
Content not implemented.
</h1>
<h1
class=
"content-subhead"
>
Content not implemented.
</h1>
{% end %}
{% end %}
</div>
</div>
<div
class=
"footer pure-u-1"
>
Grond -
<i>
The earthquake buster
</i>
<a
href=
"http://pyrocko.org"
class=
"pure-button pure-button-primary"
style=
"margin-left: 1em;"
>
pyrocko.org
</a>
</div>
</div>
</div>
<script
src=
"/css/ui.js"
></script>
<script
src=
"/css/ui.js"
></script>
</html>
</html>
src/baraddur/t
pl
/parameter_plots.html
→
src/baraddur/t
emplates
/parameter_plots.html
View file @
42ff724e
{% extends "
index
.html" %}
{% extends "
base
.html" %}
{% block extra_head %}
{% block extra_head %}
<link
rel=
"stylesheet"
href=
"https://unpkg.com/leaflet@1.0.3/dist/leaflet.css"
/>
<link
rel=
"stylesheet"
href=
"https://unpkg.com/leaflet@1.0.3/dist/leaflet.css"
/>
...
...
src/baraddur/t
pl
/status.html
→
src/baraddur/t
emplates
/status.html
View file @
42ff724e
{% extends "
index
.html" %}
{% extends "
base
.html" %}
{% block extra_head %}
{% block extra_head %}
<link
rel=
"stylesheet"
href=
"https://unpkg.com/leaflet@1.0.3/dist/leaflet.css"
/>
<link
rel=
"stylesheet"
href=
"https://unpkg.com/leaflet@1.0.3/dist/leaflet.css"
/>
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
<h1
class=
"content-subhead"
>
Status
<i>
{{ problem.name }}
</i></h1>
<h1
class=
"content-subhead"
>
Status
<i>
{{ problem.name }}
</i></h1>
<p><span
style=
"font-family: monospace;"
>
{{ problem.__class__.__name__ }}
</span>
|
<span
style=
"font-family: monospace;"
>
{{ problem.base_source.__class__.__name__ }}
</span></p>
<p><span
style=
"font-family: monospace;"
>
{{ problem.__class__.__name__ }}
</span>
|
<span
style=
"font-family: monospace;"
>
{{ problem.base_source.__class__.__name__ }}
</span></p>
</header>
</header>
<h2
class=
"content-subhead"
>
P
lo
t
misfit
</h3>
<h2
class=
"content-subhead"
>
G
lo
bal
misfit
</h3>
<p>
G
lobal misfit
evolution
.
</p>
<p>
Evolution of g
lobal misfit.
</p>
{% raw misfit_plot %}
{% raw misfit_plot %}
{% end %}
{% end %}
src/baraddur/t
pl
/summary.html
→
src/baraddur/t
emplates
/summary.html
View file @
42ff724e
{% extends "
index
.html" %}
{% extends "
base
.html" %}
{% block extra_head %}
{% block extra_head %}
<link
rel=
"stylesheet"
href=
"https://unpkg.com/leaflet@1.0.3/dist/leaflet.css"
/>
<link
rel=
"stylesheet"
href=
"https://unpkg.com/leaflet@1.0.3/dist/leaflet.css"
/>
...
@@ -14,24 +14,7 @@
...
@@ -14,24 +14,7 @@
<div
class=
"pure-u-1 pure-u-md-1 pure-u-lg-1-1"
>
<div
class=
"pure-u-1 pure-u-md-1 pure-u-lg-1-1"
>
<h2
class=
"content-subhead"
>
Targets
</h3>
<h2
class=
"content-subhead"
>
Targets
</h3>
<p>
Targets to optimize.
</p>
<p>
Targets to optimize.
</p>
<table
class=
"pure-table pure-table-horizontal"
>
{% include "table_targets.html" %}
<thead>
<tr>
<td></td>
<td>
id
</td>
<td>
Type
</td>
</tr>
</thead>
<tbody>
{% for it, target in enumerate(problem.targets) %}
<tr
{%
if
it
%
2
==
1
%}
class=
"pure-table-odd"
{%
end
%}
>
<td>
{{ it+1 }}
</td>
<td>
{{ target.scene_id }}
</td>
<td
style=
"font-family: monospace;"
>
{{ target.__class__.__name__ }}
</td>
</tr>
{% end %}
</tbody>
</table>
</div>
</div>
<div
class=
"pure-u-1 pure-u-md-1 pure-u-lg-1-2"
>
<div
class=
"pure-u-1 pure-u-md-1 pure-u-lg-1-2"
>
<h2
class=
"content-subhead"
>
Initial model
</h3>
<h2
class=
"content-subhead"
>
Initial model
</h3>
...
@@ -78,7 +61,7 @@
...
@@ -78,7 +61,7 @@
</table>
</table>
</div>
</div>
<div
class=
"pure-u-1"
>
<div
class=
"pure-u-1"
>
<h2
class=
"content-subhead"
>
Map
of initial model
position
</h2>
<h2
class=
"content-subhead"
>
Geographical position
of initial model
</h2>
<div
id=
"initial_model_map"
class=
"pure-u-1"
style=
"min-height: 250px;"
>
<div
id=
"initial_model_map"
class=
"pure-u-1"
style=
"min-height: 250px;"
>
<script>
<script>
var
map
=
L
.
map
(
'
initial_model_map
'
).
setView
(
var
map
=
L
.
map
(
'
initial_model_map
'
).
setView
(
...
...
src/problems.py
View file @
42ff724e
...
@@ -9,8 +9,6 @@ from pyrocko import gf, util, guts, moment_tensor as mtm
...
@@ -9,8 +9,6 @@ from pyrocko import gf, util, guts, moment_tensor as mtm
from
pyrocko.guts
import
(
Object
,
String
,
Bool
,
List
,
Float
,
Dict
,
Int
,
from
pyrocko.guts
import
(
Object
,
String
,
Bool
,
List
,
Float
,
Dict
,
Int
,
StringChoice
)
StringChoice
)
from
.targets
import
GrondTarget
guts_prefix
=
'grond'
guts_prefix
=
'grond'
logger
=
logging
.
getLogger
(
'grond'
)
logger
=
logging
.
getLogger
(
'grond'
)
...
@@ -818,7 +816,8 @@ class RectangularProblemConfig(ProblemConfig):
...
@@ -818,7 +816,8 @@ class RectangularProblemConfig(ProblemConfig):
lat
=
event
.
lat
,
lat
=
event
.
lat
,
lon
=
event
.
lon
,
lon
=
event
.
lon
,
time
=
event
.
time
,
time
=
event
.
time
,
depth
=
event
.
depth
depth
=
event
.
depth
,
anchor
=
'top'
,
)
)
problem
=
RectangularProblem
(
problem
=
RectangularProblem
(
...
...
src/targets.py
View file @
42ff724e
...
@@ -132,6 +132,10 @@ class MisfitTarget(gf.Target):
...
@@ -132,6 +132,10 @@ class MisfitTarget(gf.Target):
return
'.'
.
join
(
x
for
x
in
(
return
'.'
.
join
(
x
for
x
in
(
self
.
super_group
,
self
.
group
)
+
self
.
codes
if
x
)
self
.
super_group
,
self
.
group
)
+
self
.
codes
if
x
)
@
property
def
id
(
self
):
return
self
.
codes
def
get_plain_target
(
self
):
def
get_plain_target
(
self
):
d
=
dict
(
d
=
dict
(
(
k
,
getattr
(
self
,
k
))
for
k
in
gf
.
Target
.
T
.
propnames
)
(
k
,
getattr
(
self
,
k
))
for
k
in
gf
.
Target
.
T
.
propnames
)
...
@@ -470,6 +474,7 @@ class MisfitSatelliteTarget(gf.SatelliteTarget):
...
@@ -470,6 +474,7 @@ class MisfitSatelliteTarget(gf.SatelliteTarget):
scene_id
=
String
.
T
()
scene_id
=
String
.
T
()
super_group
=
gf
.
StringID
.
T
()
super_group
=
gf
.
StringID
.
T
()
inner_misfit_config
=
InnerSatelliteMisfitConfig
.
T
()
inner_misfit_config
=
InnerSatelliteMisfitConfig
.
T
()
manual_weight
=
Float
.
T
(
default
=
1.0
)
group
=
gf
.
StringID
.
T
()
group
=
gf
.
StringID
.
T
()
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
...
@@ -479,6 +484,10 @@ class MisfitSatelliteTarget(gf.SatelliteTarget):
...
@@ -479,6 +484,10 @@ class MisfitSatelliteTarget(gf.SatelliteTarget):
def
set_dataset
(
self
,
ds
):
def
set_dataset
(
self
,
ds
):
self
.
_ds
=
ds
self
.
_ds
=
ds
@
property
def
id
(
self
):
return
self
.
scene_id
def
get_dataset
(
self
):
def
get_dataset
(
self
):
return
self
.
_ds
return
self
.
_ds
...
...
Write
Preview
Markdown
is supported
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