From 04105f5fe7a1707ae12fe3e5060d599a77d8009b Mon Sep 17 00:00:00 2001 From: Sierra Gomez Date: Mon, 15 Jul 2024 12:37:10 -0400 Subject: [PATCH] CRDS changes, similar to Setup.ipynb notebook --- .../WavelengthAdjustment.ipynb | 43 ++++++++++++------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/notebooks/HASP/WavelengthAdjustment/WavelengthAdjustment.ipynb b/notebooks/HASP/WavelengthAdjustment/WavelengthAdjustment.ipynb index 68e5bf6f8..eb11f7033 100644 --- a/notebooks/HASP/WavelengthAdjustment/WavelengthAdjustment.ipynb +++ b/notebooks/HASP/WavelengthAdjustment/WavelengthAdjustment.ipynb @@ -138,7 +138,7 @@ "id": "500891d8", "metadata": {}, "source": [ - "Since we will be running both `CalCOS` and `CalSTIS`, we will need to set up environment variables for when we use the [Calibration Reference Data System](https://hst-crds.stsci.edu/). Uncomment these lines if you have not set up environment variables for both COS and STIS:" + "Since we will be running both `CalCOS` and `CalSTIS`, we will need to set up environment variables for when we use the [Calibration Reference Data System](https://hst-crds.stsci.edu/). Much of this is gone in detail in the [COS Setup.ipynb](https://github.com/spacetelescope/hst_notebooks/blob/main/notebooks/COS/Setup/Setup.ipynb) notebook." ] }, { @@ -148,11 +148,30 @@ "metadata": {}, "outputs": [], "source": [ - "os.environ['CRDS_SERVER_URL'] = 'https://hst-crds.stsci.edu'\n", - "os.environ['CRDS_SERVER'] = 'https://hst-crds.stsci.edu'\n", - "os.environ['CRDS_PATH'] = './crds_cache'\n", - "os.environ['lref'] = './crds_cache/references/hst/cos/'\n", - "os.environ['oref'] = './crds_cache/references/hst/stis/'" + "# We will set the CRDS_PATH environment_variable\n", + "# Creating path to where the files are saved\n", + "crds_path = os.path.join(os.environ[\"HOME\"], \"crds_cache\")\n", + "\n", + "# Setting the environment variable CRDS_PATH to our CRDS path\n", + "os.environ[\"CRDS_PATH\"] = crds_path\n", + "\n", + "# URL for the STScI CRDS page\n", + "crds_server_url = \"https://hst-crds.stsci.edu\"\n", + "\n", + "# Setting env variable to URL\n", + "os.environ[\"CRDS_SERVER_URL\"] = crds_server_url\n", + "\n", + "# Set the lref environment variable (COS)\n", + "lref = os.path.join(crds_path, \"references/hst/cos\")\n", + "os.environ[\"lref\"] = lref\n", + "\n", + "!crds sync --contexts hst_cos_0355.imap --fetch-references\n", + "\n", + "# Set the oref environment variable (STIS)\n", + "oref = os.path.join(crds_path, \"references/hst/stis\")\n", + "os.environ[\"oref\"] = oref\n", + "\n", + "!crds sync --contexts hst_cos_0368.imap --fetch-references" ] }, { @@ -334,11 +353,7 @@ "\n", "# Now moving all of the original X1Ds to cos_unshifted\n", "for file in glob.glob(f\"{cos_data}/*x1d*\"):\n", - " shutil.move(file, f\"{cos_unshifted}/{os.path.basename(file)}\")\n", - "\n", - "# Getting the references files for when we run CalCOS\n", - "%%capture\n", - "!crds bestrefs --files ./cos_ex/cos_data/*raw*.fits --sync-references=1 --update-bestrefs" + " shutil.move(file, f\"{cos_unshifted}/{os.path.basename(file)}\")" ] }, { @@ -1845,11 +1860,7 @@ " newpath = f\"{stis_unshifted}/{fits.getval(file, 'FILENAME')}\"\n", "\n", " # Moving the actual file\n", - " shutil.move(file, newpath)\n", - "\n", - "# Getting the references files for when we run CalSTIS\n", - "%%capture\n", - "!crds bestrefs --files ./stis_ex/stis_data/*raw*.fits --sync-references=1 --update-bestrefs" + " shutil.move(file, newpath)" ] }, {