def _export_dataset(self): """ """ try: # Export path and file name. export_target_dir = str(self._exporttargetdir_edit.text()) export_target_filename = str( self._exporttargetfilename_edit.text()) # filepathname = os.path.join(exporttargetdir, exporttargetfilename) # Warning. if os.path.exists( os.path.join(export_target_dir, export_target_filename)): box_result = QtWidgets.QMessageBox.warning( self, 'Warning', 'Excel file already exists. Do you want ro replace it?', QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.Ok) if box_result == QtWidgets.QMessageBox.Ok: self._current_sample_object.export_sample_to_excel( export_target_dir, export_target_filename) else: self._current_sample_object.export_sample_to_excel( export_target_dir, export_target_filename) # self.accept() # Close dialog box. # except Exception as e: toolbox_utils.Logging().error('Failed to export sample. ' + str(e)) QtWidgets.QMessageBox.warning(self, 'Warning', 'Failed to export sample. ' + str(e)) debug_info = self.__class__.__name__ + ', row ' + str( sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _precalculate_data(self): """ Calculates data from loaded datasets. I.e. phylum, class and order info. """ for speciesobject in self._taxa.values(): scientificname = '' try: scientificname = speciesobject['scientific_name'] counter = 0 parentobject = speciesobject while parentobject: counter += 1 if counter > 20: parentobject = None # Too many levels, or infinite loop. # print('DEBUG: Species._precalculate_data(): Too many levels, or infinite loop.') continue if 'rank' in parentobject: if parentobject['rank'] == 'Species': speciesobject['taxon_species'] = parentobject[ 'scientific_name'] if parentobject['rank'] == 'Genus': speciesobject['taxon_genus'] = parentobject[ 'scientific_name'] if parentobject['rank'] == 'Family': speciesobject['taxon_family'] = parentobject[ 'scientific_name'] if parentobject['rank'] == 'Order': speciesobject['taxon_order'] = parentobject[ 'scientific_name'] if parentobject['rank'] == 'Class': speciesobject['taxon_class'] = parentobject[ 'scientific_name'] if parentobject['rank'] == 'Phylum': speciesobject['taxon_phylum'] = parentobject[ 'scientific_name'] if parentobject['rank'] == 'Kingdom': speciesobject['taxon_kingdom'] = parentobject[ 'scientific_name'] parentobject = None # Done. Continue with next. continue # One step up in hierarchy. if 'parent_name' in parentobject: if parentobject['parent_name'] in self._taxa: parentobject = self._taxa[ parentobject['parent_name']] if parentobject[ 'parent_name'] else None else: if parentobject['scientific_name'] != 'Biota': toolbox_utils.Logging().warning( 'Parent taxon is missing for : ' + parentobject['scientific_name']) parentobject = None else: parentobject = None except: toolbox_utils.Logging().warning( 'Failed when creating classification. Taxon: ' + scientificname)
def _test(self): """ """ try: toolbox_utils.Logging().log('Name: ' + str(self._emailedit.text())) # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str( sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _create_plot_data_for_time_series(self, selectedparameter, dataset, plotdata): """ """ try: # Extract values for the plot. date = None value = None date_list = [] value_list = [] for visitnode in dataset.get_children(): date = visitnode.get_data('sample_date') for samplenode in visitnode.get_children(): for variablenode in samplenode.get_children(): parameter = variablenode.get_data('parameter') + ' (' + variablenode.get_data('unit') + ')' if parameter == selectedparameter: value = variablenode.get_data('value') date_list.append(date) value_list.append(value) # try: plotdata.add_plot(plot_name = selectedparameter, x_array = date_list, y_array = value_list, x_label = '', y_label = '') except UserWarning as e: QtWidgets.QMessageBox.warning(self._main_activity, 'Warning', str(e)) # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str(sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _add_plot_4(self): """ """ try: app_tools.ToolManager().show_tool_by_name('Graph plotter') # Show tool if hidden. graphtool = app_tools.ToolManager().get_tool_by_name('Graph plotter') graphtool.clear_plot_data() # Filtered data should be used. self._main_activity.update_filter() # Must be done before create_filtered_dataset(). analysisdata = self._analysisdata.create_filtered_dataset() if not analysisdata: return # Can't plot from empty dataset # Which parameter is selected? selectedparameter = str(self._parameter_list.currentText()) # plotdata = toolbox_utils.GraphPlotData( title = selectedparameter, x_type = 'text', y_type = 'float', x_label = '', y_label = '') # self._add_plot_bbbbbbbbb(selectedparameter, analysisdata, plotdata) # Plot. graphtool.set_chart_selection(chart = 'Bar chart', combined = True, stacked = False, y_log_scale = False) graphtool.set_plot_data(plotdata) # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str(sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _update_select_data_alternatives(self): """ """ try: analysisdata = self._analysisdata.get_data() if not analysisdata: return # Empty data. # trophic_type_set = set() lifestageset = set() for visitnode in analysisdata.get_children(): for samplenode in visitnode.get_children(): for variablenode in samplenode.get_children(): # trophic_type_set.add( str(variablenode.get_data('trophic_type'))) # lifestage = variablenode.get_data('stage') if variablenode.get_data('sex'): lifestage += '/' + variablenode.get_data('sex') lifestageset.add(lifestage) # Selection lists. self._trophic_type_listview.setList(sorted(trophic_type_set)) self._lifestage_listview.setList(sorted(lifestageset)) # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str( sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _content_save_analysis_data(self): """ """ try: saveresultbox = QtWidgets.QGroupBox('Export data', self) # Active widgets and connections. self._copytoclipboard_button = QtWidgets.QPushButton('Copy to clipboard') self._copytoclipboard_button.clicked.connect(self._copy_to_clipboard) self._saveformat_list = QtWidgets.QComboBox() self._saveformat_list.addItems(["Tab delimited text file (*.txt)", "Excel file (*.xlsx)"]) self._savedataset_button = QtWidgets.QPushButton('Save...') self._savedataset_button.clicked.connect(self._save_analysis_data) # Layout widgets. hbox1 = QtWidgets.QHBoxLayout() hbox1.addWidget(self._copytoclipboard_button) # hbox1.addStretch(5) hbox1.addWidget(QtWidgets.QLabel(' File format:')) hbox1.addWidget(self._saveformat_list) hbox1.addWidget(self._savedataset_button) hbox1.addStretch(5) # saveresultbox.setLayout(hbox1) # return saveresultbox # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str(sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _copy_to_clipboard(self): """ """ try: clipboard = QtWidgets.QApplication.clipboard() field_separator = '\t' row_separator = '\r\n' clipboardstring = '' # # table_dataset = self._tableview.getTableModel().getModeldata() table_dataset = self._tableview.getTableModel() if table_dataset: # Header. clipboardstring = field_separator.join( map(str, table_dataset.get_header())).strip() + row_separator # Rows. for row in table_dataset.get_rows(): clipboardstring += field_separator.join(map( str, row)).strip() + row_separator # clipboard.setText(clipboardstring) # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str( sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _apply_labels(self): """ """ try: # The graph part. plotdatainfo = self._plotdata.get_plot_data_info() plotdatainfo['title'] = str(self._title_edit.text()) plotdatainfo['x_label'] = str(self._xlabel_edit.text()) plotdatainfo['x_type'] = str(self._xtype_edit.text()) plotdatainfo['x_format'] = str(self._xformat_edit.text()) plotdatainfo['y_label'] = str(self._ylabel_edit.text()) plotdatainfo['y_type'] = str(self._ytype_edit.text()) plotdatainfo['y_format'] = str(self._yformat_edit.text()) plotdatainfo['z_label'] = str(self._zlabel_edit.text()) plotdatainfo['z_type'] = str(self._ztype_edit.text()) plotdatainfo['z_format'] = str(self._zformat_edit.text()) # Plots. plotlist = self._plotdata.get_plot_list() for index, row in enumerate(self._plotlabels_table.get_rows()): plotlist[index]['plot_name'] = str(row[0]) plotlist[index]['x_label'] = str(row[1]) plotlist[index]['y_label'] = str(row[2]) plotlist[index]['z_label'] = str(row[3]) # self. _reset_labels() # Update chart. self._draw_embedded_chart() self._tabWidget.setCurrentIndex(0) # Go back to graph view. # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str(sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _load_plankton_group_definition(self, excel_file_name): """ """ tablefilereader = toolbox_utils.TableFileReader( excel_file_name=excel_file_name) # for row in tablefilereader.rows(): scientificname = '' try: scientificname = row[0].strip() # Scientific name. rank = row[1].strip() # Rank. planktongroup = row[2].strip() # Plankton group. # if scientificname and planktongroup: used_rank = rank if not used_rank: used_rank = 'scientific_name' self._planktongroups_ranks_set.add(used_rank) # if used_rank not in self._planktongroups_rank_dict: self._planktongroups_rank_dict[used_rank] = {} self._planktongroups_rank_dict[used_rank][ scientificname] = planktongroup except: toolbox_utils.Logging().warning( 'Failed when loading plankton group def. File:' + excel_file_name + ' Taxon: ' + scientificname)
def clear(self): """ """ try: self._x_axis_column_list.clear() self._x_axis_parameter_list.clear() self._x_axis_column_list.addItems(['parameter:']) self._x_axis_column_list.setEnabled(False) self._x_axis_parameter_list.setEnabled(False) # self._y_axis_column_list.clear() self._y_axis_parameter_list.clear() self._y_axis_column_list.addItems(['parameter:']) self._y_axis_column_list.setEnabled(False) self._y_axis_parameter_list.setEnabled(False) # self._z_axis_column_list.clear() self._z_axis_parameter_list.clear() self._z_axis_column_list.addItems(['parameter:']) self._z_axis_column_list.setEnabled(False) self._z_axis_parameter_list.setEnabled(False) # self._update_enabled_disabled_and_types() # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str(sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _load_harmful(self, excel_file_name): """ Adds info about harmfulness to the species objects. """ tablefilereader = toolbox_utils.TableFileReader( excel_file_name=excel_file_name) # header = tablefilereader.header() for row in tablefilereader.rows(): scientific_name = '' accepted_name_usage = '' try: row_dict = dict(zip(header, row)) scientific_name = row_dict.get('scientific_name', '').strip() accepted_name_usage = row_dict.get( 'accepted_name_usage', '').strip() # Valid scientific name. # if scientific_name and (scientific_name in self._taxa_lookup): # print('Harmful: scientific_name: ' + scientific_name) taxon = self._taxa_lookup[scientific_name] taxon['harmful_name'] = scientific_name taxon['harmful'] = True if not (scientific_name == accepted_name_usage): if accepted_name_usage and (accepted_name_usage in self._taxa_lookup): # print('Harmful: accepted_name_usage: ' + accepted_name_usage + ' ( scientific_name: ' + scientific_name + ')') taxon = self._taxa_lookup[accepted_name_usage] taxon['harmful_name'] = accepted_name_usage taxon['harmful'] = True # else: # toolbox_utils.Logging().warning('Scientific name is missing: ' + scientific_name + ' (Source: ' + excel_file_name + ')') except: toolbox_utils.Logging().warning( 'Failed when loading harmful algae. File:' + excel_file_name + ' Taxon: ' + scientific_name)
def _save_data(self): """ """ try: # if self._tableview.getTableModel().getModeldata(): if self._tableview.getTableModel(): # Show select file dialog box. namefilter = 'All files (*.*)' if self._saveformat_list.currentIndex() == 1: # Xlsx file. namefilter = 'Excel files (*.xlsx);;All files (*.*)' else: namefilter = 'Text files (*.txt);;All files (*.*)' filename, _filters = QtWidgets.QFileDialog.getSaveFileName( self, 'Export dataset', self._lastuseddirectory, namefilter) filename = str(filename) # QString to str. # Check if user pressed ok or cancel. if filename: self._lastuseddirectory = os.path.dirname(filename) if self._saveformat_list.currentIndex() == 0: # Text file. # self._tableview.getTableModel().getModeldata().saveAsTextFile(filename) self._tableview.getTableModel().save_as_file(text_file_name = filename) elif self._saveformat_list.currentIndex() == 1: # Excel file. # self._tableview.getTableModel().getModeldata().saveAsExcelFile(filename) self._tableview.getTableModel().save_as_file(excel_file_name = filename) # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str(sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _tab_in_tabwidget_changed(self): """ Used to update the edit table when tab is activated/deactivated. """ try: oldtabindex = self._current_tab_index newtabindex = self._main_tab_widget.currentIndex() self._current_tab_index = newtabindex # if oldtabindex == newtabindex: return # if oldtabindex == 0: self.metadata_widget.save_data() elif oldtabindex == 1: self.methods_widget.save_data() self.count_widget.load_data() self.count_widget.save_data() elif oldtabindex == 2: self.count_widget.save_data() elif oldtabindex == 3: self.sample_data_widget.clear() # if newtabindex == 0: self.metadata_widget.load_data() elif newtabindex == 1: self.methods_widget.load_data() elif newtabindex == 2: self.count_widget.load_data() elif newtabindex == 3: self.sample_data_widget.load_data() # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str( sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def update(self): """ """ try: self.clear() analysisdata = self._analysisdata.get_data() if analysisdata: # For tab "Generic graphs". items = [item['header'] for item in analysisdata.get_export_table_columns()] self._x_axis_column_list.addItems(items) self._y_axis_column_list.addItems(items) self._z_axis_column_list.addItems(items) # Search for all parameters in analysis data. parameterset = set() for visitnode in analysisdata.get_children(): for samplenode in visitnode.get_children(): for variablenode in samplenode.get_children(): parameterset.add(variablenode.get_data('parameter') + ' (' + variablenode.get_data('unit') + ')') parameterlist = sorted(parameterset) # self._x_axis_parameter_list.addItems(parameterlist) self._y_axis_parameter_list.addItems(parameterlist) self._z_axis_parameter_list.addItems(parameterlist) # Make combo-boxes visible. self._update_enabled_disabled_and_types() # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str(sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _view_dataset(self, index): """ """ try: if index <= 0: # Clear table. self._tableview.clearModel() self._refresh_result_table() else: # envmonlib: dataset = app_framework.ToolboxDatasets().get_dataset_by_index(index - 1) if isinstance(dataset, plankton_core.DatasetTable): self._tableview.setTableModel(dataset) self._refresh_result_table() elif isinstance(dataset, plankton_core.DatasetNode): # Tree dataset must be converted to table dataset before viewing. targetdataset = plankton_core.DatasetTable() dataset.convert_to_table_dataset(targetdataset) # self._tableview.setTableModel(targetdataset) self._refresh_result_table() # # TODO: Remove later. Default alternative used for non toolbox_utils. else: self._tableview.setTableModel(dataset) self._refresh_result_table() # if self._tableview.getTableModel(): self._numberofrows_label.setText('Number of rows: ' + str(self._tableview.getTableModel().get_row_count())) else: self._numberofrows_label.setText('Number of rows: 0') # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str(sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _create_and_view_report(self, report): """ """ try: # Reset and redraw before loading new content. self._tableview.setTableModel(self._empty_dataset_table) self._tableview.resetModel() # Model data has changed. self._tableview.resizeColumnsToContents() # Create a list with selected datasets. datasets = [] for rowindex, dataset in enumerate( app_framework.ToolboxDatasets().get_datasets()): item = self._loaded_datasets_model.item(rowindex, 0) if item.checkState() == QtCore.Qt.Checked: datasets.append(dataset) # Preview result. result_table = plankton_core.DatasetTable() report.create_report( datasets, result_table, # show_debug_info = self._debuginfo_checkbox.checkState(), aggregate_rows=self._aggregate_checkbox.isChecked()) # Preview result. self._tableview.setTableModel(result_table) self._tableview.resetModel() # Model data has changed. self._tableview.resizeColumnsToContents() # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str( sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def bvol_species_screening(self, datasets): """ """ species = plankton_core.Species() # for dataset in datasets: # for visitnode in dataset.get_children(): # for samplenode in visitnode.get_children(): # for variablenode in samplenode.get_children(): # data_dict = variablenode.get_data_dict() if ('scientific_name' in data_dict) and ('size_class' in data_dict): taxonname = data_dict['scientific_name'] sizeclass = data_dict['size_class'] if species.get_bvol_value( taxonname, sizeclass, 'bvol_size_class') == None: toolbox_utils.Logging().warning( 'Taxon name/size clas not in BVOL list. Taxon name: ' + str(taxonname) + ' Size class: ' + str(sizeclass))
def _latlong_dd_edited(self): """ """ try: lat_dd = str(self._latitude_dd.text()).replace(',', '.') long_dd = str(self._longitude_dd.text()).replace(',', '.') # try: value = float(lat_dd.replace(',', '.').replace(' ', '')) value += 0.0000008 # Round (= 0.5 min). degrees = math.floor(abs(value)) minutes = (abs(value) - degrees) * 60 minutes = math.floor(minutes * 100) / 100 self._latitude_degree.setText(str(int(degrees))) self._latitude_minute.setText(str(minutes)) except: self._latitude_degree.setText('') self._latitude_minute.setText('') try: value = float(long_dd.replace(',', '.').replace(' ', '')) value += 0.0000008 # Round (= 0.5 min). degrees = math.floor(abs(value)) minutes = (abs(value) - degrees) * 60 minutes = math.floor(minutes * 100) / 100 self._longitude_degree.setText(str(int(degrees))) self._longitude_minute.setText(str(minutes)) except: self._longitude_degree.setText('') self._longitude_minute.setText('') # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str( sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _latlong_dm_edited(self): """ """ try: lat_deg = str(self._latitude_degree.text()).replace(',', '.') lat_min = str(self._latitude_minute.text()).replace(',', '.') long_deg = str(self._longitude_degree.text()).replace(',', '.') long_min = str(self._longitude_minute.text()).replace(',', '.') # try: latitude_dd = float(lat_deg.replace(',', '.').replace(' ', '')) if lat_min: latitude_dd += float( lat_min.replace(',', '.').replace(' ', '')) / 60 latitude_dd = math.floor(latitude_dd * 10000) / 10000 self._latitude_dd.setText(str(latitude_dd)) except: self._latitude_dd.setText('') try: longitude_dd = float( long_deg.replace(',', '.').replace(' ', '')) if long_min: longitude_dd += float( long_min.replace(',', '.').replace(' ', '')) / 60 longitude_dd = math.floor(longitude_dd * 10000) / 10000 self._longitude_dd.setText(str(longitude_dd)) except: self._longitude_dd.setText('') # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str( sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _view_hide_data_changed(self): """ """ try: self.update_viewed_data() # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str(sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _add_sub_plot_2(self): """ """ try: self._add_plot_2(subplot_only = True) # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str(sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _refresh_result_table(self): """ """ try: self._tableview.resetModel() # Model data has changed. self._tableview.resizeColumnsToContents() except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str(sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def clear(self): """ """ try: self._parameter_list.clear() # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str(sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def update_filter(self): """ Must be done before calls to create_filtered_dataset(). """ try: self._tab4widget.update_filter() # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str(sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def clear_plot_data(self): """ """ try: self.set_plot_data(None) # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str(sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _draw_embedded_chart(self): """ """ try: self._draw_chart(embedded = True) # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str(sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _update_column_content(self, selected_row): """ """ try: analysisdata = self._analysisdata.get_data() if not analysisdata: self._content_listview.clear() return # Empty data. # columncontent_set = set() selectedcolumn = str(self._column_list.currentText()) # Search for export column corresponding model element. nodelevel = '' key = '' for info_dict in analysisdata.get_export_table_columns(): if info_dict['header'] == selectedcolumn: nodelevel = info_dict['node'] key = info_dict['key'] break # Break loop. # if nodelevel == 'dataset': if key in analysisdata.get_data_dict().keys(): columncontent_set.add(str(analysisdata.get_data(key))) else: columncontent_set.add('') # Add empty field. # for visitnode in analysisdata.get_children(): if nodelevel == 'visit': if key in visitnode.get_data_dict().keys(): columncontent_set.add(str(visitnode.get_data(key))) else: columncontent_set.add('') # Add empty field. continue # for samplenode in visitnode.get_children(): if nodelevel == 'sample': if key in samplenode.get_data_dict().keys(): columncontent_set.add(str( samplenode.get_data(key))) else: columncontent_set.add('') # Add empty field. continue # for variablenode in samplenode.get_children(): if nodelevel == 'variable': if key in variablenode.get_data_dict().keys(): columncontent_set.add( str(variablenode.get_data(key))) else: columncontent_set.add('') # Add empty field. continue # Content list. self._content_listview.setList(sorted(columncontent_set)) # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str( sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _copy_datasets_for_analysis(self): """ """ try: try: toolbox_utils.Logging().log('Copy datasets for analysis...') toolbox_utils.Logging().start_accumulated_logging() # self._main_activity.view_analysis_data() # Clear analysis data self._analysisdata.clear_data() self._main_activity.update_viewed_data_and_tabs() # Create a list of selected datasets. datasets = [] for rowindex in range(self._loaded_datasets_model.rowCount()): item = self._loaded_datasets_model.item(rowindex, 0) if item.checkState() == QtCore.Qt.Checked: datasets.append(plankton_core.Datasets().get_datasets()[rowindex]) # Use the datasets for analysis. self._analysisdata.copy_datasets_to_analysis_data(datasets) # Check. if (self._analysisdata.get_data() == None) or (len(self._analysisdata.get_data().get_children()) == 0): toolbox_utils.Logging().log('Selected datasets are empty.') raise UserWarning('Selected datasets are empty.') self._main_activity.update_viewed_data_and_tabs() # except UserWarning as e: toolbox_utils.Logging().error('Failed to copy data for analysis. ' + str(e)) QtWidgets.QMessageBox.warning(self._main_activity, 'Warning', 'Failed to copy data for analysis. ' + str(e)) finally: toolbox_utils.Logging().log_all_accumulated_rows() toolbox_utils.Logging().log('Copy datasets for analysis is done.') # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str(sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _new_graph_and_plot_data(self): """ """ try: self._clear_plot_data() self._add_subplot_data() # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str(sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))