{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "e34b86e9-6438-4e84-8503-d6dd1699e243", "metadata": {}, "outputs": [], "source": [ "# These modules are required for this example.\n", "import numpy as np\n", "import astropy.units as u\n", "from dysh.spectra import tsys_weight\n", "from dysh.spectra import average_spectra\n", "from dysh.fits.gbtfitsload import GBTFITSLoad\n", "from dysh.log import init_logging\n", "\n", "# These modules are used for file I/O\n", "from dysh.util.files import dysh_data\n", "from pathlib import Path" ] }, { "cell_type": "markdown", "id": "9359fc63-3229-4fd3-8631-09c181e6a27b", "metadata": {}, "source": [ "# Using Spectral Weights\n", "\n", "This notebook shows how to weigh Scans and Spectra during averaging and how to find out what weights were used in the process.\n", "\n", "\n", "## Dysh commands\n", "\n", "The following dysh commands are introduced (leaving out all the function arguments):\n", "\n", " filename = dysh_data()\n", " sdf = GBTFITSLoad()\n", " sdf.select()\n", " sb = sdf.getps()\n", " ta = sb.timeaverage()\n", " ta.baseline()\n", " ta.average()\n", " ta.plot()\n", " tsys_weight\n", "\n", "\n", "## Loading Modules\n", "We start by loading the modules we will use for the data reduction. \n" ] }, { "cell_type": "markdown", "id": "d0d455bb-2f40-4585-9d36-a83b7b263d61", "metadata": {}, "source": [ "## Setup\n", "We start the dysh logging, so we get more information about what is happening.\n", "This is only needed if working on a notebook.\n", "If using the CLI through the dysh command, then logging is setup for you." ] }, { "cell_type": "code", "execution_count": 2, "id": "12906fe9-925c-44cb-826e-1cda345bf547", "metadata": {}, "outputs": [], "source": [ "init_logging(2)\n", "\n", "# also create a local \"output\" directory where temporary notebook files can be stored.\n", "output_dir = Path.cwd() / \"output\"\n", "output_dir.mkdir(exist_ok=True)" ] }, { "cell_type": "markdown", "id": "74f02c88-5632-4f64-abda-6e70f63ff0fd", "metadata": {}, "source": [ "## Data Retrieval\n", "\n", "Download the example SDFITS data, if necessary." ] }, { "cell_type": "code", "execution_count": 3, "id": "cf801734-2ba0-48cd-a664-3ca15ce58890", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "20:13:08.282 I Resolving test=getps -> AGBT05B_047_01/AGBT05B_047_01.raw.acs/\n" ] } ], "source": [ "filename = dysh_data(test=\"getps\")" ] }, { "cell_type": "markdown", "id": "66d69520-58ac-46ac-be99-071c5812217c", "metadata": {}, "source": [ "## Data Loading\n", "\n", "Next, we use \n", "[GBTFITSLoad](https://dysh.readthedocs.io/en/latest/reference/modules/dysh.fits.html#dysh.fits.gbtfitsload.GBTFITSLoad) \n", "to load the data, and then its \n", "[summary](https://dysh.readthedocs.io/en/latest/reference/modules/dysh.fits.html#dysh.fits.gbtfitsload.GBTFITSLoad.summary) \n", "method to inspect its contents." ] }, { "cell_type": "code", "execution_count": 4, "id": "fb10b18f-4510-4707-ad2a-70a1ec2b4d79", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SCANOBJECTVELOCITYPROCPROCSEQNRESTFREQDOPFREQ# IF# POL# INT# FEEDAZIMUTHELEVATION
51NGC52914386.0OnOff11.4204051.42040512111198.343118.6427
52NGC52914386.0OnOff21.4204051.42040512111198.930618.7872
53NGC52914386.0OnOff11.4204051.42040512111199.330518.3561
54NGC52914386.0OnOff21.4204051.42040512111199.915718.4927
55NGC52914386.0OnOff11.4204051.42040512111200.304218.0575
56NGC52914386.0OnOff21.4204051.42040512111200.890618.1860
57NGC52914386.0OnOff11.4204051.42040512111202.327517.3853
58NGC52914386.0OnOff21.4204051.42040512111202.919217.4949
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "sdf = GBTFITSLoad(filename)\n", "sdf.summary()" ] }, { "cell_type": "markdown", "id": "17ac95ab-15f2-4f45-80cd-cc9d6ca0f001", "metadata": {}, "source": [ "### Position Switched Calibration\n", "We calibrate several scans at once for NGC5291.\n", "This results in a \n", "[ScanBlock](https://dysh.readthedocs.io/en/latest/reference/modules/dysh.spectra.html#dysh.spectra.scan.ScanBlock) \n", "with 4 scans, each with 11 integrations. \n", "The default weights are unity, with one weight value per integration." ] }, { "cell_type": "code", "execution_count": 5, "id": "d076291b-e69e-4018-ac95-718a7fa3c350", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Number of scans: 4, Number of integrations per scan: [11, 11, 11, 11]\n", "Scan weights: [array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.]), array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.]), array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.]), array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])]\n" ] } ], "source": [ "pssb = sdf.getps(object='NGC5291', ifnum=0, plnum=1, fdnum=0)\n", "print(f\"Number of scans: {len(pssb)}, Number of integrations per scan: {[k.nint for k in pssb]}\")\n", "print(f\"Scan weights: {pssb.weights}\")" ] }, { "cell_type": "markdown", "id": "72bec737-88a0-4208-a3ce-e568f7481ac0", "metadata": {}, "source": [ "## Applying weights when averaging Scans\n", "When time averaging integrations and/or scans to create a final spectrum, you can choose from dysh's two options ('tsys' or None) or supply your own weight array.\n", "\n", "### 1. System temperature weighting\n", "The default for \n", "[timeaverage](https://dysh.readthedocs.io/en/latest/reference/modules/dysh.spectra.html#dysh.spectra.scan.ScanBlock.timeaverage)\n", "is 'tsys' which calculates and applies system temperature weighting to each integration: \n", "\n", "$$\n", "w = t_{exp} \\times \\delta\\nu/T_{sys}^2\n", "$$\n", "\n", "where $t_{exp}$ is the integration exposure time, $\\delta\\nu$ is the channel width, and $T_{sys}$ is the system temperature.\n", "You can check what those weights will be with \n", "[tsys_weight](https://dysh.readthedocs.io/en/latest/reference/modules/dysh.spectra.html#dysh.spectra.scan.SpectralAverageMixin.tsys_weight). " ] }, { "cell_type": "code", "execution_count": 6, "id": "47ff1b7f-bba0-4032-86bd-fc6a22e48b1e", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([array([20.02238592, 19.23775753, 19.89469281, 19.13748516, 19.43619207,\n", " 19.24989036, 19.94781504, 19.81766121, 19.90398672, 19.86791497,\n", " 19.1754635 ]) ,\n", " array([18.94476267, 19.78439063, 19.85434244, 19.90054628, 19.95968097,\n", " 19.08878802, 18.97575899, 18.5760123 , 19.76114768, 19.71441725,\n", " 19.70968407]) ,\n", " array([18.77161334, 19.62257845, 19.70200273, 19.68613794, 19.65882906,\n", " 19.85660591, 19.57284449, 19.60902436, 18.74157248, 18.6538321 ,\n", " 18.75593527]) ,\n", " array([18.44256036, 18.36839774, 18.34613799, 18.39603826, 17.95338427,\n", " 19.04965151, 19.09771163, 19.18475276, 19.09809603, 19.09126971,\n", " 18.34217249]) ],\n", " dtype=object)" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pssb.tsys_weight" ] }, { "cell_type": "markdown", "id": "343f3112-7bbe-4ed0-bd65-506fbf88607b", "metadata": {}, "source": [ "**Technical note:** this is an array of arrays rather than a multidimensional array because different scans may have differing numbers of integrations.\n", "\n", "[timeaverage](https://dysh.readthedocs.io/en/latest/reference/modules/dysh.spectra.html#dysh.spectra.scan.ScanBlock.timeaverage) with the default arguments will use these weights.\n", "The final spectral weight is the sum of all weights.\n", "\n", "In the following lines of code we will time average the $4\\times11$ integrations using the default weights ('tsys'), and then remove a baseline from the resulting time average. For the baseline removal we exclude ranges at the edges of the spectrum and where we know there's a signal. We end by plotting the time averged baseline subtracted spectrum, and printing the weights and statistics." ] }, { "cell_type": "code", "execution_count": 7, "id": "323448e6-7e62-405e-8fb0-89f31b71a730", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "20:13:09.420 I 1370000000.0 Hz is below the minimum spectral axis 1374818364.0 Hz. Replacing.\n", "20:13:09.420 I 1430000000.0 Hz is above the maximum spectral axis 1424816838.1210938 Hz. Replacing.\n", "20:13:09.421 I EXCLUDING [Spectral Region, 1 sub-regions:\n", " (1374818364.0 Hz, 1380000000.0 Hz) \n", ", Spectral Region, 1 sub-regions:\n", " (1395000000.0 Hz, 1405000000.0 Hz) \n", ", Spectral Region, 1 sub-regions:\n", " (1420000000.0 Hz, 1424816838.1210938 Hz) \n", "]\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "35066aec7ea84670bad5c541ed10889e", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(HBox(children=(Button(description='Clear All Regions', style=ButtonStyle(), tooltip='Clear all …" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "final weights=[847.9619254640448 847.9619254640448 847.9619254640448 ...\n", " 847.9619254640448 847.9619254640448 847.9619254640448]\n" ] }, { "data": { "text/plain": [ "{'mean': ,\n", " 'median': ,\n", " 'rms': ,\n", " 'min': ,\n", " 'max': ,\n", " 'npt': 32768,\n", " 'nan': np.int64(0)}" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ta1 = pssb.timeaverage() # default is weights='tsys'\n", "\n", "# Define regions to be excluded from the baseline fit.\n", "exclude_regions = [(1.37*u.GHz,1.38*u.GHz),\n", " (1.395*u.GHz,1.405*u.GHz),\n", " (1.42*u.GHz,1.43*u.GHz)]\n", "\n", "# Fit an order 1 polynomial excluding the ranges defined above and subtract it (remove=True).\n", "ta1.baseline(degree=1, remove=True, exclude=exclude_regions)\n", "\n", "# Plot the result.\n", "ta1.plot(ymin=-0.25, ymax=0.3)\n", "\n", "# Print final weights and statistics.\n", "print(f\"final weights={ta1.weights}\")\n", "ta1.stats() # rms 0.05926608 K" ] }, { "cell_type": "markdown", "id": "bfebebe3-75c9-49b1-b7b5-6f77fc61bb48", "metadata": {}, "source": [ "### 2. Equal weighting\n", "Supplying `weights=None` will weight all integrations the same.\n", "In this case, the result is not much different than `tsys`, because the $T_{sys}$ weights were already pretty uniform.\n", "We also baseline subtract and plot the results." ] }, { "cell_type": "code", "execution_count": 8, "id": "2db0814e-515f-421b-9784-7fd3fcda19a8", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "20:13:09.788 I 1370000000.0 Hz is below the minimum spectral axis 1374818364.0 Hz. Replacing.\n", "20:13:09.789 I 1430000000.0 Hz is above the maximum spectral axis 1424816838.1210938 Hz. Replacing.\n", "20:13:09.789 I EXCLUDING [Spectral Region, 1 sub-regions:\n", " (1374818364.0 Hz, 1380000000.0 Hz) \n", ", Spectral Region, 1 sub-regions:\n", " (1395000000.0 Hz, 1405000000.0 Hz) \n", ", Spectral Region, 1 sub-regions:\n", " (1420000000.0 Hz, 1424816838.1210938 Hz) \n", "]\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "2b1f26c39e5b44a8bf33cfdce5c4710e", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(HBox(children=(Button(description='Clear All Regions', style=ButtonStyle(), tooltip='Clear all …" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "final weights=[4.0 4.0 4.0 ... 4.0 4.0 4.0]\n" ] }, { "data": { "text/plain": [ "{'mean': ,\n", " 'median': ,\n", " 'rms': ,\n", " 'min': ,\n", " 'max': ,\n", " 'npt': 32768,\n", " 'nan': np.int64(0)}" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ta2 = pssb.timeaverage(weights=None) \n", "ta2.baseline(degree=1, remove=True, exclude=exclude_regions)\n", "ta2.plot(ymin=-0.25, ymax=0.3)\n", "print(f\"final weights={ta2.weights}\")\n", "ta2.stats() # rms 0.05928395 K" ] }, { "cell_type": "markdown", "id": "e970084c-b644-41ce-9ec1-f27da8df8c5d", "metadata": {}, "source": [ "### 3. User-supplied weights\n", "You can supply a numpy array of weights to apply. For \n", "[ScanBlock.timeaverage](https://dysh.readthedocs.io/en/latest/reference/modules/dysh.spectra.html#dysh.spectra.scan.ScanBlock.timeaverage) \n", "the weights must have shape `(Nint,)` or `(Nint,nchan)` where `Nint` is the number of integrations in the \n", "[ScanBlock](https://dysh.readthedocs.io/en/latest/reference/modules/dysh.spectra.html#dysh.spectra.scan.ScanBlock) \n", "and `nchan` is the number of channels in each scan. " ] }, { "cell_type": "markdown", "id": "9c50ed94-310b-4ac2-9cff-c6afe49978a0", "metadata": {}, "source": [ "#### 3a. Number of weights equal to number of integrations\n", "We create a slightly silly example, that weights later integrations more." ] }, { "cell_type": "code", "execution_count": 9, "id": "e84271ca-8ba1-4bbc-b451-3cb45fb2a952", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "20:13:10.154 I 1370000000.0 Hz is below the minimum spectral axis 1374818364.0 Hz. Replacing.\n", "20:13:10.155 I 1430000000.0 Hz is above the maximum spectral axis 1424816838.1210938 Hz. Replacing.\n", "20:13:10.155 I EXCLUDING [Spectral Region, 1 sub-regions:\n", " (1374818364.0 Hz, 1380000000.0 Hz) \n", ", Spectral Region, 1 sub-regions:\n", " (1395000000.0 Hz, 1405000000.0 Hz) \n", ", Spectral Region, 1 sub-regions:\n", " (1420000000.0 Hz, 1424816838.1210938 Hz) \n", "]\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "f42da57f98b54d208f793a8027c09a8b", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(HBox(children=(Button(description='Clear All Regions', style=ButtonStyle(), tooltip='Clear all …" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "final weights=[990.0 990.0 990.0 ... 990.0 990.0 990.0]\n" ] } ], "source": [ "w = np.arange(1, pssb.nint+1, dtype=float)\n", "ta3a = pssb.timeaverage(weights=w)\n", "ta3a.baseline(degree=1, remove=True, exclude=exclude_regions)\n", "ta3a.plot(ymin=-0.25, ymax=0.3)\n", "print(f\"final weights={ta3a.weights}\")" ] }, { "cell_type": "markdown", "id": "37ef352f-127a-4dd1-9c1a-c48b5e02f0ed", "metadata": {}, "source": [ "#### 3b. Weights for each channel and integration\n", "Supposed you had a channel-based $T_{sys}$ for each integration and wanted to calculate and apply system temperature weights. \n", "This can be accomplished by giving a weights array to \n", "[ScanBlock.timeaverage](https://dysh.readthedocs.io/en/latest/reference/modules/dysh.spectra.html#dysh.spectra.scan.ScanBlock.timeaverage).\n", "\n", "First we fake a `tsys` array of the correct shape.\n", "Then we calculate system temperate weights using the mean exposure time and mean channel width of the scans." ] }, { "cell_type": "code", "execution_count": 10, "id": "3050d2ba-1a7e-424a-b9a3-a8001077f297", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "tsys=array([[40.44703778, 34.29209002, 33.4027718 , ..., 38.71791603,\n", " 35.28713315, 40.87063212],\n", " [38.05088391, 33.34662369, 42.20490842, ..., 41.80063624,\n", " 38.89300609, 40.57733459],\n", " [35.43088049, 39.82836535, 33.14689888, ..., 33.44782766,\n", " 40.81104733, 34.50116723],\n", " ...,\n", " [44.27286605, 40.55077356, 32.97672831, ..., 40.44991244,\n", " 31.97284355, 39.87806732],\n", " [43.54054032, 37.95174176, 36.0192332 , ..., 30.24616871,\n", " 32.32690178, 40.55712875],\n", " [31.4013107 , 36.35880619, 38.0259688 , ..., 34.22566874,\n", " 42.53679606, 40.73033967]], shape=(44, 32768))\n", "Weights array shape: (44, 32768)\n" ] } ], "source": [ "np.random.seed(123) # make sure we have a fixed seed\n", "tsys = 30 + np.random.rand(pssb.nint, pssb.nchan)*15.0 # Fake system temperature array in the 30-45K range.\n", "# The mean exposure and channel width.\n", "dt = np.mean(np.mean(pssb.exposure))\n", "df = np.mean(np.mean(pssb.delta_freq))\n", "\n", "# Compute new weights using the inverse variance as given by the radiometer equation.\n", "w = tsys_weight(dt, df, tsys)\n", "print(f\"{tsys=}\")\n", "print(f\"Weights array shape: {w.shape}\")" ] }, { "cell_type": "markdown", "id": "0c558e56-a34c-44a7-9913-044689d68e8d", "metadata": {}, "source": [ "Now time average the data using the weights defined above, and repeat the baseline subtraction and plotting." ] }, { "cell_type": "code", "execution_count": 11, "id": "e050e70a-8308-48c3-8c9c-68242a9bd5ee", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "20:13:10.567 I 1370000000.0 Hz is below the minimum spectral axis 1374818364.0 Hz. Replacing.\n", "20:13:10.568 I 1430000000.0 Hz is above the maximum spectral axis 1424816838.1210938 Hz. Replacing.\n", "20:13:10.569 I EXCLUDING [Spectral Region, 1 sub-regions:\n", " (1374818364.0 Hz, 1380000000.0 Hz) \n", ", Spectral Region, 1 sub-regions:\n", " (1395000000.0 Hz, 1405000000.0 Hz) \n", ", Spectral Region, 1 sub-regions:\n", " (1420000000.0 Hz, 1424816838.1210938 Hz) \n", "]\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "6626bb514c3040ad90d3b0dbfaad26c6", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(HBox(children=(Button(description='Clear All Regions', style=ButtonStyle(), tooltip='Clear all …" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "final weights=[243.4369815211293 245.3675937036399 237.113209395157 ...\n", " 242.4000731446227 249.68128171631173 237.80401320732614]\n" ] } ], "source": [ "ta3b = pssb.timeaverage(weights=w)\n", "ta3b.baseline(degree=1, remove=True, exclude=exclude_regions)\n", "ta3b.plot(ymin=-0.25, ymax=0.3)\n", "print(f\"final weights={ta3b.weights}\")" ] }, { "cell_type": "markdown", "id": "b81581a3-cc23-4083-9b27-53a2b8b682cc", "metadata": {}, "source": [ "Note the scan weights have been updated, and are now equal to the weights supplied to the `timeaverage` function, so their shape is now (nint, nchan)." ] }, { "cell_type": "code", "execution_count": 12, "id": "e6396339-d34a-4be5-a3ce-e7072dbc4b56", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(11, 32768)\n", "Are the Scan weights the same as those we defined? True\n" ] } ], "source": [ "print(pssb[0].weights.shape)\n", "print(f\"Are the Scan weights the same as those we defined? {np.all(w[0:11] == pssb[0].weights)}\")" ] }, { "cell_type": "markdown", "id": "057b5182-82af-4772-8d4b-94bf2c2e5ccd", "metadata": {}, "source": [ "## Applying weights when averaging Spectrum\n", "The method \n", "[average_spectra](https://dysh.readthedocs.io/en/latest/reference/modules/dysh.spectra.html#dysh.spectra.spectrum.average_spectra) \n", "can compute weighted averages in 3 ways.\n", "The first two are the usual `weights='tsys'` and `weights=None` options.\n", "The third option, `weights='spectral'` will average the spectra using the values in each of their `weights` array.\n", "Note that \n", "[average_spectra](https://dysh.readthedocs.io/en/latest/reference/modules/dysh.spectra.html#dysh.spectra.spectrum.average_spectra)\n", "is the function used by \n", "[Spectrum.average](https://dysh.readthedocs.io/en/latest/reference/modules/dysh.spectra.html#dysh.spectra.spectrum.Spectrum.average)\n", "to average spectra." ] }, { "cell_type": "code", "execution_count": 13, "id": "aaac52b3-ec8b-47e5-8878-70b286909c90", "metadata": {}, "outputs": [], "source": [ "sp = average_spectra([ta1, ta2, ta3a, ta3b], weights='spectral')\n", "\n", "# but this is the same:\n", "# sp = ta1.average([ ta2, ta3a, ta3b], weights='spectral')" ] }, { "cell_type": "code", "execution_count": 14, "id": "5f2a74a1-e45b-43f1-9696-ec18a1f82b63", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "474e66d9611e49ceb9ad353d221ab0c7", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(HBox(children=(Button(description='Clear All Regions', style=ButtonStyle(), tooltip='Clear all …" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "final weights=[2085.398906985174 2087.329519167685 2079.0751348592016 ...\n", " 2084.3619986086674 2091.6432071803565 2079.765938671371]\n" ] } ], "source": [ "sp.plot(ymin=-0.25, ymax=0.3)\n", "print(f\"final weights={sp.weights}\")" ] }, { "cell_type": "markdown", "id": "bb5f2ea5-4c89-47b7-b2d1-c2c27d66709c", "metadata": {}, "source": [ "## Final Stats\n", "Finally, at the end we compute some statistics over a spectrum, merely as a checksum if the notebook is reproducible." ] }, { "cell_type": "code", "execution_count": 15, "id": "dd29a11c-f2f7-4c2f-a612-0f506795162b", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "20:13:10.781 I rms is OK \n" ] } ], "source": [ "sp.check_stats(0.06025871 * u.K)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.9" } }, "nbformat": 4, "nbformat_minor": 5 }