def compare_with_model_2D(X, Y, true_csd, indx, params): boundary_x = [np.min(X), np.max(X)] boundary_y = [np.min(Y), np.max(Y)] true_pots = calculate_potential_2D(true_csd, boundary_x, boundary_y, params['h']) elec_pos = np.array([[X[i, j], Y[i, j]] for i, j in indx]) pots = np.array([[true_pots[i, j]] for i, j in indx]) print elec_pos true_pots = np.atleast_2d(true_pots) k = KCSD(elec_pos, pots, params) k.estimate_pots() k.estimate_csd() rec_csd = k.solver.estimated_csd rec_pot = k.solver.estimated_pots csd_err = get_relative_error(true_csd[:100, :100], rec_csd[:100, :100, 0].T) pot_err = get_relative_error(true_pots[:100, :100], rec_pot[:100, :100, 0].T) print 'true_csd.shape: ', true_csd.shape print 'recstr_csd.shape: ', rec_csd.shape print 'csd_err.shape: ', csd_err.shape plut.plot_comparison_2D(X[1:-1, 1:-1], Y[1:-1, 1:-1], elec_pos, true_csd[1:-1, 1:-1], true_pots[1:-1, 1:-1], rec_csd[1:-1, 1:-1, 0].T, rec_pot[1:-1, 1:-1, 0].T, csd_err[1:-1, 1:-1], pot_err[1:-1, 1:-1])
def compare_with_model_1D(X, true_csd, indx, params): true_pot = calculate_potential_1D(true_csd, [np.min(X), np.max(X)], 0.5) elec_pos = np.array([[X[i]] for i in indx]) pots = np.array([[true_pot[i]] for i in indx]) k = KCSD(elec_pos, pots, params) k.estimate_pots() k.estimate_csd() true_csd = np.atleast_2d(true_csd) true_pot = np.atleast_2d(true_pot) rec_csd = k.solver.estimated_csd rec_pot = k.solver.estimated_pots csd_err = true_csd - rec_csd csd_err = get_relative_error(rec_csd[:, 0], true_csd[0, :]) pot_err = true_pot - rec_pot pot_err = get_relative_error(rec_pot[:, 0], true_pot[0, :]) print 'true_csd.shape: ', true_csd.shape print 'recstr_csd.shape: ', rec_csd.shape print 'csd_err.shape: ', csd_err.shape plut.plot_comparison_1D(X, elec_pos, true_csd[0, :], true_pot[0, :], rec_csd, rec_pot, csd_err, pot_err)
def compare_with_model_1D(X, true_csd, indx, params): true_pot = calculate_potential_1D(true_csd, [np.min(X), np.max(X)], 0.5) elec_pos = np.array([[X[i]] for i in indx]) pots = np.array([[true_pot[i]] for i in indx]) k = KCSD(elec_pos, pots, params) k.estimate_pots() k.estimate_csd() true_csd = np.atleast_2d(true_csd) true_pot = np.atleast_2d(true_pot) rec_csd = k.solver.estimated_csd rec_pot = k.solver.estimated_pots csd_err = true_csd - rec_csd csd_err = get_relative_error(rec_csd[:,0], true_csd[0,:]) pot_err = true_pot - rec_pot pot_err = get_relative_error(rec_pot[:,0], true_pot[0,:]) print 'true_csd.shape: ', true_csd.shape print 'recstr_csd.shape: ', rec_csd.shape print 'csd_err.shape: ', csd_err.shape plut.plot_comparison_1D(X, elec_pos, true_csd[0, :], true_pot[0, :], rec_csd, rec_pot, csd_err, pot_err)