{ "cells": [ { "cell_type": "markdown", "id": "ba78031a", "metadata": {}, "source": [ "# WLM — crop, align, combine\n", "\n", "Data: [LITTLE THINGS / WLM](https://science.nrao.edu/science/surveys/littlethings/data/wlm.html)\n", "(HI, V, NUV). Full narrative: [examples/wlm](../examples/wlm.md).\n", "\n", "Layer colors red / yellow / blue are **not** the same thing as subtractive\n", "`combine_mode='ryb'` — see the [color compositing guide](../guide/color_compositing.md)." ] }, { "cell_type": "code", "execution_count": null, "id": "7fa31dd2", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import astropy.io.fits as pyfits\n", "import multicolorfits as mcf" ] }, { "cell_type": "markdown", "id": "b442017b", "metadata": {}, "source": [ "## Squeeze and crop HI as the master grid\n", "\n", "`PanelState.load_fits` / `McfSession.load_files` squeeze phantom axes\n", "automatically. Explicit squeeze is only needed when you load arrays by hand." ] }, { "cell_type": "code", "execution_count": null, "id": "317df5e6", "metadata": {}, "outputs": [], "source": [ "# hi, hihdr = pyfits.getdata('./WLM_NA_X0_P_R.FITS', header=True)\n", "# v, vhdr = pyfits.getdata('./wlmv.fits', header=True)\n", "# nuv, nuvhdr = pyfits.getdata('./wlmncut.fit', header=True)\n", "#\n", "# hi = np.squeeze(hi)\n", "# hihdr = mcf.force_header_2d(hihdr)\n", "# hihdr['RADESYS'] = 'FK5'\n", "# hi_simple = mcf.make_simple_header(hihdr, radesys='FK5')\n", "#\n", "# center = mcf.pixel_to_sky(hi_simple, 512, 512)\n", "# hi_c, hi_chdr = mcf.crop_image_sky(\n", "# hi, hi_simple, center, 600., savenew='./wlm_hicrop.fits', overwrite=True)" ] }, { "cell_type": "markdown", "id": "045dec8b", "metadata": {}, "source": [ "## Align companions\n", "\n", "Prefer `align_stack` (or GUI **Align layers…**) when `[reproject]` is installed.\n", "The classic `reproject_image` calls remain available." ] }, { "cell_type": "code", "execution_count": null, "id": "619bdd2e", "metadata": {}, "outputs": [], "source": [ "# # Option A — stack helper\n", "# datas, hdr = mcf.align_stack(\n", "# [hi_c, v, nuv],\n", "# [hi_chdr, mcf.make_simple_header(vhdr), mcf.make_simple_header(nuvhdr)],\n", "# reference=0)\n", "#\n", "# # Option B — explicit reproject onto cropped HI\n", "# # v_c = mcf.reproject_image(v, mcf.make_simple_header(vhdr), hi_chdr)\n", "# # nuv_c = mcf.reproject_image(nuv, mcf.make_simple_header(nuvhdr), hi_chdr)\n", "# # pyfits.writeto('./wlm_vcrop.fits', v_c, hi_chdr, overwrite=True)\n", "# # pyfits.writeto('./wlm_nuvcrop.fits', nuv_c, hi_chdr, overwrite=True)" ] }, { "cell_type": "markdown", "id": "50885b29", "metadata": {}, "source": [ "## Session compose (Lab recommended)" ] }, { "cell_type": "code", "execution_count": null, "id": "e622b387", "metadata": {}, "outputs": [], "source": [ "# s = mcf.McfSession(n_panels=3)\n", "# s.load_files(\n", "# ['./wlm_hicrop.fits', './wlm_vcrop.fits', './wlm_nuvcrop.fits'],\n", "# colors=['#994242', '#FFF9DB', '#1773E9'],\n", "# labels=['HI', 'V', 'NUV'],\n", "# )\n", "# for p, stretch, lo, hi in [\n", "# (s.panels[0], 'asinh', None, None),\n", "# ]:\n", "# p.stretch = 'asinh'\n", "# # Or tweak levels in the GUI:\n", "# # mcf.gui(session=s)\n", "#\n", "# s.compose.combine_mode = 'lab'\n", "# s.compose.combine_blend = 'screen'\n", "# s.compose.gamma = 2.2\n", "# s.compose.title = 'WLM — HI, V, NUV'\n", "# s.save_rgb_fits('./wlm_lab.fits')\n", "# s.save_state('./wlm_session.json')\n", "# print(s.export_script()[:400], '...')" ] }, { "cell_type": "markdown", "id": "b5c6ff5e", "metadata": {}, "source": [ "## Classic colorize path (legacy RGB sum)\n", "\n", "Use absolute/percentile limits via `to_grey_rgb`. Keep\n", "`checkscale=False` for non-interactive runs." ] }, { "cell_type": "code", "execution_count": null, "id": "7b5a0b7c", "metadata": {}, "outputs": [], "source": [ "# hi_g = mcf.to_grey_rgb(hi_c, rescalefn='asinh', scaletype='perc',\n", "# min_max=[1., 99.9], gamma=2.2)\n", "# # ... colorize + combine_multicolor / combine_multicolor_colorspace ..." ] }, { "cell_type": "code", "execution_count": null, "id": "21590560", "metadata": {}, "outputs": [], "source": [ "print('Uncomment after downloading LITTLE THINGS WLM products.')" ] } ], "metadata": { "jupytext": { "formats": "ipynb,py:percent", "kernelspec": { "display_name": "Python 3", "name": "python3" }, "main_language": "python" } }, "nbformat": 4, "nbformat_minor": 5 }