{ "cells": [ { "cell_type": "markdown", "id": "09d3b5b1", "metadata": {}, "source": [ "# Save and export\n", "\n", "How to leave a session with rasters, RGB FITS (with provenance), transparent\n", "cutouts, session JSON, and a recreation script. Related:\n", "[saving_outputs guide](../guide/saving_outputs.md),\n", "[component mosaic](component_mosaic.py)." ] }, { "cell_type": "code", "execution_count": null, "id": "88b53467", "metadata": {}, "outputs": [], "source": [ "import multicolorfits as mcf\n", "from multicolorfits.figures import make_combined_figure" ] }, { "cell_type": "markdown", "id": "632a6900", "metadata": {}, "source": [ "## Assume a loaded session\n", "\n", "```python\n", "s = mcf.McfSession()\n", "s.load_files(['a.fits', 'b.fits'], colors=['#C11B17', '#4CC417'], labels=['Hα', '[OIII]'])\n", "s.compose.combine_mode = 'lab'\n", "s.compose.title = 'My nebula'\n", "```" ] }, { "cell_type": "markdown", "id": "188ffcb6", "metadata": {}, "source": [ "## Raster (format from extension)" ] }, { "cell_type": "code", "execution_count": null, "id": "7c36e5db", "metadata": {}, "outputs": [], "source": [ "# rgb = s.render_combined()\n", "# fig, ax = make_combined_figure(s, combined=rgb)\n", "# fig.savefig('out.png', dpi=300, bbox_inches='tight') # also .jpg / .pdf / .svg …\n", "#\n", "# # Publication / stamp-friendly (no ticks):\n", "# s.apply_bare_plot_style(transparent=True)\n", "# fig2, ax2 = make_combined_figure(s)\n", "# fig2.savefig('stamp.png', dpi=200, transparent=True, bbox_inches='tight')" ] }, { "cell_type": "markdown", "id": "561d5a8b", "metadata": {}, "source": [ "## RGB FITS + provenance" ] }, { "cell_type": "code", "execution_count": null, "id": "cf777303", "metadata": {}, "outputs": [], "source": [ "# s.save_rgb_fits('combined_rgb.fits') # 3-plane cube + HISTORY cards\n", "# # Low-level: mcf.save_rgb_fits(path, rgb_array, header)" ] }, { "cell_type": "markdown", "id": "4d0340c6", "metadata": {}, "source": [ "## Transparent cutout (slides / stamps)" ] }, { "cell_type": "code", "execution_count": null, "id": "471ed5b6", "metadata": {}, "outputs": [], "source": [ "# rgba = s.export_transparent_cutout(size=400, alpha_lo=55, alpha_hi=99.5)\n", "# # Or GUI: Export transparent…\n", "# # Helper: mcf.make_transparent_cutout(...)" ] }, { "cell_type": "markdown", "id": "69d43f70", "metadata": {}, "source": [ "## Session JSON and export script" ] }, { "cell_type": "code", "execution_count": null, "id": "b68a64c8", "metadata": {}, "outputs": [], "source": [ "# s.save_state('session.json')\n", "# # later:\n", "# s2 = mcf.McfSession()\n", "# s2.load_state('session.json')\n", "# # mcf.gui(state='session.json')\n", "#\n", "# script = s.export_script()\n", "# open('recreate.py', 'w').write(script)" ] }, { "cell_type": "markdown", "id": "f87c8dac", "metadata": {}, "source": [ "Multi-panel **component mosaics** (hero + per-layer strip) are covered in\n", "[component_mosaic](component_mosaic.py) — that is the preferred multi-panel\n", "figure path; a mosaic button in the GUI is deferred." ] }, { "cell_type": "code", "execution_count": null, "id": "e75cf7d8", "metadata": {}, "outputs": [], "source": [ "print('See guide/saving_outputs.md for details.')" ] } ], "metadata": { "jupytext": { "formats": "ipynb,py:percent", "kernelspec": { "display_name": "Python 3", "name": "python3" }, "main_language": "python" } }, "nbformat": 4, "nbformat_minor": 5 }