UltraNest
UltraNest copied to clipboard
Documentation enhancement request: run_iter
- UltraNest version: 3.3.2
- Python version: 3.8
- Operating System: Win10 / wsl2Ubuntu2004 / RedHat Linux
Description
Hello @JohannesBuchner! I have a question for you.
I am trying to create corner plots during the execution, as it takes a lot of time and I am equally interested in the intermediate results. I want them to be created controllably often. I don't find in the current documentation (https://johannesbuchner.github.io/UltraNest/ultranest.html?highlight=run_iter) how do I do it.
Can I somehow control this? For example, yield next iterator step every N function calls? Is it update_interval_ncall
? It is written that it is not used...
Also, I see difference in the defaults of run
and run_iter
: update_interval_volume_fraction=0.8 | 0.2
-- is it intended?
What I Did
# truncated code
sampler = ultranest.integrator.ReactiveNestedSample(...)
for i, result in enumerate(sampler.run_iter(**kwargs)):
fig = corner() # piece of code that analyzes current sampler content and plots a corner plot
fig.savefig(f"corner_{i:06d}.pdf") # save current figure with a number
Thank you in advance!
I guess it might be easiest to create corner plots of the live points, because the posterior will be ill defined (all probability in one point) for most of the run.
You can pass a viz_callback
. Have a look at the nicelogger() function or the LivePointsWidget (for jupyter notebooks).
viz_callback
is called every next_update_interval_volume
volume shrinkages. But you do not need to do something in every call.
I would recommend you to use viz_callback to write the points to a text file. Then write another program that visualises it. This will allow you to adapt the visualisation more easily while the other program is running. It also avoids that the fitter (and all its CPUs) has to wait for the visualisation.
To avoid partially written file states, you can write to one filename, then move to the real filename (moves are atomic in most unix filesystems).
This is addressed in master now.