{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Advanced usage tutorial\n", "\n", "This notebook assumes that you are already familiar with the hiresprv Python package and have run through the process described in the basic data reduction tutorial notebook. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook is meant to be a template to set up your own processing using the code snippets provided here. The notebook may not run exactly as presented if you attempt to run the full notebook directly. The code has not been rigorously tested from within a notebook environemnt.\n", "\n", "\n", "\n", "The notebook is kept with the HIRES PRV Python access toolkit in GitHub: https://github.com/Caltech-IPAC/hiresprv\n", "\n", "You can download and interact with your own copy of this notebook [here](../_static/Advanced_Usage.ipynb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Login\n", "\n", "As described in the basic data reduction tutorial we always need to login to our KOA account first." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "KOA userid: koaadmin\n", "KOA Password: ········\n", "Successful login as koaadmin\n" ] } ], "source": [ "from IPython.display import IFrame\n", "from hiresprv.auth import login\n", "\n", "login('prv.cookies')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Ancillary Tools\n", "\n", "### Workspace Directory Listing\n", "\n", "We can get a list of all the downloadable files in the workspace. There are utility functions (below) for quickly downloading the most-useful final products but we might want to see the intermediate products to evaluate/diagnose the processing. See http://caltech-ipac.github.io/hiresprv/outputs.html#workspace-directory-structure for a description of the files availble in each directory." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "scrolled": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{\n", " \"database\": \"prvState.db\",\n", " \"deblazed\": [\n", " \"deblazed/r20091231.160.fits\",\n", " \"deblazed/r20130629.110.fits\",\n", " \"deblazed/r20091231.287.fits\",\n", " \"deblazed/r20130912.73.fits\",\n", " \"deblazed/r20130912.1.fits\",\n", " \"deblazed/r20130912.128.fits\",\n", " \"deblazed/r20150606.157.fits\",\n", " \"deblazed/r20091231.225.fits\",\n", " \"deblazed/r20130912.163.fits\",\n", " \"deblazed/r20091231.189.fits\",\n", " \"deblazed/r20130629.92.fits\",\n", " \"deblazed/r20150606.97.fits\",\n", " \"deblazed/r20130912.152.fits\",\n", " \"deblazed/r20091231.214.fits\",\n", " \"deblazed/r20150606.166.fits\",\n", " \"deblazed/r20091231.67.fits\",\n", " \"deblazed/r20130912.119.fits\",\n", " \"deblazed/r20091231.151.fits\",\n", " \"deblazed/r20130912.130.fits\",\n", " \"deblazed/r20150606.104.fits\",\n", " \"deblazed/r20091231.276.fits\",\n", " \"deblazed/r20091231.191.fits\",\n", " \"deblazed/r20130912.82.fits\",\n", " \"deblazed/r20130629.19.fits\",\n", " \"deblazed/r20091231.178.fits\",\n", " \"deblazed/r20091231.133.fits\",\n", " \"deblazed/r20130629.108.fits\",\n", " \"deblazed/r20130912.11.fits\",\n", " \"deblazed/r20130629.3.fits\",\n", " \"deblazed/r20091231.96.fits\",\n", " \"deblazed/r20091231.102.fits\",\n", " \"deblazed/r20150606.66.fits\",\n", " \"deblazed/r20091231.3.fits\",\n", " \"deblazed/r20091231.149.fits\",\n", " \"deblazed/r20091231.247.fits\",\n", " \"deblazed/r20150606.135.fits\",\n", " \"deblazed/r20130912.101.fits\",\n", " \"deblazed/r20130629.96.fits\",\n", " \"deblazed/r20150606.129.fits\",\n", " \"deblazed/r20130912.156.fits\",\n", " \"deblazed/r20150606.162.fits\",\n", " \"deblazed/r20091231.210.fits\",\n", " \"deblazed/r20150606.93.fits\",\n", " \"deblazed/r20091231.155.fits\",\n", " \"deblazed/r20130629.114.fits\",\n", " \"deblazed/r20091231.283.fits\",\n", " \"deblazed/r20091231.164.fits\",\n", " \"deblazed/r20130912.5.fits\",\n", " \"deblazed/r20130912.77.fits\",\n", " \"deblazed/r20091231.221.fits\",\n", " \"deblazed/r\n", "... output truncated ...\n" ] } ], "source": [ "import json\n", "import os\n", "from hiresprv.download import Download\n", "\n", "data = Download('prv.cookies', './', debug=True)\n", "\n", "listing = data.directory_listing()\n", "prtstring = json.dumps(listing, indent=4, sort_keys=True)[:2000]\n", "prtstring += \"\\n... output truncated ...\"\n", "\n", "print(prtstring)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### File Download\n", "\n", "Any of the files in the listing can be retrieved by name. We specify the output directory when initializing the Download object." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'status': 'ok', 'msg': ''}\n" ] } ], "source": [ "rtn = data.download(\"deblazed/r20091231.247.fits\")\n", "\n", "print(rtn)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Augmented Processing\n", "\n", "There are no tunable parameters associated with the HIRES PRV pipeline. However, you can affect the processing in a couple of places by \"removing\" files (usually because there is something suspect about them). For instance, a bad B-star observation can adversely affect the stellar template calculation so you may want to rerun the template building without it. We don't actually delete the file; we deactivate it but leave it in place in case you change your mind.\n", "\n", "Similarly, in making the final RV curve you may decide to remove one or more of the reduced RV measurements.\n", "\n", "\n", "### Deactivating Files\n", "\n", "Sometimes it turns out that a data file is suboptimal and should probably be removed from the processing. It might be a B-star observation bracketing a template measurement or one of the RV observations that should be removed from an RV curve.\n", "\n", "The PRV service takes responsibility for remembering what files have been processed and for providing a mechanism (the \"DEACTIVATED\" column in the database) for \"turning off\" specific files. It does not automatically redo all the affected downstream processing. That is left up to the user so it is best to take care of all of that as soon as possible.\n", "\n", "In this example, we will turn off one of the B-star observations. This requires regenerating the template(s) associated with that observation:\n" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "status= ok\n", "msg= Script running in background. Consult monitor for status.\n", "None\n" ] } ], "source": [ "from hiresprv.idldriver import Idldriver\n", "\n", "idl = Idldriver('prv.cookies')\n", "\n", "rtn = idl.run_script(\"\"\"\n", "deactivate r20091231.77\n", "template 185144 20091231\n", "\"\"\")\n", "\n", "print(rtn)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Having regenerated the template, we must therefore regenerate the downstream data (RVs and RV curve). The underlying processing code will not regenerate the reduced RV data if that file already exists so we need to explicitly deactivate the reduced RV files if we intend to re-calculate them:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "status= ok\n", "msg= Script running in background. Consult monitor for status.\n", "None\n" ] } ], "source": [ "from hiresprv.idldriver import Idldriver\n", "\n", "idl = Idldriver('prv.cookies')\n", "\n", "rtn = idl.run_script(\"\"\"\n", "deactivate vdaa185144_r20091231.72\n", "deactivate vdaa185144_r20091231.73\n", "deactivate vdaa185144_r20091231.74\n", "deactivate vdaa185144_r20150606.145\n", "deactivate vdaa185144_r20150606.146\n", "deactivate vdaa185144_r20150606.147\n", "rv 185144 r20091231.72\n", "rv 185144 r20091231.73\n", "rv 185144 r20091231.74\n", "rv 185144 r20150606.145\n", "rv 185144 r20150606.146\n", "rv 185144 r20150606.147\n", "rvcurve 185144\n", "\"\"\")\n", "\n", "print(rtn)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "After further consideration, we decide that the second RV measurement was of inferior quality, so we deactivate it, too. You can find the name of the reduced RV file by listing out the full database again or by doing a database search (if you look a the file name, it follows a simple pattern):" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "scrolled": false }, "outputs": [ { "data": { "text/html": [ "
\n", " | DATE | \n", "OBTYPE | \n", "FILENAME | \n", "TARGET | \n", "BJD | \n", "BCVEL | \n", "
---|---|---|---|---|---|---|
0 | \n", "0 | \n", "Reduced RV | \n", "vdaa185144_r20091231.72 | \n", "rv data | \n", "2440000.0 | \n", "0.0 | \n", "
1 | \n", "0 | \n", "Reduced RV | \n", "vdaa185144_r20091231.73 | \n", "rv data | \n", "2440000.0 | \n", "0.0 | \n", "
2 | \n", "0 | \n", "Reduced RV | \n", "vdaa185144_r20091231.74 | \n", "rv data | \n", "2440000.0 | \n", "0.0 | \n", "
3 | \n", "0 | \n", "Reduced RV | \n", "vdaa185144_r20150606.145 | \n", "rv data | \n", "2440000.0 | \n", "0.0 | \n", "
4 | \n", "0 | \n", "Reduced RV | \n", "vdaa185144_r20150606.146 | \n", "rv data | \n", "2440000.0 | \n", "0.0 | \n", "
5 | \n", "0 | \n", "Reduced RV | \n", "vdaa185144_r20150606.147 | \n", "rv data | \n", "2440000.0 | \n", "0.0 | \n", "