Commit 42ff724e authored by Marius Isken's avatar Marius Isken
Browse files

wip

parent d3e359fd
......@@ -29,26 +29,37 @@ This is the parent `<div>` that contains the menu and the content area.
padding-left: 0;
}
#layout.active #menu {
left: 150px;
width: 150px;
left: 200px;
width: 200px;
}
#layout.active .menu-link {
left: 150px;
left: 200px;
}
/*
The content `<div>` is where all your content goes.
*/
.footer {
margin: 3 3em;
padding: 1 0em;
margin-bottom: 0px;
div.footer {
margin: 1em 0em;
padding: 0em 0em;
line-height: 3em;
text-align: center;
color: #999;
background-color: #fbfbfb;
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 {
......@@ -90,8 +101,8 @@ appears on the left side of the page.
*/
#menu {
margin-left: -150px; /* "#menu" width */
width: 150px;
margin-left: -200px; /* "#menu" width */
width: 200px;
position: fixed;
top: 0;
left: 0;
......@@ -107,6 +118,7 @@ appears on the left side of the page.
color: #999;
border: none;
padding: 0.6em 0 0.6em 0.6em;
letter-spacing: .15em;
}
/*
......@@ -152,6 +164,10 @@ appears on the left side of the page.
#menu .pure-menu-heading {
font-size: 110%;
margin: 0;
letter-spacing: .4em;
padding: .5em 0em;
width: 200px;
text-align: center;
}
/* -- Dynamic Button For Responsive Menu -------------------------------------*/
......@@ -223,21 +239,21 @@ Hides the menu at `48em`, but modify this based on your app's needs.
}
#layout {
padding-left: 150px; /* left col width "#menu" */
padding-left: 200px; /* left col width "#menu" */
left: 0;
}
#menu {
left: 150px;
left: 200px;
}
.menu-link {
position: fixed;
left: 150px;
left: 200px;
display: none;
}
#layout.active .menu-link {
left: 150px;
left: 200px;
}
}
......@@ -250,6 +266,6 @@ Hides the menu at `48em`, but modify this based on your app's needs.
*/
#layout.active {
position: relative;
left: 150px;
left: 200px;
}
}
This diff is collapsed.
......@@ -3,10 +3,11 @@ import grond
import os.path as op
import logging
import numpy as num
import socket
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 import gen
......@@ -20,6 +21,9 @@ from bokeh.models import ColumnDataSource
from bokeh import layouts
from bokeh.plotting import figure
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('grond.baraddur')
def makeColorGradient(misfits, fr=1., fg=.5, fb=1.,
pr=0, pg=2.5, pb=4):
......@@ -108,7 +112,8 @@ class Parameters(BaraddurRequestHandler):
fig.scatter('n', par.name,
source=self.source, alpha=.4)
plots.append(fig)
plots += ([None] * (self.ncols - (len(plots) % self.ncols)))
plots += [None] * (self.ncols - (len(plots) % self.ncols))
print plots
grid = layouts.gridplot(
plots,
......@@ -161,33 +166,76 @@ class Summary(BaraddurRequestHandler):
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
def get(self):
self.render('index.html',
pages=pages)
self.render('targets.html',
contribution_plot=autoload_server(
None,
url='/contribution_plot'),
pages=pages,
problem=self.config.problem)
pages = OrderedDict([
('Summary', Summary),
('Status', Status),
('Parameters', Parameters),
('Summary', Summary),
('Sequences', MainHandler),
('Targets', Targets),
])
class BaraddurConfig(Object):
rundir = String.T()
rundir = String.T(
help='Grond rundir.')
template_path = String.T(
default='tpl',
optional=True)
default='templates',
optional=True,
help='Baraddur templates.')
debug = Bool.T(
default=True,
optional=True)
hosts = List.T(
String.T(),
default=['*'],
optional=True,
help='List of allowed hosts.')
port = Int.T(
default=8080,
optional=True)
optional=True,
help='Port to listen on.')
@property
def problem(self):
......@@ -197,16 +245,30 @@ class BaraddurConfig(Object):
class Baraddur(BokehServer):
def __init__(self, rundir=None, *args, **kwargs):
self.config = BaraddurConfig(rundir=rundir)
port_offset = 0
BokehServer.__init__(
self,
self.get_bokeh_apps(),
io_loop=tornado.ioloop.IOLoop.current(),
extra_patterns=self.get_tornado_handlers(),
hosts='*.*.*.*')
while True:
try:
BokehServer.__init__(
self,
self.get_bokeh_apps(),
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.listen(8080)
tornado_app.settings['template_path'] = self.config.template_path
if self.config.debug:
......@@ -218,14 +280,7 @@ class Baraddur(BokehServer):
from tornado import autoreload
autoreload.start()
console = logging.StreamHandler()
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)
logging.getLogger('').setLevel(logging.DEBUG)
def get_bokeh_apps(self):
bokeh_apps = {}
......
......@@ -32,6 +32,9 @@
{% end %}
</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>
......@@ -40,9 +43,6 @@
<h1 class="content-subhead">Content not implemented.</h1>
{% end %}
</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>
<script src="/css/ui.js"></script>
</html>
{% extends "index.html" %}
{% extends "base.html" %}
{% block extra_head %}
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css" />
......
{% extends "index.html" %}
{% extends "base.html" %}
{% block extra_head %}
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css" />
......@@ -10,7 +10,7 @@
<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>
</header>
<h2 class="content-subhead">Plot misfit</h3>
<p>Global misfit evolution.</p>
<h2 class="content-subhead">Global misfit</h3>
<p>Evolution of global misfit.</p>
{% raw misfit_plot %}
{% end %}
{% extends "index.html" %}
{% extends "base.html" %}
{% block extra_head %}
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css" />
......@@ -14,24 +14,7 @@
<div class="pure-u-1 pure-u-md-1 pure-u-lg-1-1">
<h2 class="content-subhead">Targets</h3>
<p>Targets to optimize.</p>
<table class="pure-table pure-table-horizontal">
<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>
{% include "table_targets.html" %}
</div>
<div class="pure-u-1 pure-u-md-1 pure-u-lg-1-2">
<h2 class="content-subhead">Initial model</h3>
......@@ -78,7 +61,7 @@
</table>
</div>
<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;">
<script>
var map = L.map('initial_model_map').setView(
......
......@@ -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,
StringChoice)
from .targets import GrondTarget
guts_prefix = 'grond'
logger = logging.getLogger('grond')
......@@ -818,7 +816,8 @@ class RectangularProblemConfig(ProblemConfig):
lat=event.lat,
lon=event.lon,
time=event.time,
depth=event.depth
depth=event.depth,
anchor='top',
)
problem = RectangularProblem(
......
......@@ -132,6 +132,10 @@ class MisfitTarget(gf.Target):
return '.'.join(x for x in (
self.super_group, self.group) + self.codes if x)
@property
def id(self):
return self.codes
def get_plain_target(self):
d = dict(
(k, getattr(self, k)) for k in gf.Target.T.propnames)
......@@ -470,6 +474,7 @@ class MisfitSatelliteTarget(gf.SatelliteTarget):
scene_id = String.T()
super_group = gf.StringID.T()
inner_misfit_config = InnerSatelliteMisfitConfig.T()
manual_weight = Float.T(default=1.0)
group = gf.StringID.T()
def __init__(self, *args, **kwargs):
......@@ -479,6 +484,10 @@ class MisfitSatelliteTarget(gf.SatelliteTarget):
def set_dataset(self, ds):
self._ds = ds
@property
def id(self):
return self.scene_id
def get_dataset(self):
return self._ds
......
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