diff --git a/notebooks/DrizzlePac/Initialization/Initialization.ipynb b/notebooks/DrizzlePac/Initialization/Initialization.ipynb index 04f4398e..3d94c0a3 100644 --- a/notebooks/DrizzlePac/Initialization/Initialization.ipynb +++ b/notebooks/DrizzlePac/Initialization/Initialization.ipynb @@ -131,7 +131,7 @@ "import os\n", "import shutil\n", "import stwcs\n", - "import subprocess " + "import crds " ] }, { @@ -215,7 +215,7 @@ "outputs": [], "source": [ "os.environ['CRDS_SERVER_URL'] = 'https://hst-crds.stsci.edu'\n", - "os.environ['CRDS_PATH'] = os.path.abspath(os.path.join('.', 'reference_files'))" + "os.environ['CRDS_PATH'] = os.path.abspath(os.path.join('.', 'reference_files2'))" ] }, { @@ -231,7 +231,7 @@ "metadata": {}, "outputs": [], "source": [ - "subprocess.check_output('crds bestrefs --files ib2j02n5q_flc.fits --sync-references=1 --update-bestrefs', shell=True, stderr=subprocess.DEVNULL)" + "crds.assign_bestrefs(['ib2j02n5q_flc.fits'], sync_references=True, verbosity=0)" ] }, { @@ -302,7 +302,8 @@ "## About this Notebook\n", "\n", " Author: T. Desjardins, STScI ACS Team \n", - " Updated: December 14, 2018" + " Updated: December 14, 2018\n", + " Updated: June 23, 2020" ] }, { @@ -329,7 +330,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.6" + "version": "3.7.6" } }, "nbformat": 4, diff --git a/notebooks/DrizzlePac/drizzle_wfpc2/drizzle_wfpc2.ipynb b/notebooks/DrizzlePac/drizzle_wfpc2/drizzle_wfpc2.ipynb index 62069c53..7fca4c0b 100644 --- a/notebooks/DrizzlePac/drizzle_wfpc2/drizzle_wfpc2.ipynb +++ b/notebooks/DrizzlePac/drizzle_wfpc2/drizzle_wfpc2.ipynb @@ -40,7 +40,7 @@ "import shutil\n", "import glob\n", "import os\n", - "import subprocess\n", + "import crds\n", "\n", "import matplotlib.pyplot as plt\n", "from astropy.io import fits\n", @@ -119,7 +119,7 @@ "os.environ['CRDS_SERVER_URL'] = 'https://hst-crds.stsci.edu'\n", "os.environ['CRDS_PATH'] = os.path.abspath(os.path.join('.', 'reference_files'))\n", "\n", - "subprocess.check_output('crds bestrefs --files ua0605*_c0m.fits --sync-references=1 --update-bestrefs', shell=True, stderr=subprocess.DEVNULL)\n", + "crds.assign_bestrefs(glob.glob(\"ua0605*_c0m.fits\"), sync_references=True, verbosity=0)\n", "\n", "os.environ['uref'] = os.path.abspath(os.path.join('.', 'reference_files', 'references', 'hst', 'wfpc2')) + os.path.sep" ] @@ -424,7 +424,8 @@ "# About this Notebook\n", "\n", " Author: M. Cara, STScI Data Analysis Tools Branch\n", - " Updated: December 14, 2018" + " Updated: December 14, 2018\n", + " Updated: June 23, 2018" ] } ], @@ -444,7 +445,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.6" + "version": "3.7.6" } }, "nbformat": 4, diff --git a/notebooks/DrizzlePac/using_updated_astrometry_solutions/using_updated_astrometry_solutions.ipynb b/notebooks/DrizzlePac/using_updated_astrometry_solutions/using_updated_astrometry_solutions.ipynb index ec2e22de..578f762a 100644 --- a/notebooks/DrizzlePac/using_updated_astrometry_solutions/using_updated_astrometry_solutions.ipynb +++ b/notebooks/DrizzlePac/using_updated_astrometry_solutions/using_updated_astrometry_solutions.ipynb @@ -59,14 +59,16 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "import glob\n", "import numpy as np\n", "import os\n", "import shutil\n", - "import subprocess \n", + "import crds \n", "\n", "from astropy.io import fits\n", "from astropy.table import Table\n", @@ -85,7 +87,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "os.environ['CRDS_SERVER_URL'] = 'https://hst-crds.stsci.edu'\n", @@ -111,7 +115,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "obsTable = Observations.query_criteria(project='HST',proposal_id='14689',obs_id='ID7307030')\n", @@ -123,7 +129,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "dl_tbl = Observations.download_products(filtered_products, mrp_only=False)\n", @@ -140,7 +148,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "for f in dl_tbl['Local Path']:\n", @@ -159,13 +169,14 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "for row in filtered_products:\n", " if row['productSubGroupDescription'] == 'FLC':\n", - " subprocess.check_output('crds bestrefs --files {}_flc.fits --sync-references=1 --update-bestrefs'.format(row['obs_id']), \\\n", - " shell=True, stderr=subprocess.DEVNULL)\n" + " crds.assign_bestrefs(['{}_flc.fits'.format(row['obs_id'])], sync_references=True, verbosity=0)" ] }, { @@ -185,7 +196,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "filename = 'id7307xfq_flc.fits'" @@ -201,7 +214,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "updatewcs.updatewcs(filename, use_db=True)" @@ -217,7 +232,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "fits.info(filename)" @@ -247,7 +264,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "ext_indices = headerlet.find_headerlet_HDUs(filename, strict=False)\n", @@ -266,7 +285,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "hdu = fits.open(filename)\n", @@ -287,7 +308,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "new_wcsnames = headerlet.get_headerlet_kw_names(filename, kw='WCSNAME')\n", @@ -304,7 +327,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "def get_hdrlet_wcsnames(filename):\n", @@ -326,7 +351,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "new_wcsnames = get_hdrlet_wcsnames(filename)" @@ -342,7 +369,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "current_wcs = fits.getval(filename, 'WCSNAME', ext=('SCI', 1))\n", @@ -385,7 +414,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "# Gets the index of list element with value 'IDC_2731450pi-GSC240'\n", @@ -397,7 +428,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "headerlet.restore_from_headerlet(filename, hdrext=('HDRLET', chosen_ext), archive=False, force=False)" @@ -421,7 +454,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "current_wcs = fits.getval(filename, 'WCSNAME', ext=('SCI', 1))\n", @@ -439,7 +474,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "hdrlet_hdrnames = headerlet.get_headerlet_kw_names(fits.open(filename), 'HDRNAME')\n", @@ -449,7 +486,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "print(desired_hdrname)" @@ -458,7 +497,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "headerlet.restore_from_headerlet(filename, hdrname=desired_hdrname, archive=False, force=False)" @@ -474,7 +515,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "for i, wcsname in enumerate(new_wcsnames):\n", @@ -519,7 +562,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "idc_file = fits.getval(filename, 'IDCTAB')\n", @@ -530,7 +575,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "print(idc_wcsname)" @@ -546,7 +593,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "chosen_ext = new_wcsnames.index(idc_wcsname) + 1" @@ -555,7 +604,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "headerlet.restore_from_headerlet(filename, hdrext=('HDRLET', chosen_ext), archive=False, force=False)" @@ -564,7 +615,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "current_wcs = fits.getval(filename, 'WCSNAME', ext=('SCI', 1))\n", @@ -582,7 +635,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "from stwcs import updatewcs\n", @@ -592,7 +647,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "current_wcs = fits.getval(filename, 'WCSNAME', ext=('SCI', 1))\n", @@ -617,7 +674,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", @@ -635,7 +694,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "from drizzlepac.alignimages import generate_astrometric_catalog\n", @@ -653,7 +714,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "from astropy.wcs import WCS" @@ -662,7 +725,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "hdu = fits.open(filename)\n", @@ -673,7 +738,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "x, y = w.all_world2pix(np.array([ast_tbl['RA'], ast_tbl['DEC']]).T, 0).T" @@ -725,7 +792,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "from drizzlepac import astrodrizzle" @@ -741,7 +810,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "astrodrizzle.AstroDrizzle('id7307030_asn.fits', mdriztab=True, build=True, clean=True, preserve=False)" @@ -764,7 +835,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.0" + "version": "3.7.6" } }, "nbformat": 4,