def test_multigroup2(): """Check that implemented averaging gives the same results as SNOP""" base_path = os.path.dirname(__file__) op0 = OpgHdf5.open_file(os.path.join(base_path, 'data/Al_snp_10kgr.h5')) op1 = OpgHdf5.open_file(os.path.join(base_path, 'data/Al_snp_40gr.h5')) group_idx, groups_new = project_on_grid(op1['groups'][:], op0['groups'][:]) res = avg_mg_table(op0, group_idx, fields=['opp_mg', 'opr_mg', 'emp_mg'], weight_pars={'opp_mg': 'planck', 'opr_mg': 'rosseland', 'emp_mg': "planck"}) for key, rtol in {'opp_mg':1e-3, 'opr_mg':1e-3, 'emp_mg':0.7}.items(): yield assert_allclose, op1[key][:], res[key], rtol, 0, 'Not the same '+key
def test_project_on_grid(): points = np.array([1.15, 1.99, 3.4]) grid = np.arange(0, 5, 0.1) idx, proj_points = project_on_grid(points, grid) yield assert_allclose, proj_points, np.array([1.1, 2.0, 3.4])