{ "cells": [ { "cell_type": "markdown", "id": "8c8138ef-e687-444e-95b1-9797654f3f62", "metadata": {}, "source": [ "# Spectral Axes: Velocity Frames and Doppler Conventions\n", "\n", "In this notebook we show how to change the spectral axis to represent different rest frames and Doppler conventions. In addition, a spectrum is normally\n", "associated with a redshift/radial velocity, which can also be modified. We also show how to save a spectrum in\n", "frequency and velocity space.\n", "\n", "Supported **doppler conventions**: (see also https://www.gb.nrao.edu/~fghigo/gbtdoc/doppler.html)\n", "1. radio\n", "2. relativistic\n", "3. optical\n", "\n", "Some of the supported **rest frames**:\n", "1. itrs - topocentric\n", "2. icrs - barycentric\n", "3. gcrs - geocentric\n", "4. hcrs - heliocentric\n", "5. lsrk, lsrd - Local Standard of Rest (Kinematic or Dynamic)\n", "\n", "Although the `Spectrum.plot()` can plot a spectrum in different frames with different conventions, it does not modify the underlying data and meta-data in the spectrum. To make these persistent (e.g. necessary when writing a spectrum) there is both an in-place and copy operation to modify frame and convention. Here's a dysh command summary that we will cover in this notebook, leaving out the values and arguments that are not relevant:\n", "\n", "```\n", " ta.plot(vel_frame=, doppler_convention=)\n", "\n", " ta.velocity_axis_to(toframe=, doppler_convention=)\n", "\n", " ta.set_frame()\n", " ta.set_convention()\n", "\n", " ta1 = ta.with_frame()\n", " ta2 = ta1.with_velocity_convention()\n", "\n", " ta3 = ta.with_spectral_axis_unit(\"km/s\")\n", "\n", " ta.set_redshift.to()\n", " ta.set_radial_velocity_to()\n", " ta.shift_spectrum_to(redshift=)\n", " ta.shift_spectrum_to(radial_velocity=)\n", "\n", " ta.rest_value =\n", "\n", " # no setters for these\n", " ta.redshift\n", " ta.radial_velocity\n", "```\n", "\n", "\n", "## Loading Modules\n", "We start by loading the modules we will use for the data reduction. \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", "from dysh.spectra.spectrum import Spectrum\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": "c91993b7-fc23-4164-82a6-d8446cf7f5af", "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": "4a3ea33e-0d69-49ba-9aaf-74ac4815f1c7", "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": [ "20:22:11.259 I Resolving test=getps -> AGBT05B_047_01/AGBT05B_047_01.raw.acs/\n" ] } ], "source": [ "filename = dysh_data(test=\"getps\")" ] }, { "cell_type": "markdown", "id": "e05facfd-26bc-484c-8d35-a2f3fa73086d", "metadata": {}, "source": [ "## Data Loading" ] }, { "cell_type": "code", "execution_count": 4, "id": "93a62e3a-c95d-475b-8602-b5b8b7934733", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [ "load" ] }, "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", "