straditize.widgets.data module

The main control widget for handling the data

Disclaimer

Copyright (C) 2018-2019 Philipp S. Sommer

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Classes

BarSplitter(straditizer_widgets, *args, **kwargs)

A widget for splitting bars

DigitizingControl(straditizer_widgets, item)

An interface to straditize.straditizer.Straditizer.data_reader

Functions

get_reader_name(reader)

Get the reader key in the straditize.binary.readers dictionary

int_list2str(numbers)

Create a short string representation of an integer list

class straditize.widgets.data.BarSplitter(straditizer_widgets, *args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QTreeWidget, straditize.widgets.StraditizerControlBase

A widget for splitting bars

Methods

add_toolbar_widgets()

Add an action to switch between the bars to the matplotlib toolbar

disconnect()

Disconnect the events to split an item

enable_or_disable_widgets(b)

Enable or disable the widgets in this control

fill_table([source])

Fill the table with the bars that should be splitted

get_overlapping_bars()

Get the bars the overlap with multiple bars in another column

go_to_next_bar()

Go to the next_item

go_to_prev_bar()

Go to the previous_item

new_split(y, y0[, draw_figure])

Mark the current item to be splitted at y

prepare_for_split(event)

Select or deselect a split location

refresh()

Reimplemented to use the fill_table() method

remove_actions()

Remove the actions added by add_toolbar_widgets()

remove_lines()

Remove the plotted lines

remove_split_children()

Remove all the child items that mark a split

revert_split(y, y0)

Revert the split

set_suggestions_fig_titles(ax)

Set the title in the suggestion figure with the displayed column

split_bars()

Split the bars after they have been separated manually

start_splitting(item, *args, **kwargs)

Enable the splitting for the selected item

suggest_splits()

Find overlaps for the current selected bar in other columns

Attributes

next_item

The QTreeWidgetItem for the next bar to split

prev_action

The action in the matplotlib toolbar to go to the previous bar to split

previous_item

The QTreeWidgetItem for the previous bar to split

selected_child

The QTreeWidgetItem that is currently shown in the plot

suggestions_fig

A figure to show the other columns

add_toolbar_widgets()[source]

Add an action to switch between the bars to the matplotlib toolbar

disconnect()[source]

Disconnect the events to split an item

enable_or_disable_widgets(b)[source]

Enable or disable the widgets in this control

This method enables or disables the widgets2disable if the should_be_enabled() method evaluates to True

Parameters

b (bool) – If True, enable the widgets, if False, disable them

fill_table(source='too-long')[source]

Fill the table with the bars that should be splitted

Parameters

source ({ 'too-long' | 'overlaps' | 'all' }) –

The source with what to fill the table.

too-long

Only display the bars that are considered as too long

overlap

Only display the bars that overlap with multiple bars in another column (see get_overlapping_bars())

all

Display all bars

get_overlapping_bars()[source]

Get the bars the overlap with multiple bars in another column

go_to_next_bar()[source]

Go to the next_item

go_to_prev_bar()[source]

Go to the previous_item

new_split(y, y0, draw_figure=True)[source]

Mark the current item to be splitted at y

This method draws a horizontal line at y and adds a new child QTreeWidgetItem to the selected_child to mark the split

Parameters
property next_item

The QTreeWidgetItem for the next bar to split

prepare_for_split(event)[source]

Select or deselect a split location

LeftButton selects the given location for a new split (see new_split()), RightButton deselects it (see revert_split())

prev_action = None

The action in the matplotlib toolbar to go to the previous bar to split

property previous_item

The QTreeWidgetItem for the previous bar to split

refresh()[source]

Reimplemented to use the fill_table() method

remove_actions()[source]

Remove the actions added by add_toolbar_widgets()

remove_lines()[source]

Remove the plotted lines

remove_split_children()[source]

Remove all the child items that mark a split

revert_split(y, y0)[source]

Revert the split

Parameters
selected_child = None

The QTreeWidgetItem that is currently shown in the plot

set_suggestions_fig_titles(ax)[source]

Set the title in the suggestion figure with the displayed column

split_bars()[source]

Split the bars after they have been separated manually

start_splitting(item, *args, **kwargs)[source]

Enable the splitting for the selected item

suggest_splits()[source]

Find overlaps for the current selected bar in other columns

suggestions_fig = None

A figure to show the other columns

class straditize.widgets.data.DigitizingControl(straditizer_widgets, item)[source]

Bases: straditize.widgets.StraditizerControlBase

An interface to straditize.straditizer.Straditizer.data_reader

This widgets contains the functionalities to interface with the data readers for the stratigraphic diagram

Parameters
  • straditizer_widgets (StraditizerWidgets) – The main widget for the straditizer GUI

  • item (QTreeWidgetItem) – The parent item in the StraditizerWidgets.tree. If given, the setup_children() is called with this item

Methods

align_vertical()

Create marks for vertical alignment of the columns

change_reader(txt)

Change the current parent reader

digitize()

Digitize the data

digitize_exaggerations()

Digitize the data

edit_occurences()

Enable the editing of occurences

edit_samples()

Enable the sample editing

enable_col_selection_for_new_reader()

Start the selection process to get a new reader for specific cols

enable_occurences_selection()

Enable the selection of occurences

enable_or_disable_btn_highlight_small_selection()

Enable the btn_highlight_small_selection during a selection

enable_or_disable_widgets(*args, **kwargs)

Enable or disable the widgets in this control

fill_cb_readers()

Fill the cb_readers combo based on the current reader

find_samples()

finish_exaggerated_features()

Save the exaggerations in the exaggerations reader

init_exaggerated_reader()

Initialize the reader for exaggeration features

init_reader()

Initialize the reader

load_samples([fname])

Load the samples of a text file

maybe_show_btn_reset_columns()

Show the btn_reset_columns if the column starts are set

maybe_show_btn_reset_samples()

Show the btn_reset_samples if the samples are set

modify_column_ends()

Modify the column ends

new_reader_for_selection([cls])

Create a new child reader for the selected columns

refresh()

Refresh from the straditizer

remove_hlines()

Remove horizontal lines

remove_vlines()

Remove vertical lines

remove_xaxes()

Remove x-axes in the plot

remove_yaxes()

Remove y-axes in the plot

reset_column_starts()

Reset the column starts

reset_samples()

Reset the samples

select_column_starts()

Estimate the column starts and draw marks

select_data_part([guess_lims])

Enable the selection of the diagram part

select_exaggerated_features()

Enable the selection of exaggerated features

select_occurences()

Save (and potentially remove) the selected occurences

set_occurences_value(value)

Set the occurences_value

setup_children(item)

Set up the child items for a topLevelItem in the control tree

should_be_enabled(w)

Check if a widget should be enabled

show_cross_column_features()

Remove cross column features

show_disconnected_parts()

Remove disconnected parts

show_parts_at_column_ends()

Remove parts that touch the column ends

show_small_parts()

Remove parts that touch the column ends

toggle_bar_split_source(i)

Fill the tree_bar_split based on the cb_split_source

toggle_btn_highlight_small_selection()

Enable or disable the btn_highlight_small_selection

toggle_sp_max_lw(state)

Toggle sp_max_lw based on cb_max_lw

toggle_txt_edit_rows(state)

Toggle txt_edit_rows based on cb_edit_separate

toggle_txt_from0(state)

Toggle txt_from0 based on cb_from0

toggle_txt_fromlast(state)

Toggle txt_fromlast based on cb_fromlast

toggle_txt_tolerance(s)

Set the visibility of the txt_tolerance based on the reader

update_tolerance(s)

Set the readers tolerance

Attributes

btn_column_ends

Button for selecting and modifying column ends

btn_column_starts

Button for selecting and modifying column starts, see the straditize.straditizer.Straditizer.marks_for_column_starts() method.

btn_digitize

Button for digitizing the diagram

btn_digitize_exag

Button to digitize the exaggerations

btn_edit_occurences

A button to edit the occurences with the

btn_edit_samples

A button to edit the samples (see the

btn_find_samples

A button to find the samples with the

btn_highlight_small_selection

A button to highlight small selections using the

btn_init_reader

Button for initializing the reader

btn_load_samples

A button to load samples from a file

btn_new_child_reader

Button to add a new column-specific child reader

btn_new_exaggeration

Button to add an exaggerations reader

btn_remove_hlines

button for removing horizontal lines

btn_remove_vlines

Button for removing vertical lines

btn_remove_xaxes

button for removing x-axes

btn_remove_yaxes

Button for removing y-axes

btn_reset_columns

Button to reset the column starts and ends

btn_reset_samples

A button to reset the samples

btn_select_data

Button for selecting the data box, see the straditize.straditizer.Straditizer.marks_for_data_selection() method.

btn_select_exaggerations

Button to select the exaggerations

btn_select_occurences

A button to select occurences in the data part (see the

btn_show_cross_column

A button to

btn_show_disconnected_parts

Button for removing disconnected parts in the plot.

btn_show_parts_at_column_ends

A button to show the parts that touch the column end

btn_show_small_parts

A button to show_small_parts()

cb_edit_separate

A QCheckBox to edit the samples in a separate figure and not inside the

cb_exag_reader_type

A QComboBox to select the reader type for exaggerations

cb_from0

A QCheckBox to enable and disable the from0 keyword in the

cb_fromlast

A QCheckBox to enable and disable the fromlast keyword in the

cb_max_lw

QCheckBox to enable and disable the maximum linewidth as a criterion

cb_reader_type

Combobox for selecting the reader type

cb_remove_occurences

A QCheckBox to remove the occurences in the plot after selection

cb_split_source

A QComboBox to select whether to fill the tree_bar_split with

reader

The straditize.straditizer.Straditizer.data_reader

selection_toolbar

sp_max_lw

A QSpinBox to select the maximum linewidth

sp_min_lw

A QSpinBox to select the minimum linewidth

sp_pixel_tol

A QSpinBox to set the minimum distance between to samples in the

tree

The straditize.widgets.StraditizerWidgets.tree

tree_bar_split

A BarSplitter to split too long bars

txt_column_thresh

A QLineEdit to set the threshold for the column starts detection

txt_cross_column_px

A QLineEdit to select the minimum pixels (min_px) for a cross column

txt_edit_rows

A QLineEdit to specify the number or rows in a plot for editing the

txt_exag_factor

A QLineEdit for the exageration factor

txt_from0

A QLineEdit to set the from0 keyword for the

txt_fromlast

A QLineEdit to set the fromlast keyword for the

txt_line_fraction

LineEditor for specifying the fraction of vertical and horizontal lines

txt_max_len

A QLinEdit to specify the maximum length of a potential sample to be

txt_max_small_size

A QLineEdit to set the size for small parts

txt_min_highlight

A QLineEdit to set the maximal size for

txt_min_len

A QLinEdit to specify the minimum length of a potential sample to be

txt_occurences_value

A QLineEdit to set the value for occurences in the final data

txt_tolerance

Line edit for setting the tolerance for bars

align_vertical()[source]

Create marks for vertical alignment of the columns

btn_column_ends = None

Button for selecting and modifying column ends

btn_column_starts = None

Button for selecting and modifying column starts, see the straditize.straditizer.Straditizer.marks_for_column_starts() method.

btn_digitize = None

Button for digitizing the diagram

btn_digitize_exag = None

Button to digitize the exaggerations

btn_edit_occurences = None

A button to edit the occurences with the straditize.straditizer.Straditizer.marks_for_occurences() method

btn_edit_samples = None

A button to edit the samples (see the straditize.straditizer.Straditizer.marks_for_samples() and straditize.straditizer.Straditizer.marks_for_samples_sep())

btn_find_samples = None

A button to find the samples with the straditize.binary.DataReader.find_samples() method

btn_highlight_small_selection = None

A button to highlight small selections using the straditize.label_selection.LabelSelection.highlight_small_selections() method

btn_init_reader = None

Button for initializing the reader

btn_load_samples = None

A button to load samples from a file

btn_new_child_reader = None

Button to add a new column-specific child reader

btn_new_exaggeration = None

Button to add an exaggerations reader

btn_remove_hlines = None

button for removing horizontal lines

btn_remove_vlines = None

Button for removing vertical lines

btn_remove_xaxes = None

button for removing x-axes

btn_remove_yaxes = None

Button for removing y-axes

btn_reset_columns = None

Button to reset the column starts and ends

btn_reset_samples = None

A button to reset the samples

btn_select_data = None

Button for selecting the data box, see the straditize.straditizer.Straditizer.marks_for_data_selection() method.

btn_select_exaggerations = None

Button to select the exaggerations

btn_select_occurences = None

A button to select occurences in the data part (see the enable_occurences_selection() method)

btn_show_cross_column = None

A button to show_cross_column_features()

btn_show_disconnected_parts = None

Button for removing disconnected parts in the plot. See the straditize.binary.DataReader.show_disconnected_parts() method

btn_show_parts_at_column_ends = None

A button to show the parts that touch the column end

btn_show_small_parts = None

A button to show_small_parts()

cb_edit_separate = None

A QCheckBox to edit the samples in a separate figure and not inside the original diagram

cb_exag_reader_type = None

A QComboBox to select the reader type for exaggerations

cb_from0 = None

A QCheckBox to enable and disable the from0 keyword in the straditize.binary.DataReader.show_disconnected_parts() method

cb_fromlast = None

A QCheckBox to enable and disable the fromlast keyword in the straditize.binary.DataReader.show_disconnected_parts() method

cb_max_lw = None

QCheckBox to enable and disable the maximum linewidth as a criterion

cb_reader_type = None

Combobox for selecting the reader type

cb_remove_occurences = None

A QCheckBox to remove the occurences in the plot after selection

cb_split_source = None

A QComboBox to select whether to fill the tree_bar_split with too long, overlapping, or all bars

change_reader(txt)[source]

Change the current parent reader

This changes the straditize.straditizer.Straditizer.data_reader using the straditize.binary.DataReader.set_as_parent() method

Parameters

s (str) – A string matching 'Columns (\d.*)', where the numbers are the columns of the reader to use

digitize()[source]

Digitize the data

This method uses the straditize.binary.DataReader.digitize() method to digitize the data of the current reader

digitize_exaggerations()[source]

Digitize the data

This method uses the straditize.binary.DataReader.digitize_exaggerated() method to digitize the exaggerated data of the current reader and merge it into the data obtained by the digitize() method.

digitize_item = None
edit_occurences()[source]

Enable the editing of occurences

This enables the editing of occurences using the straditize.straditizer.Straditizer.marks_for_occurences() method for the occurences selected by the select_occurences() method

edit_samples()[source]

Enable the sample editing

This method opens a straditize.widgets.samples_table.MultiCrossMarksEditor or a straditize.widgets.samples_table.SingleCrossMarksEditor to edit the samples in the GUI. Depending on whether the cb_edit_separate is checked or not, we use the straditize.straditizer.Straditizer.marks_for_samples_sep() or straditize.straditizer.Straditizer.marks_for_samples() method.

enable_col_selection_for_new_reader()[source]

Start the selection process to get a new reader for specific cols

enable_occurences_selection()[source]

Enable the selection of occurences

This method starts the selection of features in the data image and connects the select_occurences() to the apply_button.

enable_or_disable_btn_highlight_small_selection()[source]

Enable the btn_highlight_small_selection during a selection

enable_or_disable_widgets(*args, **kwargs)[source]

Enable or disable the widgets in this control

This method enables or disables the widgets2disable if the should_be_enabled() method evaluates to True

Parameters

b (bool) – If True, enable the widgets, if False, disable them

fill_cb_readers()[source]

Fill the cb_readers combo based on the current reader

find_samples()[source]
finish_exaggerated_features()[source]

Save the exaggerations in the exaggerations reader

This method finalizes the operation initialized by the select_exaggerated_features() by calling the straditize.binary.DataReader.mark_as_exaggerations() method

init_exaggerated_reader()[source]

Initialize the reader for exaggeration features

init_reader()[source]

Initialize the reader

Initialize the data reader with the straditize.straditizer.Straditizer.init_reader() method

load_samples(fname=None)[source]

Load the samples of a text file

This method askes for a filename to update the samples. The first column in this file is taken as the sample locations. If the y-axis translation is already done, the new data is assumed to be in this transformed unit.

Parameters

fname (str) – The path to the file to use. If None, a QFileDialog is opened and we ask for a name

maybe_show_btn_reset_columns()[source]

Show the btn_reset_columns if the column starts are set

maybe_show_btn_reset_samples()[source]

Show the btn_reset_samples if the samples are set

modify_column_ends()[source]

Modify the column ends

After having selected the column starts, this method enables the modification of the column ends

new_reader_for_selection(cls=None)[source]

Create a new child reader for the selected columns

This method finishes the process started by enable_col_selection_for_new_reader()

Parameters

cls (type) – The subclass of the straditize.binary.DataReader class to use for the new reader. If None, a QInputDialog is opened and we ask for a reader

property reader

The straditize.straditizer.Straditizer.data_reader

refresh()[source]

Refresh from the straditizer

remove_hlines()[source]

Remove horizontal lines

This method uses the straditize.binary.DataReader.recognize_hlines() method to identify horizontal lines in the plot

remove_vlines()[source]

Remove vertical lines

This method uses the straditize.binary.DataReader.recognize_vlines() method to identify vertical lines in the plot

remove_xaxes()[source]

Remove x-axes in the plot

This method uses the straditize.binary.DataReader.recognize_xaxes() method to identify x-axes in the plot

remove_yaxes()[source]

Remove y-axes in the plot

This method uses the straditize.binary.DataReader.recognize_yaxes() method to identify y-axes in the plot

reset_column_starts()[source]

Reset the column starts

Reset the column starts by calling the straditize.binary.DataReader.reset_column_starts() method

reset_samples()[source]

Reset the samples

Reset the samples by calling the straditize.binary.DataReader.reset_samples() method

select_column_starts()[source]

Estimate the column starts and draw marks

This methods estimates the column starts (if they are not yet set) based on the threshold in the txt_column_thresh and draws straditize.cross_marks.DraggableVLine marks on the plot.

select_data_part(guess_lims=True)[source]

Enable the selection of the diagram part

This method uses the straditize.straditizer.Straditizer.marks_for_data_selection() method to draw cross marks on the image for the diagram part

select_exaggerated_features()[source]

Enable the selection of exaggerated features

select_occurences()[source]

Save (and potentially remove) the selected occurences

Save the occurences with the straditize.binary.DataReader.get_occurences() method and remove them if the cb_remove_occurences is checked

property selection_toolbar
set_occurences_value(value)[source]

Set the occurences_value

Set the straditize.binary.DataReader.occurence_value of the data_reader with the given value

Parameters

value (float) – The value to use for occurences

setup_children(item)[source]

Set up the child items for a topLevelItem in the control tree

should_be_enabled(w)[source]

Check if a widget should be enabled

This function checks if a given widget w from the widgets2disable attribute should be enabled or not

Parameters

w (QWidget) – The widget to check

Returns

True, if the widget should be enabled

Return type

bool

show_cross_column_features()[source]

Remove cross column features

This method highlights features that span multiple columns using the straditize.binary.DataReader.show_cross_column_features() method. The algorithm can be modified with the txt_cross_column_px line editor

show_disconnected_parts()[source]

Remove disconnected parts

This method uses the straditize.binary.DataReader.show_disconnected_parts() to highlight and remove disconnected features in the diagram part. The algorithm can be modified by the txt_fromlast and txt_from0 text editors

show_parts_at_column_ends()[source]

Remove parts that touch the column ends

This method highlights features that touch the column ends using the straditize.binary.DataReader.show_parts_at_column_ends() method.

show_small_parts()[source]

Remove parts that touch the column ends

This method highlights small features in the data image using the straditize.binary.DataReader.show_small_parts() method. The maximal size of the small features can is taken from the txt_max_small_size line editor

sp_max_lw = None

A QSpinBox to select the maximum linewidth

sp_min_lw = None

A QSpinBox to select the minimum linewidth

sp_pixel_tol = None

A QSpinBox to set the minimum distance between to samples in the sample finding algorithm

toggle_bar_split_source(i)[source]

Fill the tree_bar_split based on the cb_split_source

Parameters

i (int) – The BarSplitter.fill_table() is called with either 'too-long' (if i is 0), 'overlaps' (if i is 1) or 'all'

toggle_btn_highlight_small_selection()[source]

Enable or disable the btn_highlight_small_selection

This method enables the btn_highlight_small_selection button if we are selecting something at the moment

toggle_sp_max_lw(state)[source]

Toggle sp_max_lw based on cb_max_lw

toggle_txt_edit_rows(state)[source]

Toggle txt_edit_rows based on cb_edit_separate

toggle_txt_from0(state)[source]

Toggle txt_from0 based on cb_from0

toggle_txt_fromlast(state)[source]

Toggle txt_fromlast based on cb_fromlast

toggle_txt_tolerance(s)[source]

Set the visibility of the txt_tolerance based on the reader

Parameters

s (str) – The reader name. If there is bars in s, then the txt_tolerance is displayed

property tree

The straditize.widgets.StraditizerWidgets.tree

tree_bar_split = None

A BarSplitter to split too long bars

txt_column_thresh = None

A QLineEdit to set the threshold for the column starts detection

txt_cross_column_px = None

A QLineEdit to select the minimum pixels (min_px) for a cross column feature

txt_edit_rows = None

A QLineEdit to specify the number or rows in a plot for editing the samples in a separate figure (see btn_edit_samples and cb_edit_separate)

txt_exag_factor = None

A QLineEdit for the exageration factor

txt_from0 = None

A QLineEdit to set the from0 keyword for the straditize.binary.DataReader.show_disconnected_parts() method

txt_fromlast = None

A QLineEdit to set the fromlast keyword for the straditize.binary.DataReader.show_disconnected_parts() method

txt_line_fraction = None

LineEditor for specifying the fraction of vertical and horizontal lines

txt_max_len = None

A QLinEdit to specify the maximum length of a potential sample to be included in the sample finding algorithm (see btn_find_samples)

txt_max_small_size = None

A QLineEdit to set the size for small parts

txt_min_highlight = None

A QLineEdit to set the maximal size for highlighting small features

txt_min_len = None

A QLinEdit to specify the minimum length of a potential sample to be included in the sample finding algorithm (see btn_find_samples)

txt_occurences_value = None

A QLineEdit to set the value for occurences in the final data

txt_tolerance = None

Line edit for setting the tolerance for bars

update_tolerance(s)[source]

Set the readers tolerance

Parameters

s (str or int) – The tolerance for the straditizer.binary.BarDataReader.tolerance attribute

straditize.widgets.data.get_reader_name(reader)[source]

Get the reader key in the straditize.binary.readers dictionary

Parameters

reader (straditize.binary.DataReader) – The reader for which to get the key in the straditize.binary.readers dictionary

Returns

The key in the straditize.binary.readers dictionary whose value corresponds to the class of the given reader

Return type

str

straditize.widgets.data.int_list2str(numbers)[source]

Create a short string representation of an integer list

Parameters

numbers (list of ints) – Integer list

Returns

The string representation

Return type

str

Examples

[1, 2, 3] becomes '1-3', [1, 2, 3, 5, 7, 8, 9] becomes '1-3, 5, 7-9'