def put_file_order(fname): arr = [] aux = [] n = 1 f0 = open(fname).read().split('\n') i = 0 while i < len(f0): if0 = f0[i].split() if len(if0) != n: if n != 1: flaux = phc.flatten(aux) for j in range(n): arr.extend(flaux[j::n]) n = len(if0) aux = [] if len(if0) == 1: arr.extend(if0) else: aux.append(if0) i += 1 return arr
def griddataBAtlas(minfo, models, params, listpar, dims, isig): import pyhdust.phc as phc from scipy.interpolate import griddata idx = range(len(minfo)) lim_vals = len(params)*[ [], ] for i in [i for i in range(len(params)) if i != isig]: lim_vals[i] = [ phc.find_nearest(listpar[i], params[i], bigger=False), phc.find_nearest(listpar[i], params[i], bigger=True)] tmp = np.where((minfo[:, i] == lim_vals[i][0]) | (minfo[:, i] == lim_vals[i][1])) idx = np.intersect1d(idx, tmp) # out_interp = griddata(minfo[idx], models[idx], params)[0] # if (np.sum(out_interp) == 0 or np.sum(np.isnan(out_interp)) > 0): print("# Houve um problema na grade. Tentando arrumar...") print(params) idx = np.arange(len(minfo)) for i in [i for i in range(len(params)) if i != dims["sig0"]]: imin = lim_vals[i][0] if lim_vals[i][0] != np.min(listpar[i]): imin = phc.find_nearest(listpar[i], lim_vals[i][0], bigger=False) imax = lim_vals[i][1] if lim_vals[i][1] != np.max(listpar[i]): imax = phc.find_nearest(listpar[i], lim_vals[i][1], bigger=True) lim_vals[i] = [imin, imax] tmp = np.where((minfo[:, i] >= lim_vals[i][0]) & (minfo[:, i] <= lim_vals[i][1])) idx = np.intersect1d(idx, phc.flatten(tmp)) out_interp = griddata(minfo[idx], models[idx], params)[0] # if (np.sum(out_interp) == 0 or np.sum(np.isnan(out_interp)) > 0): print("# Houve um problema na grade e eu nao conseguir arrumar...") # return out_interp