import os import re import numpy as np from tqdm import tqdm from qdx import BindFilter, Bind binds = [] BF = BindFilter() path = 'result/bind' file_list = os.listdir(path) reg = re.compile(r'(([0-9]{4})-([0-9])-([0-9])).txt') pbar = tqdm(desc="Gaussian Mixture Bind Filter", total=len(file_list)) for file in file_list: name, E, n, m = reg.match(file).groups() file = os.path.join(path, file) BF.filter(file) # BF.draw('result/GMM/' + name + '.png') # np.savetxt('result/bind-GMM/' + name + '.txt', BF.fit_data, fmt='%d') binds.append(Bind(int(E), int(n), int(m), BF.fit_data)) pbar.update(1) pbar.close() pbar = tqdm(desc="Bind Linear Fit", total=len(binds)) for bind in binds: bind.fit() bind.draw('result/L-FIT/' + bind.name + '.png') pbar.update(1) pbar.close()