Ejemplo n.º 1
0
    def export(self):
        path = self.test_path
        if self.test_path == 'none':
            path = get_save_directory_name()
        logger.info('Exporting files to %s' % path)
        for data in data_manager.get_growth_data_files():
            filename = data.label + '.csv'
            if self.rename.isChecked():
                filename = path + '/' + data.profile + '_ada.csv'
            else:
                filename = path + '/' + \
                    filename.split('/')[-1].split('.')[0] + '_ada.csv'
            logger.debug('Exporting file %s' % filename)

            # Get the condition data if that option is checked
            conditions = None
            if self.conditions.isChecked():
                for cond_data in data_manager.get_condition_data_files():
                    if data.reactor != cond_data.reactor:
                        continue
                    if data.date != cond_data.date:
                        continue
                    if data.time != cond_data.time:
                        continue
                    conditions = cond_data

            with open(filename, 'w', newline='') as csvfile:
                writer = csv.writer(csvfile)
                name_header = [
                    'Name', data.label, 'Title', data.title, 'Reactor',
                    data.reactor, 'Profile', data.profile
                ]
                writer.writerow(name_header)
                date_header = ['Date', data.date, 'Time', data.time]
                writer.writerow(date_header)
                measurement_header = [
                    data.xaxis.name + ' [' + data.xaxis.unit + ']'
                ]
                for sig in data.signals:
                    measurement_header.append(sig.name + ' [' + sig.unit + ']')
                if conditions is not None:
                    measurement_header.append('Conditions')
                    for sig in conditions.signals:
                        measurement_header.append(sig.name + ' [' + sig.unit +
                                                  ']')
                writer.writerow(measurement_header)
                for i, xdat in enumerate(data.xaxis.data):
                    row = [xdat]
                    for sig in data.signals:
                        row.append(sig.data[i])
                    # Find closest signal time
                    if conditions is not None:
                        row.append('')
                        cond_ind = (np.abs(conditions.xaxis.data -
                                           xdat)).argmin()
                        for sig in conditions.signals:
                            row.append(sig.data[cond_ind])
                    writer.writerow(row)
        self.close()
Ejemplo n.º 2
0
 def load_algem_pro(self, file_name):
     logger.info('Loading an Algem-Pro file %s' % file_name)
     # Read in files from Algem Pro
     algem_data = read_algem_pro(file_name)
     if self.row == -1:
         data_manager.growth_data.add_data(algem_data)
     else:
         data_manager.growth_data.add_replicate(algem_data, self.row)
Ejemplo n.º 3
0
 def load_algem_pro_conditions(self, file_name, downsample):
     logger.info('Loading Algem-Pro condition file %s, downsample %i' %
                 (file_name, downsample))
     # Read in conditions files from Algem Pro
     algem_conditions = read_algem_pro(file_name, downsample)
     if self.row == -1:
         data_manager.condition_data.add_data(algem_conditions)
     else:
         data_manager.condition_data.add_replicate(algem_conditions,
                                                   self.row)
Ejemplo n.º 4
0
 def load_ada(self, file_name):
     logger.info('Loading ADA file %s' % file_name)
     ada_data, condition_data = read_ada(file_name)
     if self.row == -1:
         data_manager.growth_data.add_data(ada_data)
         if condition_data is not None:
             data_manager.condition_data.add_data(condition_data)
     else:
         data_manager.growth_data.add_replicate(ada_data, self.row)
         if condition_data is not None:
             data_manager.condition_data.add_replicate(
                 condition_data, self.row)
Ejemplo n.º 5
0
 def load_psi(self, file_name):
     logger.info('Loading PSI file %s' % file_name)
     # Read in files from Photon System Instruments photobioreactor
     try:
         psi_data, condition_data = read_psi(file_name)
     except Exception as e:
         raise RuntimeError('Error reading file ' + file_name + '\n' +
                            str(e))
     if self.row == -1:
         data_manager.growth_data.add_data(psi_data)
         data_manager.condition_data.add_data(condition_data)
     else:
         data_manager.growth_data.add_replicate(psi_data, self.row)
         data_manager.condition_data.add_replicate(condition_data, self.row)
Ejemplo n.º 6
0
 def load_ip(self, file_name):
     logger.info('Loading IP file %s' % file_name)
     # Read in files from Industrial Plankton
     try:
         ip_data, condition_data = read_ip(file_name)
     except Exception as e:
         raise RuntimeError('Error reading file ' + file_name + '\n' +
                            str(e))
     if self.row == -1:
         data_manager.growth_data.add_data(ip_data)
         data_manager.condition_data.add_data(condition_data)
     else:
         data_manager.growth_data.add_replicate(ip_data, self.row)
         data_manager.condition_data.add_replicate(condition_data, self.row)
Ejemplo n.º 7
0
 def load_microbemeter(self, file_name):
     logger.info('Loading MicrobeMeter file %s' % file_name)
     data_list, condition_data = read_microbemeter(file_name)
     if self.row == -1:
         data_manager.growth_data.add_data(data_list[0])
         n_files = len(data_manager.growth_data.data_files)
         for data in data_list[1:]:
             if self.merge_replicates.isChecked():
                 data_manager.growth_data.add_replicate(data, n_files - 1)
             else:
                 data_manager.growth_data.add_data(data)
         if condition_data is not None:
             data_manager.condition_data.add_data(condition_data)
     else:
         for data in data_list:
             data_manager.growth_data.add_replicate(data, self.row)
Ejemplo n.º 8
0
    def load_algem_ht24(self, file_name):
        logger.info('Loading HT-24 file %s' % file_name)
        # Read in files from Algem HT24 if no details file is provided
        if len(self.details) == 0:
            algem_data_list = read_algem_ht24(file_name)
            for algem_data in algem_data_list:
                data_manager.growth_data.add_data(algem_data)

        # Read in files from Algem HT24 with details file
        else:
            algem_data_list, replicate_data_list = read_algem_ht24_details(
                file_name, self.details[0])
            for algem_data in algem_data_list:
                data_manager.growth_data.add_data(algem_data)
            for replicate in replicate_data_list:
                if self.merge_replicates.isChecked():
                    data_manager.growth_data.add_replicate(
                        replicate[0], replicate[1])
                else:
                    data_manager.growth_data.add_data(replicate[0])
Ejemplo n.º 9
0
    def load_algem_ht24_conditions(self, file_name, downsample):
        logger.info('Loading HT-24 condition file %s, downsample %i' %
                    (file_name, downsample))
        # Read in files from Algem HT24 if details file is provided
        if len(self.details) == 0:
            algem_conditions_list = read_algem_ht24(file_name, downsample)
            for algem_conditions in algem_conditions_list:
                data_manager.condition_data.add_data(algem_conditions)

        # Read in files from Algem HT24 without details file
        else:
            algem_conditions_list, replicate_conditions_list = \
                read_algem_ht24_details(file_name, self.details[0],
                                        downsample)
            for algem_conditions in algem_conditions_list:
                data_manager.condition_data.add_data(algem_conditions)
            for replicate in replicate_conditions_list:
                if self.merge_replicates.isChecked():
                    data_manager.condition_data.add_replicate(
                        replicate[0], replicate[1])
                else:
                    data_manager.condition_data.add_data(replicate[0])
Ejemplo n.º 10
0
    def load_algem_ht24_txt(self, file_name):
        downsample = self.downsample.get_int()

        logger.info('Loading a partial HT-24 file %s, downsample: %i' %
                    (file_name, downsample))
        algem_data_list, rep_algem_data_list, cond_data_list,\
            rep_cond_data_list = read_algem_ht24_txt(file_name, downsample)
        for algem_data in algem_data_list:
            data_manager.growth_data.add_data(algem_data)
        for replicate in rep_algem_data_list:
            if self.merge_replicates.isChecked():
                data_manager.growth_data.add_replicate(replicate[0],
                                                       replicate[1])
            else:
                data_manager.growth_data.add_data(replicate[0])
        for condition_data in cond_data_list:
            data_manager.condition_data.add_data(condition_data)
        for replicate in rep_cond_data_list:
            if self.merge_replicates.isChecked():
                data_manager.condition_data.add_replicate(
                    replicate[0], replicate[1])
            else:
                data_manager.condition_data.add_data(replicate[0])
Ejemplo n.º 11
0
    def _createMenuBar(self):
        logger.info('Creating menu')
        menu_bar = self.menuBar()
        menu_bar.setNativeMenuBar(False)

        file_menu = menu_bar.addMenu("&File")
        self.save_action = QAction('Save plot', self)
        self.save_action.triggered.connect(self.save_plot)
        file_menu.addAction(self.save_action)
        self.export_action = QAction('Export data', self)
        self.export_action.triggered.connect(self.export_files)
        file_menu.addAction(self.export_action)

        help_menu = menu_bar.addMenu("&Help")
        self.docs_action = QAction('Documentation', self)
        self.docs_action.triggered.connect(self.open_docs)
        help_menu.addAction(self.docs_action)
        self.video_action = QAction('Tutorials', self)
        self.video_action.triggered.connect(self.open_video)
        help_menu.addAction(self.video_action)
        self.issues_action = QAction('Issues', self)
        self.issues_action.triggered.connect(self.open_issues)
        help_menu.addAction(self.issues_action)
Ejemplo n.º 12
0
 def save_plot(self):
     logger.info('Saving the correlation plot')
     self.plot.save()
Ejemplo n.º 13
0
 def save_plot(self):
     logger.info('Saving the plot')
     self.plot.save()
Ejemplo n.º 14
0
# Local imports
from ada.gui.main_window import App
import ada.configuration as config
from ada.logger import logger

# Standard imports
import sys

# pyqt5 imports
from PyQt5.QtWidgets import QApplication

if __name__ == '__main__':

    app = QApplication(sys.argv)

    screen = app.primaryScreen()
    size = screen.availableGeometry()
    config.wr = size.width() / 1280.
    config.hr = size.width() / 1280.
    logger.info('Configuring screen dimensions width = %.2f, height = %.2f' %
                (size.width(), size.height()))

    logger.info('Starting application')
    ex = App()

    sys.exit(app.exec_())