Beispiel #1
0
def _build_profile_matrix(group, index, zp, contours):
    # Interpolate to common z
    fp = np.vstack([np.interp(zp, L[0], L[index]) for L in group])
    # Find quantiles
    q, qval = form_quantiles(fp, contours)
    # Build and return data columns
    columns = ["z", "best"] + list("%g%%" % v for v in 100 * q.flatten())
    data = np.vstack((zp, fp[0], np.reshape(qval, (-1, qval.shape[2]))))
    return data, columns
Beispiel #2
0
def _save_residual_data(errors, contours, save):
    _, _, Q, residuals = errors
    k = 1
    for title, x, r in sorted((m.name, Q[m], v) for m, v in residuals.items()):
        p, q = form_quantiles(r.T, contours)
        # TODO: should have columns for R, dR as well.
        data = np.vstack((x, r[:, 0], np.reshape(q, (-1, q.shape[2]))))
        columns = ["q", "best"] + list("%g%%"%v for v in 100*p.flatten())
        _write_file(save+"_resid_contour%d.dat"%k, data, title, columns)
        k += 1
Beispiel #3
0
def _save_profile_data(errors, align, contours, npoints, save):
    profiles, slabs, _, _ = errors
    if align is not None:
        profiles = align_profiles(profiles, slabs, align)
    k = 1
    for title, p in sorted((m.name, p) for m, p in profiles.items()):
        # Find limits of all profiles
        z = np.hstack([line[0] for line in p])
        zp = np.linspace(np.min(z), np.max(z), npoints)
        # Interpolate rho on common z
        rho = np.vstack([np.interp(zp, L[0], L[1]) for L in p])
        p, q = form_quantiles(rho, contours)
        data = np.vstack((zp, rho[0], np.reshape(q, (-1, q.shape[2]))))
        columns = ["z", "best"] + list("%g%%"%v for v in 100*p.flatten())
        _write_file(save+"_rho_contour%d.dat"%k, data, title, columns)
        if len(p[0]) > 3:
            rhoM = np.vstack([np.interp(zp, L[0], L[3]) for L in p])
            p, q = form_quantiles(rhoM, contours)
            data = np.vstack((zp, rhoM[0], np.reshape(q, (-1, q.shape[2]))))
            _write_file(save+"_rhoM_contour%d.dat"%k, data, title, columns)
        k += 1