Skip to content

Commit

Permalink
adding function to calculate mean vector and fisher-sc live
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias47n9e committed Jul 4, 2015
1 parent 20764b8 commit 0482a82
Show file tree
Hide file tree
Showing 4 changed files with 313 additions and 1 deletion.
183 changes: 183 additions & 0 deletions innstereo/gui_layout.glade
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ In Preperation (2015)</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_fisher_conf">
<property name="upper">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_line_width">
<property name="upper">100</property>
<property name="step_increment">0.10000000000000001</property>
Expand Down Expand Up @@ -2716,6 +2721,7 @@ customizable grid.</property>
<property name="margin_right">5</property>
<property name="margin_top">10</property>
<property name="margin_bottom">5</property>
<property name="column_homogeneous">True</property>
<child>
<object class="GtkLabel" id="label23">
<property name="visible">True</property>
Expand Down Expand Up @@ -2912,6 +2918,183 @@ customizable grid.</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkSeparator" id="separator4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
<property name="width">6</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="label" translatable="yes">&lt;b&gt;Statistics&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label11">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="label" translatable="yes">Mean Vector</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="switch_mean_vector">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<signal name="state-set" handler="on_switch_mean_vector_state_set" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label40">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="label" translatable="yes">Fisher Smallcircle</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="switch_fisher_sc">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<signal name="state-set" handler="on_switch_fisher_sc_state_set" swapped="no"/>
</object>
<packing>
<property name="left_attach">3</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label41">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="label" translatable="yes">Confidence</property>
</object>
<packing>
<property name="left_attach">4</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spinbutton_fisher_conf">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="adjustment">adjustment_fisher_conf</property>
<signal name="value-changed" handler="on_spinbutton_fisher_conf_value_changed" swapped="no"/>
</object>
<packing>
<property name="left_attach">5</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
Expand Down
55 changes: 54 additions & 1 deletion innstereo/layer_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, layer, redraw_plot, main_window):
"liststore_colormaps", "liststore_contour_method",
"adjustment_contour_sigma", "adjustment_contour_label_size",
"adjustment_lower_limit", "adjustment_upper_limit",
"adjustment_steps"))
"adjustment_steps", "adjustment_fisher_conf"))
self.layer = layer
self.redraw = redraw_plot
self.changes = []
Expand Down Expand Up @@ -155,6 +155,14 @@ def load_linear_properties(self):
self.builder.get_object("spinbutton_edge_width")
self.adjustment_marker_edge_width = \
self.builder.get_object("adjustment_edge_width")
self.switch_mean_vector = \
self.builder.get_object("switch_mean_vector")
self.switch_fisher_sc = \
self.builder.get_object("switch_fisher_sc")
self.spinbutton_fisher_conf = \
self.builder.get_object("spinbutton_fisher_conf")
self.adjustment_fisher_conf = \
self.builder.get_object("adjustment_fisher_conf")
self.combobox_marker_style.set_active(
self.marker_style_dict[self.layer.get_marker_style()])
self.adjustment_marker_size.set_value(self.layer.get_marker_size())
Expand All @@ -166,6 +174,10 @@ def load_linear_properties(self):
switch_state = self.layer.get_draw_linears()
self.switch_render_linears.set_active(switch_state)
self.set_linear_sensitivity(switch_state)
self.switch_mean_vector.set_state(self.layer.get_draw_mean_vector())
self.switch_fisher_sc.set_state(self.layer.get_draw_fisher_sc())
self.adjustment_fisher_conf.set_value(self.layer.get_fisher_conf())
self.set_fisher_conf_sensitivity(self.layer.get_draw_fisher_sc())

def load_fault_properties(self):
"""
Expand Down Expand Up @@ -835,3 +847,44 @@ def on_spinbutton_steps_value_changed(self, spinbutton):
self.changes.append(lambda: self.layer.set_steps(steps))
self.set_contour_range_label()

def set_fisher_conf_sensitivity(self, state):
"""
Sets the sensitivity of the Fisher confidence spinbutton.
The spinbutton for the level of confidence in the direction is only
sensitive when the Switch for the draw-state is on (= True). The
method is called when the dialog starts and when the draw-state
of the Fisher smallcircle is changed.
"""
self.spinbutton_fisher_conf.set_sensitive(state)

def on_switch_mean_vector_state_set(self, switch, state):
"""
Queues up a new state for the drawing of the mean vector linear.
When the state of the Switch is changed the new state is queued in the
list of changes. True means that a linear is drawn for the mean
direction of the dataset. False means that it is not drawn.
"""
self.changes.append(lambda: self.layer.set_draw_mean_vector(state))

def on_switch_fisher_sc_state_set(self, switch, state):
"""
Queues up a new state for the drawing of the Fisher smallcircle.
When the state of the Switch is changed the new state is queued in the
list of changes. True means that a smallcircle is drawn that represents
the confidence in the mean direction. False means that it is not drawn.
"""
self.changes.append(lambda: self.layer.set_draw_fisher_sc(state))
self.set_fisher_conf_sensitivity(state)

def on_spinbutton_fisher_conf_value_changed(self, spinbutton):
"""
Queues up a new value for the confidence of the Fisher direction.
When the value is changed, the new value is queued in the list of
changes. A larger number means that a larger circle will be drawn.
"""
conf = spinbutton.get_value()
self.changes.append(lambda: self.layer.set_fisher_conf(conf))
40 changes: 40 additions & 0 deletions innstereo/layer_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ def __init__(self, treestore, treeview):
"marker_edge_color": "#000000",
"marker_edge_width": 1.0,
"marker_alpha": 1.0,
#Linear statistics
"draw_mean_vector": False,
"draw_fisher_sc": False,
"fisher_conf": 95,
#Rose diagram properties
"rose_spacing": 10,
"rose_bottom": 0,
Expand Down Expand Up @@ -967,6 +971,42 @@ def set_properties(self, props):
"""
self.props = props

def get_draw_mean_vector(self):
"""
Returns if the mean vector should be drawn.
"""
return self.props["draw_mean_vector"]

def set_draw_mean_vector(self, new_state):
"""
Sets a new state whether the mean direction linar should be drawn.
"""
self.props["draw_mean_vector"] = new_state

def get_draw_fisher_sc(self):
"""
Returns if the confidence small circle should be drawn.
"""
return self.props["draw_fisher_sc"]

def set_draw_fisher_sc(self, new_state):
"""
Sets a new state whether the confidence small circle should be drawn.
"""
self.props["draw_fisher_sc"] = new_state

def get_fisher_conf(self):
"""
Returns the confidence for calculating the Fisher Statistics.
"""
return self.props["fisher_conf"]

def set_fisher_conf(self, new_conf):
"""
Sets a new confidene for calculating the Fisher Statistics.
"""
self.props["fisher_conf"] = new_conf


class FaultPlaneLayer(PlaneLayer):

Expand Down
36 changes: 36 additions & 0 deletions innstereo/main_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1701,6 +1701,36 @@ def draw_smallcircles(self, lyr_obj, dipdir, dip, angle, highlight=False):
alpha=lyr_obj.get_line_alpha())
return handler, lbl

def draw_mean_vector(self, lyr_obj, dipdir, dip, highlight=False):
"""
Draws the mean vector of the current linear layer.
"""
if len(dipdir) == 0:
return

vector, r_value = mplstereonet.find_mean_vector(dip, dipdir)
self.ax_stereo.line(vector[0], vector[1], marker="d",
markersize=8,
color="#ff0000",
markeredgewidth=1,
markeredgecolor="#000000",
clip_on=False)

def draw_fisher_smallcircle(self, lyr_obj, dipdir, dip, highlight=False):
"""
Draws the confidence small circle of the current linear layer.
"""
if len(dipdir) == 0:
return

confidence = lyr_obj.get_fisher_conf()
vector, stats = mplstereonet.find_fisher_stats(dip, dipdir, conf=confidence)
self.ax_stereo.cone(vector[0], vector[1], stats[1], facecolor="None",
color=lyr_obj.get_line_color(),
linewidth=lyr_obj.get_line_width(),
label=lyr_obj.get_label(),
linestyle=lyr_obj.get_line_style())

def draw_poles(self, lyr_obj, dipdir, dip, highlight=False):
"""
Function draws a plane pole in the stereonet. It calls the formatting
Expand Down Expand Up @@ -1960,6 +1990,12 @@ def plot_layer(self, lyr_obj, subset=None, highlight=False):
edgecolor = lyr_obj.get_marker_edge_color(),
bottom = lyr_obj.get_rose_bottom())

if lyr_obj.get_draw_mean_vector() == True:
self.draw_mean_vector(lyr_obj, dipdir, dip)

if lyr_obj.get_draw_fisher_sc() == True:
self.draw_fisher_smallcircle(lyr_obj, dipdir, dip)

elif lyr_type == "faultplane":
strike, plane_dir, plane_dip, line_dir, line_dip, \
sense, line_sense_dir, line_sense_dip, \
Expand Down

0 comments on commit 0482a82

Please sign in to comment.