Note

This page is generated from a Jupyter notebook. Download the .ipynb from the sources, or open the paired jupytext .py under docs/tutorials/.

Session JSON and export script#

Both GUIs share McfSession. Saving state captures paths, stretches, colors, and compose settings (not pixel data). export_script() writes a standalone recreation script, including reproject/align steps when they were used. See session_model.

[ ]:
import multicolorfits as mcf

Save / load#

[ ]:
# s = mcf.McfSession()
# s.load_files(['a.fits', 'b.fits'], colors=['#f00', '#0ff'], labels=['A', 'B'])
# s.compose.combine_mode = 'lab'
# s.compose.show_combo_swatch = True
# s.save_state('my_session.json')
#
# s2 = mcf.McfSession()
# warnings = s2.load_state('my_session.json')
# assert warnings == []
#
# # Launch GUI from state:
# # mcf.gui(state='my_session.json')
# # mcf.gui_qt(state='my_session.json')
# # CLI: mcf-web --state my_session.json

Growing panel count#

Sessions saved with more than four panels restore full tab counts (up to 16). In scripts:

s.add_panel(color='#88FF88')
s.set_n_panels(6)
s.remove_panel(5)

Export script#

text = s.export_script()
open('recreate_plot.py', 'w').write(text)

The emitted script uses public helpers (load_fits, stretches, compose flags, optional reproject_image replay) so coauthors can regenerate the figure without opening the GUI.

[ ]:
print('McfSession.save_state / load_state / export_script')