code: def posterior_to_xarray(self):
          
          posterior = self.posterior
          # filter posterior_predictive and log_likelihood
          posterior_predictive = self.posterior_predictive
          if posterior_predictive is None:
              posterior_predictive = []
          elif isinstance(posterior_predictive, str):
              posterior_predictive = [posterior_predictive]
          log_likelihood = self.log_likelihood
          if not isinstance(log_likelihood, str):
              log_likelihood = []
          else:
              log_likelihood = [log_likelihood]
  
          ignore = posterior_predictive + log_likelihood + ["lp__"]
  
          data = get_draws(posterior, ignore=ignore)
  
          return dict_to_dataset(data, library=self.pystan, coords=self.coords, dims=self.dims)
docs: Extract posterior samples from fit.