{ "cells": [ { "cell_type": "markdown", "id": "ea30f0c1-8e35-4b94-a315-ffc812bde023", "metadata": { "tags": [] }, "source": [ "# Overlappogram Simulation Workflow\n", "\n", "Demo workflow for producing a simulated overlappogram.\n", "This is the first conception of the MOXSI overlappogram pipeline.\n", "\n", "1. Compute DEM from AIA+XRT data\n", "2. Compute spectral table as function of $\\lambda$ and $T_e$ from CHIANTI\n", "3. Compute spectral cube by taking outer product of DEM and spectral table\n", "4. Compute instrument intensities by convolving \n", "5. Reproject to detector geometry" ] }, { "cell_type": "code", "execution_count": 1, "id": "87821435-123f-4c0d-bb47-261d21b5f696", "metadata": { "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/jovyan/users_conda_envs/mocksipipeline/lib/python3.9/site-packages/dask_gateway/client.py:21: FutureWarning: format_bytes is deprecated and will be removed in a future release. Please use dask.utils.format_bytes instead.\n", " from distributed.utils import LoopRunner, format_bytes\n", "WARNING: SunpyDeprecationWarning: The `sunpy.io.fits` module is deprecated, as it was designed for internal use. Use the `astropy.fits.io` module instead for more generic functionality to read FITS files. [sunpy.io.fits]\n" ] } ], "source": [ "import sys\n", "import glob\n", "import copy\n", "\n", "import numpy as np\n", "#import jax\n", "#import jax.scipy\n", "#import cupy\n", "#import cupyx.scipy\n", "from scipy.interpolate import interp1d\n", "import astropy.units as u\n", "import astropy.time\n", "import astropy.wcs\n", "import astropy.io.fits\n", "from astropy.coordinates import SkyCoord\n", "import astropy.constants\n", "import matplotlib\n", "import matplotlib.pyplot as plt\n", "from mpl_toolkits.axes_grid1 import make_axes_locatable\n", "import matplotlib.ticker\n", "from sunpy.map import Map, make_fitswcs_header\n", "from sunpy.net import Fido, attrs as a\n", "from sunpy.net.attr import and_,or_\n", "from sunpy.time import TimeRange\n", "from sunpy.coordinates import Helioprojective\n", "import sunpy.io\n", "import sunpy.map.maputils\n", "from ndcube import NDCube, NDCollection\n", "from astropy.nddata import StdDevUncertainty\n", "from astropy.visualization import (ImageNormalize, LogStretch, SqrtStretch, AsinhStretch,\n", " PowerStretch, quantity_support, AsymmetricPercentileInterval)\n", "from aiapy.calibrate import register, estimate_error, correct_degradation\n", "from sunkit_dem import Model\n", "from sunkit_dem.models import HK12Model\n", "import reproject\n", "\n", "import dask\n", "import distributed\n", "import dask.array\n", "from dask.distributed import PipInstall\n", "from dask_gateway import Gateway, GatewayCluster\n", "\n", "from overlappy.reproject import reproject_to_overlappogram\n", "from overlappy.wcs import pcij_matrix, overlappogram_fits_wcs\n", "from overlappy.util import color_lat_lon_axes, strided_array\n", "from overlappy.io import read_overlappogram, write_overlappogram\n", "\n", "sys.path.append('physics/dem')\n", "from dem_models import (get_aia_temperature_response,\n", " get_xrt_temperature_response,\n", " PlowmanModel)\n", "sys.path.append('physics/spectral')\n", "from spectral_utils import read_spectral_table\n", "sys.path.append('detector')\n", "from response import SpectrogramChannel, Channel\n", "\n", "#%load_ext snakeviz" ] }, { "cell_type": "code", "execution_count": 2, "id": "2eb42da4-0c8e-4364-bf88-9fcd2ef42f57", "metadata": {}, "outputs": [], "source": [ "# The following numbers are from Jake and Albert:\n", "CDELT_SPACE = 5.66 * u.arcsec / u.pix\n", "CDELT_WAVE = 55 * u.milliangstrom / u.pix\n", "# This comes from the proposal:\n", "DETECTOR_SHAPE_DISPERSED = (750, 2000)\n", "DETECTOR_SHAPE_PINHOLE = (750, 475)" ] }, { "cell_type": "markdown", "id": "6b7dcbe4-753a-481f-a4ca-8c930d31a55c", "metadata": {}, "source": [ "## Setup Dask Client\n", "\n", "Useful for reprojection and DEM computation" ] }, { "cell_type": "code", "execution_count": 10, "id": "73248b61-d66e-4360-8f74-cf39ab1359bb", "metadata": {}, "outputs": [], "source": [ "gateway = Gateway()\n", "options = gateway.cluster_options()\n", "options.worker_cores=4\n", "options.worker_memory=8" ] }, { "cell_type": "code", "execution_count": 11, "id": "b5279f5a-2f65-4435-bc89-efe922177a11", "metadata": { "tags": [] }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "bcbeef3b31cc422189b46db563931e8c", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(HTML(value='