{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Download data " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Using astroquery" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Download observations from MAST using astroquery for a part of an HST program" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**TL;DR: If you want to download the data from the two visits, execute the script [ on the PACMAN GitHub](https://github.com/sebastian-zieba/PACMAN/blob/master/docs/source/media/download/download_data_astroquery.py).**\n", "\n", "This tutorial was based on the following Jupyter Notebooks on the STScI GitHub that are not accessible anymore:\n", "[(1)](https://github.com/spacetelescope/MAST-API-Notebooks/blob/master/HST/HST_Data_Access.ipynb)\n", "and [(2)](https://github.com/spacetelescope/MAST-API-Notebooks/blob/master/AstroqueryIntro/AstroqueryFunctionalityDemo.ipynb).\n", "\n", "\n", "Here we will download HST data using [astroquery](https://astroquery.readthedocs.io/en/latest/).\n", "\n", "An example script showing how to do this can be found [on the PACMAN GitHub](https://github.com/sebastian-zieba/PACMAN/blob/master/docs/source/media/download/download_data_astroquery.py).\n", "In this tutorial, we are going to have a look at this script using a Jupyter Notebook." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "It is recommended to run this script or jupyter notebook in a new directory.\n", "The fits files will be saved there and this directory will then be used as the \"data directory\".\n", "More on the data directory [here (in the context of the pcf)](https://pacmandocs.readthedocs.io/en/latest/pcf.html#datadir)\n", "and [here](https://pacmandocs.readthedocs.io/en/latest/directories.html#nomenclature)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this example, we are going to analyze just two visits (with index 5 and 6) taken in the middle of the GO13021 program for simplicity:\n", "\n", "Dates (YYYY-MM-DD): 2013-03-13 and 2013-03-15.\n", "\n", "If the user has already downloaded all 15 visits in GO13021 (which should be 1145 files that have the ima extension), they can choose:\n", "which_visits = [5,6] in the pcf (see the [pcf page](https://pacmandocs.readthedocs.io/en/latest/pcf.html#which-visits) about this parameter)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Alternative methods on how to download HST data can be found here: https://pacmandocs.readthedocs.io/en/latest/download_data.html" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's first import some necessary packages." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from astropy.time import Time\n", "import os\n", "from astroquery.mast import Observations" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Set start and end time of the observations in MJD" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We are going to first find out the start and end times of the observations to define the files we want to download.\n", "Looking at the [Visit Status Report for program 13021](https://www.stsci.edu/cgi-bin/get-visit-status?id=13021&markupFormat=html&observatory=HST) we can see the times in UT are:\n", "Note that STScI is using a different indexing for the visits! PACMAN uses a temporally sorted indexing scheme." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "From the website:\n", "\n", "###\n", "\n", "START Mar 13, 2013 12:34:53\n", "\n", "END Mar 13, 2013 18:17:34\n", "\n", "###\n", "\n", "START Mar 15, 2013 02:52:08\n", "\n", "END Mar 15, 2013 08:34:55" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "t_obs_utc = ['2013-03-13T12:34:53', '2013-03-15T08:34:55'] # very start and end of the two visits\n", "t_obs = Time(t_obs_utc, format='isot', scale='utc')" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "