{ "cells": [ { "cell_type": "markdown", "id": "8c8138ef-e687-444e-95b1-9797654f3f62", "metadata": {}, "source": [ "# Modifying the Default Values for Surface Error and Aperture Efficiency\n", "\n", "This notebook shows how you can modify the defaults for surface error and aperture efficiency.\n", "We encourage users of the GBT to rely on the Observatory-measured values and functions for surface error and aperture efficiency, which are implemented in dysh. However, advanced users may wish to modify the values or functions; this example shows how to do that.\n" ] }, { "cell_type": "markdown", "id": "61f26081-b9ab-4a4c-bb51-38358ac33a8f", "metadata": {}, "source": [ "## Refresher on Aperture Efficiency and Brightness Scales\n", "The aperture efficiency $\\eta_a$ is determined by:\n", "\n", "$$\\eta_a = \\eta_0~G(ZD) \\exp(-(4\\pi\\epsilon/\\lambda)^2),$$\n", "\n", "where $\\eta_0$ is the long wavelength aperture efficiency, $G(ZD)$ is the gain correction factor\n", "at a zenith distance $ZD$, $\\epsilon$ is the surface error, and $\\lambda$ is the wavelength.\n", "\n", "To scale antenna temperature $T_a$ to brightness tempeature $T_a^*$:\n", "\n", "$$ T_a^* = T_a~\\exp(\\tau~A)/(\\eta_a~\\eta_l),$$\n", "\n", "where $\\tau$ is the zenith opacity, $A$ is the airmass, and $\\eta_l$ is the loss efficiency. To scale to flux $S_\\nu$\n", "\n", "$$ S_\\nu = 2~k~T_a^*/A_p, $$\n", "\n", "where $k$ is Boltzmann's constant is $A_p$ is the physical aperture of the telescope. \n", "\n", "\n" ] }, { "cell_type": "markdown", "id": "0cb232c9-e7a2-4344-a3fe-492f939630eb", "metadata": {}, "source": [ "## What dysh Does\n", "\n", "When you calibrate and scale data through, e.g. \n", "[GBTFITSLoad.getps](https://dysh.readthedocs.io/en/latest/reference/modules/dysh.fits.html#dysh.fits.GBTFITSLoad.getps),\n", "dysh uses the `GBTGainCorrection` class to manage the calculations described above. `GBTGainCorrection` maintains $G(ZD)$ and surface error as a function of date as derived in \n", "[GBT Memo 301](https://library.nrao.edu/public/memos/gbt/GBT_301.pdf). \n", "You can provide your own values for $\\eta_a$ or $\\epsilon$ in the standard calibration routines (you must provide $\\tau$)." ] }, { "cell_type": "markdown", "id": "03ae6cc9-3398-448c-843c-3045f36c0dca", "metadata": {}, "source": [ "## 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", " sb = sdf.getps()\n", " ta = sb.timeaverage()\n" ] }, { "cell_type": "markdown", "id": "814b589f-dab5-4b3b-9866-a5448cdbcf14", "metadata": {}, "source": [ "\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 the data reduction.\n", "from dysh.fits.gbtfitsload import GBTFITSLoad\n", "from astropy import units as u\n", "import numpy as np\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": "d723b880-988b-45b9-9772-01eba8f02571", "metadata": {}, "source": [ "## Setup\n", "\n", "dysh uses a logger to communicate. If you are working in the command\n", "line, then the logging is setup for you. If you are working in a\n", "jupyter lab instance, then you need to set it up. You can do so using\n", "the init_logging function imported above. As an argument, init_logging\n", "takes a number, the verbosity level. level 0 is for error messages\n", "only, 1 for warning, 2 for info and 3 for debug. Here we set it to\n", "level 2." ] }, { "cell_type": "code", "execution_count": 2, "id": "a62c987f-ccb5-4a94-b66b-52fa9b370e2e", "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": [ "13:59:12.102 I Resolving test=getps -> AGBT05B_047_01/AGBT05B_047_01.raw.acs/\n" ] } ], "source": [ "filename = dysh_data(test=\"getps\")" ] }, { "cell_type": "markdown", "id": "e0bf5028-e5b2-43c3-9a0c-6416dc02e2ec", "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": "90d482e1-3953-49da-9be6-49605ae9cf64", "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", "