This paper studies the data imbalance issue in federated learning. We propose a new model aggregation method based on adaptive clustering, called weighted clustered federated learning (CFL). At each round of model aggregation, we first cluster the participating edge devices based on the cosine similarity of their local gradients, where the similarity threshold can adapt to the time varying divergence of local gradients. Then we perform weighted per-cluster model aggregation on the edge sever. We analyze the convergence rate of the proposed learning framework with respect to the data balance feature of the training dataset. Based on this convergence analysis, the weights for model aggregation are designed to balance the contribution of each cluster. Experimental results demonstrate that the proposed weighted CFL can achieve faster model convergence rate and higher learning accuracy than existing methods in the scenario with imbalanced data.