def _polynomial_order_changed(self, new): if new >= self.window_length: dialog = MessageDialog( title='Attention!', message='Polynomial order must be less than window length.') dialog.open()
def _add_creep_plot_fired(self): plt = self.figure if (len(self.plot_list) >= self.plots_num): dialog = MessageDialog( title='Attention!', message='Max plots number is {}'.format(self.plots_num)) dialog.open() return disp_max = self.x_axis_multiplier * \ np.load(os.path.join(self.npy_folder_path, self.file_name + '_' + self.x_axis + '_max.npy')) disp_min = self.x_axis_multiplier * \ np.load(os.path.join(self.npy_folder_path, self.file_name + '_' + self.x_axis + '_min.npy')) print('Adding creep plot...') mpl.rcParams['agg.path.chunksize'] = 50000 self.apply_new_subplot() plt.xlabel('Cycles number') plt.ylabel('mm') plt.title('Fatigue creep curve', fontsize=20) plt.plot(np.arange(0, disp_max.size), disp_max, 'k', linewidth=0.8, color='red') plt.plot(np.arange(0, disp_min.size), disp_min, 'k', linewidth=0.8, color='green') self.plot_list.append('Plot {}'.format(len(self.plot_list) + 1)) print('Finished adding creep plot!')
def max_plots_number_is_reached(self): if len(self.plot_list) >= self.plots_num: dialog = MessageDialog(title='Attention!', message='Max plots number is {}'.format( self.plots_num)) dialog.open() return True else: return False
def filtered_and_creep_npy_files_exist(self, path): if os.path.exists(path) == True: return True else: dialog = MessageDialog( title='Attention!', message='Please generate filtered and creep npy files first.'. format(self.plots_num)) dialog.open() return False
def npy_files_exist(self, path): if os.path.exists(path) == True: return True else: dialog = MessageDialog( title='Attention!', message='Please parse csv file to generate npy files first.'. format(self.plots_num)) dialog.open() return False
def _window_length_changed(self, new): if new <= self.polynomial_order: dialog = MessageDialog( title='Attention!', message='Window length must be bigger than polynomial order.') dialog.open() if new % 2 == 0 or new <= 0: dialog = MessageDialog( title='Attention!', message='Window length must be odd positive integer.') dialog.open()
def _get_h5_tree(self): if self.filename is None: return None try: self.h5file = openFile(self.filename, "a") return _hdf5_tree(self.h5file) except Exception, exc: dlg = MessageDialog(title='Could not open file %s' % self.filename, message=str(exc)) dlg.open() return None
def _get_data(self): """ The filename has changed, so try to read in a new dataset. Note that we can display the array directly. """ if not self.filename: return numpy.array([], dtype=iris_dtype) try: # load into an array return load_iris(self.filename) except Exception, exc: dlg = MessageDialog(title='Could not open file %s' % self.filename, message=str(exc)) dlg.open() return numpy.array([], dtype=iris_dtype)
def open_file(self, ui_info): wildcard = 'NetCDF (*.nc)|*.nc|All files|*.*' fd = FileDialog(action='open', title='Open CERES EBAF data file', wildcard=wildcard) if fd.open() == OK: basename = os.path.basename(fd.path) if not (basename.endswith('.nc') and basename.startswith('CERES')): msg = MessageDialog(message='Not a valid CERES file. Valid files follow the form CERES*.nc?', severity='warning', title='invalid file') msg.open() return print 'Opening ' + fd.path self.view.open_ceres_data(fd.path) self.view.update_plot()
def exception_handler(self, exc_type, exc_value, exc_traceback): """ Handle un-handled exceptions """ if not isinstance(exc_value, Exception): # defer to usual exception handler sys.__excepthook__(exc_type, exc_value, exc_traceback) logging.error('Unhandled exception:', exc_info=(exc_type, exc_value, exc_traceback)) from traceback import format_tb from pyface.api import MessageDialog informative = "{0}: {1}".format(exc_type.__name__, str(exc_value)) detail = '\n'.join(format_tb(exc_traceback)) dlg = MessageDialog(severity='error', message="Unhandled Exception", informative=informative, detail=detail, size=(800,600)) dlg.open()
def close(self, info, is_ok): """ Handles the user attempting to close the dialog. If it is via the OK dialog button, try to create an account before closing. If this fails, display an error message and veto the close by returning false. """ if is_ok: success, message = info.model.create_account() if not success: dlg = MessageDialog(message="Cannot create account", informative=message, severity='error') dlg.open() return False return True
def _add_plot_fired(self): if False: # (len(self.plot_list) >= self.plots_num): dialog = MessageDialog( title='Attention!', message='Max plots number is {}'.format(self.plots_num)) dialog.open() return print('Loading npy files...') if self.apply_filters: x_axis_name = self.x_axis + '_filtered' y_axis_name = self.y_axis + '_filtered' x_axis_array = self.x_axis_multiplier * \ np.load(os.path.join(self.npy_folder_path, self.file_name + '_' + self.x_axis + '_filtered.npy')) y_axis_array = self.y_axis_multiplier * \ np.load(os.path.join(self.npy_folder_path, self.file_name + '_' + self.y_axis + '_filtered.npy')) else: x_axis_name = self.x_axis y_axis_name = self.y_axis x_axis_array = self.x_axis_multiplier * \ np.load(os.path.join(self.npy_folder_path, self.file_name + '_' + self.x_axis + '.npy')) y_axis_array = self.y_axis_multiplier * \ np.load(os.path.join(self.npy_folder_path, self.file_name + '_' + self.y_axis + '.npy')) print('Adding Plot...') mpl.rcParams['agg.path.chunksize'] = 50000 # plt.figure(self.plot_figure_num) ax = self.figure.add_subplot(1, 1, 1) ax.set_xlabel('Displacement [mm]') ax.set_ylabel('kN') ax.set_title('Original data', fontsize=20) ax.plot(x_axis_array, y_axis_array, 'k', linewidth=0.8) self.plot_list.append('{}, {}'.format(x_axis_name, y_axis_name)) self.data_changed = True print('Finished adding plot!')
def message_box(message,title,severity): from pyface.api import MessageDialog dialog = MessageDialog(message= message, title= title, severity=severity) dialog.open()