예제 #1
0
    def __init__(self, config):
        setup = SubfolderHandle(config['folder'], config['subfolder'])

        counter = 0
        for file in setup.fileiter(config['dbfiles']):
            if counter == 0:
                copied = False
                if not exists_and_isfile(config['mother_db']):
                    copy(file, config['mother_db'])
                    copied = True
                info = PySurfDB.info_database(config['mother_db'])
                if 'natoms' not in info['dimensions']:
                    model = True
                else:
                    model = False
                mother_db = PySurfDB.load_database(
                    config['mother_db'],
                    data=info['variables'],
                    dimensions=info['dimensions'],
                    model=model,
                    sp=False)
                counter += 1
                if copied is True:
                    continue

            CombineDBs(mother_db, file, start=config['start_value'])
            print(f"Added file {file} to DB")
예제 #2
0
    def __init__(self, config):
        dbin = PySurfDB.load_database(config['db_in'], read_only=True)
        info = PySurfDB.info_database(config['db_in'])

        self.thresh = config['energy_threshold']
        self.trust_radius_general = config['trust_radius_general']
        self.trust_radius_ci = config['trust_radius_ci']
        self.crd_mode = config['crd_mode']

        if 'natoms' in info['dimensions']:
            model = False
        else:
            model = True
        dbout = PySurfDB.generate_database(config['db_out'],
                                           data=info['variables'],
                                           dimensions=info['dimensions'],
                                           model=model)

        self.crds = None
        for i, crd in enumerate(dbin['crd']):
            if self.crd_mode == 'internal':
                crd = internal(np.copy(crd))
            else:
                crd = np.copy(crd)
            if i % 1000 == 0:
                print(f"Processing point {i}")
            crd_shape = crd.shape
            crd.resize((1, crd.size))
            if self.crds is None:
                self.crds = crd.reshape((1, crd.size))
            else:
                diff = np.diff(dbin.get('energy', i))

                _, (trust_general, trust_ci) = within_trust_radius(
                    crd,
                    self.crds,
                    radius=self.trust_radius_general,
                    radius_ci=self.trust_radius_ci,
                    metric='euclidean')
                if np.min(diff) < self.thresh:
                    if trust_ci is True:
                        continue
                else:
                    if trust_general is True:
                        continue
                self.crds = np.concatenate((self.crds, crd))

            crd.resize(crd_shape)
            for prop in info['variables']:
                dbout.append(prop, dbin.get(prop, i))
            dbout.increase
예제 #3
0
    def __init__(self, main_db, added_db, start=0):

        if not isinstance(main_db, PySurfDB):
            info = PySurfDB.info_database(main_db)
            if 'natoms' in info['dimensions']:
                model = False
            else:
                model = True
            main_db = PySurfDB.load_database(main_db,
                                             dimensions=info['dimensions'],
                                             data=info['variables'],
                                             model=model)
        if not isinstance(added_db, PySurfDB):
            added_db = PySurfDB.load_database(added_db, read_only=True)

        keys_raw = main_db.get_keys()
        keys = []
        for key in keys_raw:
            if main_db.get_dimension(key)[0].isunlimited() is True:
                keys += [key]

        #check whether dbs fit together
        check = True
        for key in keys:
            if key in added_db.get_keys():
                for dim1, dim2 in zip(
                        main_db.get_dimension(key)[1:],
                        added_db.get_dimension(key)[1:]):
                    if dim1.size != dim2.size:
                        check = False
            else:
                check = False
        if check is False:
            print('Error DBs do not fit together by dimensions')
            exit()


#        nn = NextNeighbor(db1)
        for i in range(start, len(added_db)):
            #            min_dist = nn.get(crd)
            #            if min_dist[0] > 0.25:
            for key in keys:
                main_db.append(key, added_db[key][i])
            main_db.increase