def groupby_params(dict_w_params, params):
    """ Groups `dict_w_params` according the given set of parameters. This
 can be used to e.g. seperate physical from numerical parameters. """
    grouped_dict = {}
    for key, item in dict_w_params.items():
        item_copy = item.copy()
        index_dict = {}
        for param in params:
            if param in item_copy:
                index_dict[param] = item_copy[param]
                del item_copy[param]
        index_tuple = tuple((key, index_dict[key]) for key in sorted(
            index_dict))
        grouped_dict.setdefault(index_tuple, {}).update({key: item_copy})
    return grouped_dict
