def get_sets(instance, varname):
    """Get sets that belong to a pyomo Variable or Param
    :param instance: Pyomo Instance
    :param varname: Name of the Pyomo Variable (string)
    :return: A list with the sets that belong to this Param
    """
    var = getattr(instance, varname)

    if var.dim() > 1:
        sets = [pset.getname() for pset in var._index.subsets()]
    else:
        sets = [var._index.name]
    return sets