Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC: Use AWS S3 buckets #22

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 11 additions & 23 deletions acs_reduction/acs_reduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"|------------------|:-----------------|:-------------:|:------------|\n",
"| `os` | `system` | <a class=\"divlink\" href=\"https://docs.python.org/2/library/os.html#os.system\">link</a>|command line input|\n",
"| `os` | `environ` | <a class=\"divlink\" href=\"https://docs.python.org/2/library/os.html#os.environ\">link</a>| setting environments |\n",
"|`shutil` | `rmtree` | <a class=\"divlink\" href=\"https://docs.python.org/2/library/shutil.html#shutil.rmtree\">link</a>| remove directory tree |\n",
"|`glob` | `glob` | <a class=\"divlink\" href=\"https://docs.python.org/2/library/glob.html#glob.glob\">link</a>| search for files based on Unix shell rules |\n",
"|`astroquery.mast` |`Observations` | <a class=\"divlink\" href=\"https://astroquery.readthedocs.io/en/latest/mast/mast.html\">link</a>| download data from MAST |\n",
"|`astropy.io` | `fits` | <a class=\"divlink\" href=\"http://docs.astropy.org/en/stable/io/fits/\">link</a>| access and update fits files |\n",
Expand All @@ -74,13 +73,11 @@
"outputs": [],
"source": [
"import os\n",
"import shutil\n",
"import glob\n",
"\n",
"from astroquery.mast import Observations\n",
"\n",
"from astropy.io import fits\n",
"from astropy.table import Table\n",
"\n",
"from stwcs import updatewcs"
]
Expand Down Expand Up @@ -111,19 +108,9 @@
"metadata": {},
"outputs": [],
"source": [
"obs_table = Observations.query_criteria(proposal_id=10775, obs_id='J9L960010')\n",
"\n",
"\n",
"dl_table = Observations.download_products(obs_table['obsid'],\n",
" productSubGroupDescription=['RAW', 'ASN', 'SPT'],\n",
" mrp_only=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We'll use the packages `os` and `shutil` to put all of these files in our working directory and do a little housekeeping."
"# Enable 'S3 mode' for module which will return S3-like URLs for FITs files\n",
"# e.g. s3://stpubdata/hst/public/icde/icde43l0q/icde43l0q_drz.fits\n",
"Observations.enable_cloud_dataset()"
]
},
{
Expand All @@ -132,13 +119,12 @@
"metadata": {},
"outputs": [],
"source": [
"for row in dl_table:\n",
" oldfname = row['Local Path']\n",
" newfname = os.path.basename(oldfname)\n",
" os.rename(oldfname, newfname)\n",
" \n",
"# Delete the mastDownload directory and all subdirectories it contains.\n",
"shutil.rmtree('mastDownload')"
"obs_table = Observations.query_criteria(proposal_id=10775, obs_id='J9L960010')\n",
"\n",
"\n",
"dl_table = Observations.download_products(obs_table['obsid'],\n",
" productSubGroupDescription=['RAW', 'ASN', 'SPT'],\n",
" mrp_only=False)"
]
},
{
Expand Down Expand Up @@ -316,6 +302,8 @@
"metadata": {},
"outputs": [],
"source": [
"# TODO: How to tell CRDS to grab from S3 buckets.\n",
"# https://github.com/spacetelescope/crds/issues/571\n",
"for file in raw_files:\n",
" command_line_input = 'crds bestrefs --files {:} --sync-references=1 --update-bestrefs'.format(file)\n",
" os.system(command_line_input)"
Expand Down