{ "cells": [ { "cell_type": "markdown", "id": "da18aeb2-71a2-4ed9-ab28-564d79542f91", "metadata": {}, "source": [ "# Modifying Metadata\n", "\n", "This notebook shows how to modify the metadata of an SDFITS file using dysh.\n", "\n", "## Background\n", "\n", "We will use a practical example. For observations with the GBT it is recommended to observe a flux density calibrator (see e.g., [Perley & Butler 2017](https://ui.adsabs.harvard.edu/abs/2017ApJS..230....7P/abstract) for a list of calibrator sources and their flux densities) with the same configuration as that used for the science observations. The reason being that the values of the temperature equivalent power of the noise diodes stored in the SDFITS files can be out of date.\n", "\n", "In this example we won't use observations of a flux density calibrator, but instead we will use the analysis of [Goddy et al (2020)](https://ui.adsabs.harvard.edu/abs/2020RNAAS...4....3G/abstract). They find that the temperature stored in the SDFITS files is on average lower than the measured values, so that the temperature must be corrected by 20%\n", "$$\n", "T_{\\rm{CAL,corr}}=1.2\\ T_{\\rm{CAL,file}}\n", "$$\n", "Here we use this to correct the temperature of the noise diode.\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", " ta_plt.savefig()\n", "\n", "\n", "## Loading Modules\n", "We start by loading the modules we will use for this example. " ] }, { "cell_type": "code", "execution_count": 1, "id": "3de88ab1-3ed0-417f-a3a9-33ef711ce5aa", "metadata": {}, "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": "22b6d78d-1489-40a3-ad9b-e313af808f3f", "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": "de4e81c0-6dcd-47ad-8351-5008860e4917", "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": "aad31cf1-092d-48d0-8468-8d50756ecdaa", "metadata": {}, "source": [ "### Data retrieval\n", "\n", "We download the data we will use for this example, if necessary." ] }, { "cell_type": "code", "execution_count": 3, "id": "f610f64f-f951-4ee4-aee4-6d450c2ef851", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "12:26:17.411 I Resolving test=getps -> AGBT05B_047_01/AGBT05B_047_01.raw.acs/\n" ] } ], "source": [ "filename = dysh_data(test=\"getps\")" ] }, { "cell_type": "markdown", "id": "248462cf-06d3-48ff-9cc5-5fa6ad9f8d47", "metadata": {}, "source": [ "### Data loading\n", "\n", "We load the data and inspect its contents." ] }, { "cell_type": "code", "execution_count": 4, "id": "ca5004bd-fbda-4ba3-ab6b-6da604c419ce", "metadata": {}, "outputs": [], "source": [ "sdfits = GBTFITSLoad(filename)" ] }, { "cell_type": "code", "execution_count": 5, "id": "24e047ab-a4bf-447c-90f6-246ee7f9413e", "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", "
| \n", " | TCAL | \n", "PLNUM | \n", "CAL | \n", "INTNUM | \n", "
|---|---|---|---|---|
| 0 | \n", "1.424292 | \n", "1 | \n", "T | \n", "0 | \n", "
| 1 | \n", "1.424292 | \n", "1 | \n", "F | \n", "0 | \n", "
| 2 | \n", "1.452650 | \n", "0 | \n", "T | \n", "0 | \n", "
| 3 | \n", "1.452650 | \n", "0 | \n", "F | \n", "0 | \n", "
| 4 | \n", "1.424292 | \n", "1 | \n", "T | \n", "1 | \n", "
| ... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
| 347 | \n", "1.452650 | \n", "0 | \n", "F | \n", "9 | \n", "
| 348 | \n", "1.424292 | \n", "1 | \n", "T | \n", "10 | \n", "
| 349 | \n", "1.424292 | \n", "1 | \n", "F | \n", "10 | \n", "
| 350 | \n", "1.452650 | \n", "0 | \n", "T | \n", "10 | \n", "
| 351 | \n", "1.452650 | \n", "0 | \n", "F | \n", "10 | \n", "
352 rows × 4 columns
\n", "| \n", " | TCAL | \n", "PLNUM | \n", "
|---|---|---|
| 0 | \n", "1.70915 | \n", "1 | \n", "
| 1 | \n", "1.70915 | \n", "1 | \n", "
| 2 | \n", "1.74318 | \n", "0 | \n", "
| 3 | \n", "1.74318 | \n", "0 | \n", "
| 4 | \n", "1.70915 | \n", "1 | \n", "
| ... | \n", "... | \n", "... | \n", "
| 347 | \n", "1.74318 | \n", "0 | \n", "
| 348 | \n", "1.70915 | \n", "1 | \n", "
| 349 | \n", "1.70915 | \n", "1 | \n", "
| 350 | \n", "1.74318 | \n", "0 | \n", "
| 351 | \n", "1.74318 | \n", "0 | \n", "
352 rows × 2 columns
\n", "