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. ...@@ -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: 150px; left: 200px;
width: 150px; width: 200px;
} }
#layout.active .menu-link { #layout.active .menu-link {
left: 150px; left: 200px;
} }
/* /*
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: -150px; /* "#menu" width */ margin-left: -200px; /* "#menu" width */
width: 150px; width: 200px;
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: 150px; /* left col width "#menu" */ padding-left: 200px; /* left col width "#menu" */
left: 0; left: 0;
} }
#menu { #menu {
left: 150px; left: 200px;
} }
.menu-link { .menu-link {
position: fixed; position: fixed;
left: 150px; left: 200px;
display: none; display: none;
} }
#layout.active .menu-link { #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. ...@@ -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: 150px; left: 200px;
} }
} }
This diff is collapsed.
...@@ -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 = {}
......
...@@ -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>
{% 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" />
......
{% 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">Plot misfit</h3> <h2 class="content-subhead">Global misfit</h3>
<p>Global misfit evolution.</p> <p>Evolution of global misfit.</p>
{% raw misfit_plot %} {% raw misfit_plot %}
{% end %} {% end %}
{% 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(
......
...@@ -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(
......
...@@ -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
......
Markdown is supported
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