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
d48a928d
Commit
d48a928d
authored
Mar 02, 2017
by
Marius Isken
Browse files
wip
parent
af444b6a
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/baraddur/res/site.css
View file @
d48a928d
...
...
@@ -272,5 +272,7 @@ Hides the menu at `48em`, but modify this based on your app's needs.
.button-selected
{
background
:
rgb
(
28
,
184
,
65
);
/* this is a green */
}
background
:
rgb
(
28
,
184
,
65
);
/* this is a green */
color
:
#fff
;
opacity
:
.6
;
}
src/baraddur/server.py
View file @
d48a928d
...
...
@@ -8,7 +8,7 @@ import numpy as num
import
socket
from
collections
import
OrderedDict
from
datetime
import
date
from
datetime
import
date
time
from
pyrocko.guts
import
Object
,
Bool
,
String
,
Int
,
List
...
...
@@ -48,7 +48,7 @@ class BaraddurBokehHandler(BokehHandler):
self
.
config
=
config
class
GrondBokeh
Model
(
object
):
class
Baraddur
Model
(
object
):
def
__init__
(
self
,
rundir
):
self
.
set_rundir
(
rundir
)
...
...
@@ -65,12 +65,12 @@ class GrondBokehModel(object):
@
property
def
start_time
(
self
):
stat
=
os
.
stat
(
self
.
_jp
(
'problem.yaml'
)
)
try
:
t
=
stat
.
st_birthtime
except
AttributeError
:
t
=
stat
.
st_mtime
return
date
.
fromtimestamp
(
t
).
strftime
(
'%Y-%m-%d %H:%M'
)
return
datetime
.
fromtimestamp
(
os
.
stat
(
self
.
rundir
).
st_mtime
)
@
property
def
duration
(
self
)
:
return
datetime
.
fromtimestamp
(
os
.
stat
(
self
.
_jp
(
'models'
)).
st_ctime
)
-
self
.
start_time
@
property
def
name
(
self
):
...
...
@@ -85,6 +85,10 @@ class GrondBokehModel(object):
def
niterations
(
self
):
return
op
.
getsize
(
self
.
_jp
(
'models'
))
/
(
self
.
nparameters
*
8
)
@
property
def
iter_per_second
(
self
):
return
self
.
niterations
/
self
.
duration
.
seconds
@
staticmethod
def
validate_rundir
(
rundir
):
...
...
@@ -110,33 +114,35 @@ class GrondBokehModel(object):
f
,
dtype
=
'<f8'
,
count
=
nmodels
*
self
.
nparameters
)
\
.
astype
(
num
.
float32
)
nmodels
=
data
.
size
/
self
.
nparameters
-
skip_nmodels
nmodels
=
data
.
size
/
self
.
nparameters
models
=
data
.
reshape
((
nmodels
,
self
.
nparameters
))
mods_dict
=
{}
mod
el
s_dict
=
{}
for
ip
,
par
in
enumerate
(
self
.
parameters
):
mods_dict
[
par
.
name
]
=
models
[:,
ip
]
mods_dict
[
'niter'
]
=
num
.
arange
(
nmodels
,
dtype
=
num
.
int
)
\
mod
el
s_dict
[
par
.
name
]
=
models
[:,
ip
]
mod
el
s_dict
[
'niter'
]
=
num
.
arange
(
nmodels
,
dtype
=
num
.
int
)
\
+
skip_nmodels
+
1
if
keys
is
not
None
:
for
k
in
mods_dict
.
keys
():
for
k
in
mod
el
s_dict
.
keys
():
if
k
not
in
keys
:
mods_dict
.
pop
(
k
)
mod
el
s_dict
.
pop
(
k
)
return
nmodels
,
mods_dict
return
nmodels
,
mod
el
s_dict
def
get_misfits
(
self
,
skip_nmodels
=
0
,
keys
=
None
):
fn
=
self
.
_jp
(
'misfits'
)
with
open
(
fn
,
'r'
)
as
f
:
nmodels
=
os
.
fstat
(
f
.
fileno
()).
st_size
/
(
self
.
n
p
ar
ameters
*
8
)
nmodels
=
os
.
fstat
(
f
.
fileno
()).
st_size
/
(
self
.
n
t
ar
gets
*
2
*
8
)
nmodels
-=
skip_nmodels
f
.
seek
(
skip_nmodels
*
self
.
ntargets
*
2
*
8
)
data
=
num
.
fromfile
(
f
,
dtype
=
'<f8'
,
count
=
nmodels
*
self
.
ntargets
*
2
)
\
.
astype
(
num
.
float32
)
nmodels
=
data
.
size
/
(
self
.
ntargets
*
2
)
data
=
data
.
reshape
((
nmodels
,
self
.
ntargets
*
2
))
combi
=
num
.
empty_like
(
data
)
combi
[:,
0
::
2
]
=
data
[:,
:
self
.
ntargets
]
...
...
@@ -162,7 +168,7 @@ class GrondBokehModel(object):
class
Rundirs
(
BaraddurRequestHandler
):
def
get
(
self
):
models
=
[
GrondBokeh
Model
(
rundir
=
rd
)
models
=
[
Baraddur
Model
(
rundir
=
rd
)
for
rd
in
self
.
config
.
available_rundirs
]
self
.
render
(
'rundirs.html'
,
pages
=
pages
,
...
...
@@ -177,7 +183,7 @@ class Rundirs(BaraddurRequestHandler):
self
.
get
()
class
Summary
(
BaraddurRequestHandler
):
class
Misfit
(
BaraddurRequestHandler
):
@
gen
.
coroutine
def
get
(
self
):
...
...
@@ -242,7 +248,7 @@ class Parameters(BaraddurRequestHandler):
self
.
source
=
ColumnDataSource
()
for
p
in
[
'niter'
]
+
[
p
.
name
for
p
in
problem
.
parameters
]:
self
.
source
.
add
(
num
.
ndarray
(
0
,
dtype
=
num
.
float32
),
p
)
self
.
model
=
GrondBokeh
Model
(
self
.
config
.
rundir
)
self
.
model
=
Baraddur
Model
(
self
.
config
.
rundir
)
self
.
update_parameters
()
plots
=
[]
...
...
@@ -325,8 +331,8 @@ class Targets(BaraddurRequestHandler):
pages
=
OrderedDict
([
(
'Rundirs'
,
Rundirs
),
(
'Summary'
,
Summary
),
(
'
Status
'
,
Status
),
(
'Summary'
,
Misfit
),
(
'
Misfit
'
,
Status
),
(
'Parameters'
,
Parameters
),
# ('Targets', Targets),
])
...
...
@@ -373,12 +379,12 @@ class BaraddurConfig(Object):
@
rundir
.
setter
def
rundir
(
self
,
value
):
self
.
_rundir
=
value
self
.
_model
=
GrondBokeh
Model
(
rundir
=
self
.
_rundir
)
self
.
_model
=
Baraddur
Model
(
rundir
=
self
.
_rundir
)
@
property
def
model
(
self
):
if
self
.
_model
is
None
:
self
.
_model
=
GrondBokeh
Model
(
rundir
=
self
.
rundir
)
self
.
_model
=
Baraddur
Model
(
rundir
=
self
.
rundir
)
return
self
.
_model
@
property
...
...
@@ -386,7 +392,7 @@ class BaraddurConfig(Object):
rundirs
=
[]
for
d
in
[
d
for
d
in
glob
.
glob
(
op
.
join
(
self
.
project_dir
,
'*'
))
if
op
.
isdir
(
d
)]:
if
GrondBokeh
Model
.
validate_rundir
(
d
):
if
Baraddur
Model
.
validate_rundir
(
d
):
rundirs
.
append
(
d
)
return
rundirs
...
...
src/baraddur/templates/rundirs.html
View file @
d48a928d
...
...
@@ -17,21 +17,23 @@
<td>
Directory
</td>
<td>
Start time
</td>
<td>
Iterations
</td>
<td
colspan=
2
>
Best misfit
</td>
<td>
Best misfit
</td>
<td
colspan=
2
>
Duration
</td>
</tr>
</thead>
<tbody>
{% for im, model in enumerate(models) %}
<tr
{%
if
im
%
2
==
1
%}
class=
"pure-table-odd"
{%
end
%}
>
<td
style=
"font-family: monospace;"
>
{{ model.name }}
</td>
<td>
{{ model.start_time }}
</td>
<td>
{{ model.start_time
.strftime('%Y-%m-%d %H:%M')
}}
</td>
<td>
{{ model.niterations }}
</td>
<td>
{{ model.best_misfit }}
</td>
<td>
{{ model.duration }}
</td>
<td
align=
"center"
>
{% if model.rundir == active_rundir %}
<button
class=
"pure-button
pure-button-disabled
button-selected"
')"
>
Selected
</button>
<button
class=
"pure-button button-selected"
')"
>
Selected
</button>
{% else %}
<button
class=
"pure-button pure-button-primary"
onclick=
"changeRundir('{{ model.rundir }}');"
>
Change
</button>
<button
class=
"pure-button pure-button-primary"
onclick=
"changeRundir('{{ model.rundir }}');"
>
Select
</button>
{% end %}
</td>
</tr>
...
...
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