Beispiel #1
0
    def __init__(self, timestamp, caching=False, set_label=None, temp_label='Sample temperature', recalculate=False):
        """Save all data in 'DATA' dict object"""

        # Various attributes
        self.pickle_format = 'tpd__{}__{}.pickle'
        self.exps = {}
        #self.caching = True if CACHING is True or caching is True else False
        self.caching = caching
        if CACHING is not None:
            self.caching = CACHING
        self.timestamp = {}
        self.timestamp['date'] = timestamp
        self.timestamp['unix'] = time.mktime(datetime.datetime.strptime(
                                             timestamp, "%Y-%m-%d %H:%M:%S").timetuple())
        # Try to load from file
        cache_file = []
        load_from_pickle = False
        if self.caching and not recalculate:
            list_of_files = path.os.listdir(CACHE_DIR)
            for name in list_of_files:
                if name.startswith('tpd__{}__'.format(timestamp)):
                    cache_file.append(name)
            if len(cache_file) == 1:
                with open(path.join(CACHE_DIR, cache_file[0]), 'rb') as f:
                    copy = pickle.load(f)
                    self.name = copy.name
                    self.labels = copy.labels
                    self.data = copy.data
                    self.exps = copy.exps
                load_from_pickle = True
                print(' *** Loaded TPD data from pickle: {} ***'.format(self.name))
            elif len(cache_file) > 1:
                print('Found multiple pickles matching timestamp:\n{}'.format(cache_file))

        # Get data from database
        if load_from_pickle is False:
            # Connect to database
            db = Cinfdata('omicron',
                        use_caching=caching,
                        grouping_column='time',
                        )
            # Get data in unit seconds
            group_data = db.get_data_group(timestamp, scaling_factors=(1E-3, None))
            group_meta = db.get_metadata_group(timestamp)

            # Get a list of labels and group data
            print(group_meta)
            self.name = group_meta[list(group_meta.keys())[0]]['Comment'].replace('/', '')
            self.labels = [group_meta[key]['mass_label'] for key in group_data.keys()]
            self.data = {group_meta[key]['mass_label']: group_data[key] for key in group_data.keys()}
            print('Loaded data from Experiment: "{}"'.format(self.name))
            self.isolate_experiments(set_label=set_label, temp_label=temp_label)
Beispiel #2
0
    def __init__(self, timestamp, caching=False):
        """Save all data in 'DATA' dict object"""

        # Connect to database
        db = Cinfdata('omicron',
                    use_caching=caching,
                    grouping_column='time',
                    )
        # Get data in unit seconds
        group_data = db.get_data_group(timestamp, scaling_factors=(1E-3, None))
        group_meta = db.get_metadata_group(timestamp)
        # Get a list of labels and group data
        self.name = group_meta[list(group_meta.keys())[0]]['Comment']
        self.labels = [group_meta[key]['mass_label'] for key in group_data.keys()]
        self.data = {group_meta[key]['mass_label']: group_data[key] for key in group_data.keys()}
        print('Loaded data from Experiment: "{}"'.format(self.name))
Beispiel #3
0
    def __init__(self, timestamp, caching=True):
        """Save all data in 'DATA' dict object"""

        # Connect to database
        db = Cinfdata('omicron',
                    use_caching=caching,
                    grouping_column='time',
                    )
        # Get data in unit seconds
        group_data = db.get_data_group(timestamp, scaling_factors=(1E-3, None))
        group_meta = db.get_metadata_group(timestamp)
        # Get a list of labels and group data
        self.name = group_meta[list(group_meta.keys())[0]]['Comment']
        self.labels = [group_meta[key]['mass_label'] for key in group_data.keys()]
        self.data = {group_meta[key]['mass_label']: group_data[key] for key in group_data.keys()}
        print('Loaded data from Experiment: "{}"'.format(self.name))