{ "cells": [ { "cell_type": "markdown", "id": "8c8138ef-e687-444e-95b1-9797654f3f62", "metadata": {}, "source": [ "# Smoothing\n", "\n", "This notebook shows how to use dysh to smooth a spectrum. \n", "\n", "For the example below we will use data from the Position-Switch example again.\n", "The following dysh commands are the simplest to get and smooth a spectrum (leaving out all the function arguments):\n", "\n", " sdf = GBTFITSLoad()\n", " sb = sdf.getps()\n", " ta = sb.timeaverage()\n", " tb = ta.smooth()\n", " tb.plot()\n", "\n", "or if you wish to make use of the Python object chaining you can do this in one line:\n", "\n", " GBTFITSLoad().getps().timeaverage().smooth().plot()\n", "\n", "## Loading Modules\n", "We start by loading the modules we will use for the data reduction. \n", "\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "b4967550-2ca1-4931-b53b-6f9868718490", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [ "import" ] }, "outputs": [], "source": [ "# These modules are required for working with the data.\n", "from dysh.fits.gbtfitsload import GBTFITSLoad\n", "from dysh.log import init_logging\n", "from astropy import units as u\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": "bea96434-ab5d-4c13-9f4e-c20258cad627", "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": "2fb86f56-0d81-4347-916f-f1e3a7893c06", "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": "87669763-8d96-4521-9e81-f69d7213e133", "metadata": {}, "source": [ "## Data Retrieval\n", "\n", "Download the example SDFITS data, if necessary." ] }, { "cell_type": "code", "execution_count": 3, "id": "6bc88bc5-986d-4eae-b1c7-6398cc9ddd5a", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [ "wget" ] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "11:40:07.485 I Resolving test=getps -> AGBT05B_047_01/AGBT05B_047_01.raw.acs/\n" ] } ], "source": [ "filename = dysh_data(test=\"getps\")" ] }, { "cell_type": "markdown", "id": "01c33131-69a2-4021-b184-6f80bb31bb20", "metadata": {}, "source": [ "## Data Loading\n", "\n", "Next, we use `GBTFITSLoad` to load the data, and then its `summary` method to inspect its contents." ] }, { "cell_type": "code", "execution_count": 4, "id": "93a62e3a-c95d-475b-8602-b5b8b7934733", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [ "load" ] }, "outputs": [], "source": [ "sdfits = GBTFITSLoad(filename)" ] }, { "cell_type": "code", "execution_count": 5, "id": "6bf49756-6af2-41ff-8bc0-01d6a973837a", "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", "