{ "cells": [ { "cell_type": "markdown", "id": "074c7c88", "metadata": {}, "source": [ "# Session JSON and export script\n", "\n", "Both GUIs share `McfSession`. Saving state captures paths, stretches, colors,\n", "and compose settings (not pixel data). `export_script()` writes a standalone\n", "recreation script, including reproject/align steps when they were used.\n", "See [session_model](../guide/session_model.md)." ] }, { "cell_type": "code", "execution_count": null, "id": "0c0b2fa5", "metadata": {}, "outputs": [], "source": [ "import multicolorfits as mcf" ] }, { "cell_type": "markdown", "id": "db0a09d3", "metadata": {}, "source": [ "## Save / load" ] }, { "cell_type": "code", "execution_count": null, "id": "3cfff286", "metadata": {}, "outputs": [], "source": [ "# s = mcf.McfSession()\n", "# s.load_files(['a.fits', 'b.fits'], colors=['#f00', '#0ff'], labels=['A', 'B'])\n", "# s.compose.combine_mode = 'lab'\n", "# s.compose.show_combo_swatch = True\n", "# s.save_state('my_session.json')\n", "#\n", "# s2 = mcf.McfSession()\n", "# warnings = s2.load_state('my_session.json')\n", "# assert warnings == []\n", "#\n", "# # Launch GUI from state:\n", "# # mcf.gui(state='my_session.json')\n", "# # mcf.gui_qt(state='my_session.json')\n", "# # CLI: mcf-web --state my_session.json" ] }, { "cell_type": "markdown", "id": "a8496e15", "metadata": {}, "source": [ "## Growing panel count\n", "\n", "Sessions saved with more than four panels restore full tab counts (up to 16).\n", "In scripts:\n", "\n", "```python\n", "s.add_panel(color='#88FF88')\n", "s.set_n_panels(6)\n", "s.remove_panel(5)\n", "```" ] }, { "cell_type": "markdown", "id": "1a83ce7a", "metadata": {}, "source": [ "## Export script\n", "\n", "```python\n", "text = s.export_script()\n", "open('recreate_plot.py', 'w').write(text)\n", "```\n", "\n", "The emitted script uses public helpers (`load_fits`, stretches, compose flags,\n", "optional `reproject_image` replay) so coauthors can regenerate the figure without\n", "opening the GUI." ] }, { "cell_type": "code", "execution_count": null, "id": "b2f4b95d", "metadata": {}, "outputs": [], "source": [ "print('McfSession.save_state / load_state / export_script')" ] } ], "metadata": { "jupytext": { "formats": "ipynb,py:percent", "kernelspec": { "display_name": "Python 3", "name": "python3" }, "main_language": "python" } }, "nbformat": 4, "nbformat_minor": 5 }