Пример #1
0
    def __init__(self, parent, geo_file, params=None):
        super(Simulation, self).__init__(parent)

        self._geom = None
        self.geo_file_name = geo_file
        self.loaded = False
        self._label = None

        self.__sig_emitDataChanged = None

        ThreadLoader(self, self).start()

        # progress update timer
        self.timer = QtCore.QTimer()
        self.timer.timeout.connect(self.sigUpdateProgress.emit)
        self.timer.start(4000)
        self.sigLoaded.connect(lambda: [self.timer.stop(), self.sigUpdateProgress.emit()])

        torque_file = os.path.join(os.path.dirname(geo_file), 'TORQUE.csv')
        if os.path.isfile(torque_file):
            self._torque = TorqueFile(torque_file, params=params)
            try:
                self._torque.read()
            except IncompleteFile:
                QtWidgets.QMessageBox.information(None, "Warning",
                                                  "Incomplete torque file. Only available data will be considered.",
                                                  QtWidgets.QMessageBox.Ok)
            except Exception as err:
                python_exception_dialog(err, parent)
        else:
            self._torque = None
Пример #2
0
 def plot(self, patches):
     if self.simulation is not None:
         geom = self.simulation.geom()
         if geom is not None:
             try:
                 x, y = geom.get_patch_faces(patches)
                 self.plotter.plot(x, y)
             except ValueError as err:
                 qt_error_handling.python_exception_dialog(err, self)
Пример #3
0
 def plot(self):
     if self.torque is not None and self.patches is not None:
         try:
             try:
                 x, y = self.compute_value(self.torque)
                 self.plotter.plot(x, y)
             except NoPatchesError:
                 self.plotter.plot([], [])
         except Exception as error:
             qt_error_handling.python_exception_dialog(error, parent)
Пример #4
0
 def do_plot(self):
     if self.torque is not None and len(self.patches) > 0:
         if self.start_range is not None and self.end_range is not None:
             try:
                 mean, time_steps = self.compute()
                 self.set_mean_value(mean)
                 self.plotter.plot(time_steps, [mean, mean])
             except Exception as err:
                 self.plotter.plot([], [])
                 qt_error_handling.python_exception_dialog(err, self)
Пример #5
0
 def plot_with_exception_handling(self):
     try:
         self.plot()
     except ValueError as err:
         qt_error_handling.python_exception_dialog(err, self)