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
|
A widget for splitting bars |
|
An interface to |
Functions
|
Get the reader key in the |
|
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 an action to switch between the bars to the matplotlib toolbar
Disconnect the events to split an item
Enable or disable the widgets in this control
fill_table
([source])Fill the table with the bars that should be splitted
Get the bars the overlap with multiple bars in another column
Go to the
next_item
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()
methodRemove the actions added by
add_toolbar_widgets()
Remove the plotted lines
Remove all the child items that mark a split
revert_split
(y, y0)Revert the split
Set the title in the suggestion figure with the displayed column
Split the bars after they have been separated manually
start_splitting
(item, *args, **kwargs)Enable the splitting for the selected item
Find overlaps for the current selected bar in other columns
Attributes
The QTreeWidgetItem for the next bar to split
The action in the matplotlib toolbar to go to the previous bar to split
The QTreeWidgetItem for the previous bar to split
The QTreeWidgetItem that is currently shown in the plot
A figure to show the other columns
-
enable_or_disable_widgets
(b)[source]¶ Enable or disable the widgets in this control
This method enables or disables the
widgets2disable
if theshould_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
-
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
y (int) – The vertical position of the split in the data image coordinate system
y0 (int) – The vertical start of the data image (see
straditize.binary.DataReader.extent
)draw_figure (bool) – If True, draw the figure
-
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 (seerevert_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()
-
revert_split
(y, y0)[source]¶ Revert the split
- Parameters
y (int) – The vertical position of the split in the data image coordinate system
y0 (int) – The vertical start of the data image (see
straditize.binary.DataReader.extent
)
-
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
-
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, thesetup_children()
is called with this item
Methods
Create marks for vertical alignment of the columns
change_reader
(txt)Change the current parent reader
digitize
()Digitize the data
Digitize the data
Enable the editing of occurences
Enable the sample editing
Start the selection process to get a new reader for specific cols
Enable the selection of occurences
Enable the
btn_highlight_small_selection
during a selectionenable_or_disable_widgets
(*args, **kwargs)Enable or disable the widgets in this control
Fill the
cb_readers
combo based on the current readerSave the exaggerations in the exaggerations reader
Initialize the reader for exaggeration features
Initialize the reader
load_samples
([fname])Load the samples of a text file
Show the
btn_reset_columns
if the column starts are setShow the
btn_reset_samples
if the samples are setModify the column ends
new_reader_for_selection
([cls])Create a new child reader for the selected columns
refresh
()Refresh from the straditizer
Remove horizontal lines
Remove vertical lines
Remove x-axes in the plot
Remove y-axes in the plot
Reset the column starts
Reset the samples
Estimate the column starts and draw marks
select_data_part
([guess_lims])Enable the selection of the diagram part
Enable the selection of exaggerated features
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
Check if a widget should be enabled
Remove cross column features
Remove disconnected parts
Remove parts that touch the column ends
Remove parts that touch the column ends
Fill the
tree_bar_split
based on thecb_split_source
Enable or disable the
btn_highlight_small_selection
toggle_sp_max_lw
(state)Toggle
sp_max_lw
based oncb_max_lw
toggle_txt_edit_rows
(state)Toggle
txt_edit_rows
based oncb_edit_separate
toggle_txt_from0
(state)Toggle
txt_from0
based oncb_from0
toggle_txt_fromlast
(state)Toggle
txt_fromlast
based oncb_fromlast
Set the visibility of the
txt_tolerance
based on the readerSet the readers
tolerance
Attributes
Button for selecting and modifying column ends
Button for selecting and modifying column starts, see the
straditize.straditizer.Straditizer.marks_for_column_starts()
method.Button for digitizing the diagram
Button to digitize the exaggerations
A button to edit the occurences with the
A button to edit the samples (see the
A button to find the samples with the
A button to highlight small selections using the
Button for initializing the reader
A button to load samples from a file
Button to add a new column-specific child reader
Button to add an exaggerations reader
button for removing horizontal lines
Button for removing vertical lines
button for removing x-axes
Button for removing y-axes
Button to reset the column starts and ends
A button to reset the samples
Button for selecting the data box, see the
straditize.straditizer.Straditizer.marks_for_data_selection()
method.Button to select the exaggerations
A button to select occurences in the data part (see the
A button to
Button for removing disconnected parts in the plot.
A button to show the parts that touch the column end
A button to
show_small_parts()
A QCheckBox to edit the samples in a separate figure and not inside the
A QComboBox to select the reader type for exaggerations
A QCheckBox to enable and disable the from0 keyword in the
A QCheckBox to enable and disable the fromlast keyword in the
QCheckBox to enable and disable the maximum linewidth as a criterion
Combobox for selecting the reader type
A QCheckBox to remove the occurences in the plot after selection
A QComboBox to select whether to fill the
tree_bar_split
withA QSpinBox to select the maximum linewidth
A QSpinBox to select the minimum linewidth
A QSpinBox to set the minimum distance between to samples in the
A
BarSplitter
to split too long barsA QLineEdit to set the threshold for the column starts detection
A QLineEdit to select the minimum pixels (min_px) for a cross column
A QLineEdit to specify the number or rows in a plot for editing the
A QLineEdit for the exageration factor
A QLineEdit to set the from0 keyword for the
A QLineEdit to set the fromlast keyword for the
LineEditor for specifying the fraction of vertical and horizontal lines
A QLinEdit to specify the maximum length of a potential sample to be
A QLineEdit to set the size for small parts
A QLineEdit to set the maximal size for
A QLinEdit to specify the minimum length of a potential sample to be
A QLineEdit to set the value for occurences in the final data
Line edit for setting the tolerance for bars
-
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()
andstraditize.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 thestraditize.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 thedigitize()
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 theselect_occurences()
method
-
edit_samples
()[source]¶ Enable the sample editing
This method opens a
straditize.widgets.samples_table.MultiCrossMarksEditor
or astraditize.widgets.samples_table.SingleCrossMarksEditor
to edit the samples in the GUI. Depending on whether thecb_edit_separate
is checked or not, we use thestraditize.straditizer.Straditizer.marks_for_samples_sep()
orstraditize.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 theapply_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 theshould_be_enabled()
method evaluates to True- Parameters
b (bool) – If True, enable the widgets, if False, disable them
-
finish_exaggerated_features
()[source]¶ Save the exaggerations in the exaggerations reader
This method finalizes the operation initialized by the
select_exaggerated_features()
by calling thestraditize.binary.DataReader.mark_as_exaggerations()
method
-
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
¶
-
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 drawsstraditize.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_occurences
()[source]¶ Save (and potentially remove) the selected occurences
Save the occurences with the
straditize.binary.DataReader.get_occurences()
method and remove them if thecb_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
-
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
-
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 thetxt_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 thetxt_fromlast
andtxt_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 thetxt_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 thecb_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_txt_edit_rows
(state)[source]¶ Toggle
txt_edit_rows
based oncb_edit_separate
-
toggle_txt_fromlast
(state)[source]¶ Toggle
txt_fromlast
based oncb_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
¶
-
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
andcb_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
-
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