Skip to content

Commit

Permalink
CRDS changes, similar to Setup.ipynb notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
srosagomez committed Jul 15, 2024
1 parent 98388bb commit 04105f5
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions notebooks/HASP/WavelengthAdjustment/WavelengthAdjustment.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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."
]
},
{
Expand All @@ -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"
]
},
{
Expand Down Expand Up @@ -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)}\")"
]
},
{
Expand Down Expand Up @@ -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)"
]
},
{
Expand Down

0 comments on commit 04105f5

Please sign in to comment.