Using xarray’s quantile() looks correct to me. Just to be precise, these are (Bayesian) credible intervals, not (frequentist) confidence intervals. Alternatively, you can use the arviz hdi() function to get the highest density interval (i.e., the smallest credible interval).
2 Likes