I am trying to use this in practice, and ran into some issues. This is an initial attempt at fixing them. Overview of changes:
Split computation of thin_factor into its own function. This allows the function to work correctly on datasets and datatrees. Otherwise each dataarray is thinned by a different factor, and they eventually get merged together which generates nans to the ones with more agressive filtering.
Add "mode" argument. I found that using mean and np.ceil was sometimes a bit too agressive, so I added an option to use mode="min" to use min and np.floor instead.
Add "target_ess" argument. It is not difficult to do separatedly, but I thought it was a good fit here. In some cases I don't want the "optimal" thinning but as much thinning as possible provided I'll still get an ESS around X. This should take care of that and print a warning if the requested ESS is too big and can't be achieved.
I am trying to use this in practice, and ran into some issues. This is an initial attempt at fixing them. Overview of changes:
thin_factor
into its own function. This allows the function to work correctly on datasets and datatrees. Otherwise each dataarray is thinned by a different factor, and they eventually get merged together which generates nans to the ones with more agressive filtering.mode="min"
to use min and np.floor instead.π Documentation preview π: https://arviz-stats--27.org.readthedocs.build/en/27/