{ "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": [ "
| SCAN | \n", "OBJECT | \n", "VELOCITY | \n", "PROC | \n", "PROCSEQN | \n", "RESTFREQ | \n", "DOPFREQ | \n", "# IF | \n", "# POL | \n", "# INT | \n", "# FEED | \n", "AZIMUTH | \n", "ELEVATION | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 51 | \n", "NGC5291 | \n", "4386.0 | \n", "OnOff | \n", "1 | \n", "1.420405 | \n", "1.420405 | \n", "1 | \n", "2 | \n", "11 | \n", "1 | \n", "198.3431 | \n", "18.6427 | \n", "
| 52 | \n", "NGC5291 | \n", "4386.0 | \n", "OnOff | \n", "2 | \n", "1.420405 | \n", "1.420405 | \n", "1 | \n", "2 | \n", "11 | \n", "1 | \n", "198.9306 | \n", "18.7872 | \n", "
| 53 | \n", "NGC5291 | \n", "4386.0 | \n", "OnOff | \n", "1 | \n", "1.420405 | \n", "1.420405 | \n", "1 | \n", "2 | \n", "11 | \n", "1 | \n", "199.3305 | \n", "18.3561 | \n", "
| 54 | \n", "NGC5291 | \n", "4386.0 | \n", "OnOff | \n", "2 | \n", "1.420405 | \n", "1.420405 | \n", "1 | \n", "2 | \n", "11 | \n", "1 | \n", "199.9157 | \n", "18.4927 | \n", "
| 55 | \n", "NGC5291 | \n", "4386.0 | \n", "OnOff | \n", "1 | \n", "1.420405 | \n", "1.420405 | \n", "1 | \n", "2 | \n", "11 | \n", "1 | \n", "200.3042 | \n", "18.0575 | \n", "
| 56 | \n", "NGC5291 | \n", "4386.0 | \n", "OnOff | \n", "2 | \n", "1.420405 | \n", "1.420405 | \n", "1 | \n", "2 | \n", "11 | \n", "1 | \n", "200.8906 | \n", "18.1860 | \n", "
| 57 | \n", "NGC5291 | \n", "4386.0 | \n", "OnOff | \n", "1 | \n", "1.420405 | \n", "1.420405 | \n", "1 | \n", "2 | \n", "11 | \n", "1 | \n", "202.3275 | \n", "17.3853 | \n", "
| 58 | \n", "NGC5291 | \n", "4386.0 | \n", "OnOff | \n", "2 | \n", "1.420405 | \n", "1.420405 | \n", "1 | \n", "2 | \n", "11 | \n", "1 | \n", "202.9192 | \n", "17.4949 | \n", "