Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

dev notebooks #9

Merged
merged 14 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
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
260 changes: 120 additions & 140 deletions calstis/calstis_2d_ccd.html

Large diffs are not rendered by default.

261 changes: 121 additions & 140 deletions calstis/calstis_2d_ccd.ipynb

Large diffs are not rendered by default.

205 changes: 107 additions & 98 deletions cross-correlation/cross-correlation.html

Large diffs are not rendered by default.

203 changes: 106 additions & 97 deletions cross-correlation/cross-correlation.ipynb

Large diffs are not rendered by default.

280 changes: 140 additions & 140 deletions custom_ccd_darks/custom_ccd_darks.html

Large diffs are not rendered by default.

292 changes: 143 additions & 149 deletions custom_ccd_darks/custom_ccd_darks.ipynb

Large diffs are not rendered by default.

922 changes: 922 additions & 0 deletions etc_resampling/Resampling.ipynb

Large diffs are not rendered by default.

105 changes: 36 additions & 69 deletions extraction/1D_Extraction.html

Large diffs are not rendered by default.

97 changes: 39 additions & 58 deletions extraction/1D_Extraction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"- `astroquery.mast.Observations` for finding and downloading data from the [MAST](https://mast.stsci.edu/portal/Mashup/Clients/Mast/Portal.html) archive\n",
"- `os` for managing system paths\n",
"- `numpy` to handle array functions\n",
"- `stistools` for operations on STIS Data\n",
"- `matplotlib` for plotting data"
]
},
Expand All @@ -51,48 +50,26 @@
"execution_count": 1,
"id": "bb98f7e5",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/kding/miniconda3/envs/stis/lib/python3.7/site-packages/stsci/tools/nmpfit.py:8: UserWarning: NMPFIT is deprecated - stsci.tools v 3.5 is the last version to contain it.\n",
" warnings.warn(\"NMPFIT is deprecated - stsci.tools v 3.5 is the last version to contain it.\")\n",
"/Users/kding/miniconda3/envs/stis/lib/python3.7/site-packages/stsci/tools/gfit.py:18: UserWarning: GFIT is deprecated - stsci.tools v 3.4.12 is the last version to contain it.Use astropy.modeling instead.\n",
" warnings.warn(\"GFIT is deprecated - stsci.tools v 3.4.12 is the last version to contain it.\"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"The following tasks in the stistools package can be run with TEAL:\n",
" basic2d calstis ocrreject wavecal x1d x2d\n"
]
}
],
"outputs": [],
"source": [
"# Import for: Reading in fits file\n",
"from astropy.io import fits\n",
"from astropy.table import Table\n",
"\n",
"# Import for: Downloading necessary files. (Not necessary if you choose to collect data from MAST)\n",
"# Import for: Downloading necessary files.\n",
"# (Not necessary if you choose to collect data from MAST)\n",
"from astroquery.mast import Observations\n",
"\n",
"# Import for: Managing system variables and paths\n",
"import os\n",
"\n",
"# Import for: Quick Calculation and Data Analysis\n",
"import numpy as np\n",
"\n",
"# Import for: Operations on STIS Data\n",
"import stistools\n",
"# Import for: Managing system variables and paths\n",
"import os\n",
"\n",
"# Import for: Plotting and specifying plotting parameters\n",
"import matplotlib\n",
"%matplotlib inline\n",
"from matplotlib import pyplot as plt\n",
"from matplotlib.ticker import FixedLocator"
"import matplotlib\n",
"%matplotlib inline"
]
},
{
Expand Down Expand Up @@ -128,8 +105,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/odj102010_x1d.fits to ./mastDownload/HST/odj102010/odj102010_x1d.fits ... [Done]\n",
"Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/odj102010_flt.fits to ./mastDownload/HST/odj102010/odj102010_flt.fits ... [Done]\n"
"INFO: Found cached file ./mastDownload/HST/odj102010/odj102010_x1d.fits with expected size 77760. [astroquery.query]\n",
"INFO: Found cached file ./mastDownload/HST/odj102010/odj102010_flt.fits with expected size 10535040. [astroquery.query]\n"
]
}
],
Expand Down Expand Up @@ -211,7 +188,7 @@
"data": {
"text/html": [
"<i>Table length=1</i>\n",
"<table id=\"table140334336153424\" class=\"table-striped table-bordered table-condensed\">\n",
"<table id=\"table140575237431120\" class=\"table-striped table-bordered table-condensed\">\n",
"<thead><tr><th>SPORDER</th><th>WAVELENGTH [1024]</th><th>FLUX [1024]</th><th>EXTRLOCY [1024]</th><th>A2CENTER</th><th>EXTRSIZE</th><th>BK1SIZE</th><th>BK2SIZE</th><th>BK1OFFST</th><th>BK2OFFST</th></tr></thead>\n",
"<thead><tr><th></th><th>Angstroms</th><th>erg / (Angstrom cm2 s)</th><th>pix</th><th>pix</th><th>pix</th><th>pix</th><th>pix</th><th>pix</th><th>pix</th></tr></thead>\n",
"<thead><tr><th>int16</th><th>float64</th><th>float32</th><th>float32</th><th>float32</th><th>float32</th><th>float32</th><th>float32</th><th>float32</th><th>float32</th></tr></thead>\n",
Expand All @@ -233,7 +210,9 @@
}
],
"source": [
"cols = ['SPORDER', 'WAVELENGTH', 'FLUX', 'EXTRLOCY', 'A2CENTER', 'EXTRSIZE','BK1SIZE', 'BK2SIZE', 'BK1OFFST', 'BK2OFFST']\n",
"cols = ['SPORDER', 'WAVELENGTH', 'FLUX', 'EXTRLOCY',\n",
" 'A2CENTER', 'EXTRSIZE', 'BK1SIZE', 'BK2SIZE',\n",
" 'BK1OFFST', 'BK2OFFST']\n",
"Table.read(x1d_filename)[cols]"
]
},
Expand Down Expand Up @@ -267,55 +246,55 @@
"outputs": [],
"source": [
"def show_extraction_regions(x1d_filename, flt_filename, sci_ext=1, row=0, xrange=None, yrange=None):\n",
" \n",
"\n",
" fig, axes = plt.subplots(1, 2, sharey=True)\n",
" fig.tight_layout()\n",
" fig.subplots_adjust(wspace=0.2, hspace=0.2, top=0.88)\n",
" fig.set_figwidth(10)\n",
" fig.set_figheight(5)\n",
" fig.suptitle(os.path.basename(x1d_filename))\n",
" \n",
"\n",
" x1d = fits.getdata(x1d_filename, ext=sci_ext)[row]\n",
" flt = fits.getdata(flt_filename, ext=('SCI', sci_ext))\n",
" \n",
"\n",
" # LEFT & Right PLOTS:\n",
" for ax in axes[0:2]:\n",
" # Display the 2D FLT spectrum on the left:\n",
" ax.imshow(flt, origin='lower', interpolation='none', aspect='auto', \n",
" vmin=-6, vmax=15)\n",
" ax.imshow(flt, origin='lower', interpolation='none', aspect='auto',\n",
" vmin=-6, vmax=15)\n",
" ax.set_xlabel('X')\n",
" ax.set_ylabel('Y')\n",
"\n",
" # Right PLOT:\n",
" axes[1].set_title(f\"A2CENTER={x1d['A2CENTER']:.2f}\")\n",
" # Extraction region in red:\n",
" axes[1].plot(np.arange(1024), \n",
" axes[1].plot(np.arange(1024),\n",
" x1d['EXTRLOCY'] - 1, 'r:', alpha=0.6)\n",
" axes[1].plot(np.arange(1024), \n",
" axes[1].plot(np.arange(1024),\n",
" x1d['EXTRLOCY'] - 1 - x1d['EXTRSIZE']//2,\n",
" color='red', alpha=0.6)\n",
" axes[1].plot(np.arange(1024), \n",
" axes[1].plot(np.arange(1024),\n",
" x1d['EXTRLOCY'] - 1 + x1d['EXTRSIZE']//2,\n",
" color='red', alpha=0.6)\n",
" # Background regions in orange:\n",
" axes[1].plot(np.arange(1024), \n",
" axes[1].plot(np.arange(1024),\n",
" x1d['EXTRLOCY'] - 1 + x1d['BK1OFFST'] - x1d['BK1SIZE']//2,\n",
" color='orange', alpha=0.6)\n",
" axes[1].plot(np.arange(1024), \n",
" axes[1].plot(np.arange(1024),\n",
" x1d['EXTRLOCY'] - 1 + x1d['BK1OFFST'] + x1d['BK1SIZE']//2,\n",
" color='orange', alpha=0.6)\n",
" axes[1].plot(np.arange(1024), \n",
" x1d['EXTRLOCY'] - 1 + x1d['BK2OFFST'] - x1d['BK2SIZE']//2, \n",
" axes[1].plot(np.arange(1024),\n",
" x1d['EXTRLOCY'] - 1 + x1d['BK2OFFST'] - x1d['BK2SIZE']//2,\n",
" color='orange', alpha=0.6)\n",
" axes[1].plot(np.arange(1024), \n",
" x1d['EXTRLOCY'] - 1 + x1d['BK2OFFST'] + x1d['BK2SIZE']//2, \n",
" axes[1].plot(np.arange(1024),\n",
" x1d['EXTRLOCY'] - 1 + x1d['BK2OFFST'] + x1d['BK2SIZE']//2,\n",
" color='orange', alpha=0.6)\n",
" \n",
"\n",
" axes[0].set_xlim(-0.5, 1023.5)\n",
" axes[0].set_ylim(-0.5, 1023.5)\n",
" axes[1].set_xlim(-0.5, 1023.5)\n",
" axes[1].set_ylim(-0.5, 1023.5)\n",
" \n",
"\n",
" if xrange is not None:\n",
" axes[0].set_xlim(xrange[0], xrange[1])\n",
" axes[1].set_xlim(xrange[0], xrange[1])\n",
Expand Down Expand Up @@ -428,8 +407,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/octx01030_x1d.fits to ./mastDownload/HST/octx01030/octx01030_x1d.fits ... [Done]\n",
"Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/octx01030_flt.fits to ./mastDownload/HST/octx01030/octx01030_flt.fits ... [Done]\n"
"INFO: Found cached file ./mastDownload/HST/octx01030/octx01030_x1d.fits with expected size 7629120. [astroquery.query]\n",
"INFO: Found cached file ./mastDownload/HST/octx01030/octx01030_flt.fits with expected size 84139200. [astroquery.query]\n"
]
}
],
Expand All @@ -441,7 +420,9 @@
"# get a list of files assiciated with that target\n",
"echelle_list = Observations.get_product_list(target)\n",
"# Download fits files\n",
"result = Observations.download_products(echelle_list, extension=['_flt.fits', '_x1d.fits'], productType=['SCIENCE',])\n",
"result = Observations.download_products(echelle_list,\n",
" extension=['_flt.fits', '_x1d.fits'],\n",
" productType=['SCIENCE'])\n",
"echelle_flt = os.path.join(f'./mastDownload/HST/{obs_id}/{obs_id}_flt.fits')\n",
"echelle_x1d = os.path.join(f'./mastDownload/HST/{obs_id}/{obs_id}_x1d.fits')"
]
Expand Down Expand Up @@ -471,7 +452,7 @@
"data": {
"text/html": [
"<i>Table length=24</i>\n",
"<table id=\"table140333506431376\" class=\"table-striped table-bordered table-condensed\">\n",
"<table id=\"table140575098642512\" class=\"table-striped table-bordered table-condensed\">\n",
"<thead><tr><th>SPORDER</th><th>WAVELENGTH [1024]</th><th>FLUX [1024]</th><th>EXTRLOCY [1024]</th><th>EXTRSIZE</th><th>BK1SIZE</th><th>BK2SIZE</th><th>BK1OFFST</th><th>BK2OFFST</th></tr></thead>\n",
"<thead><tr><th></th><th>Angstroms</th><th>erg / (Angstrom cm2 s)</th><th>pix</th><th>pix</th><th>pix</th><th>pix</th><th>pix</th><th>pix</th></tr></thead>\n",
"<thead><tr><th>int16</th><th>float64</th><th>float32</th><th>float32</th><th>float32</th><th>float32</th><th>float32</th><th>float32</th><th>float32</th></tr></thead>\n",
Expand Down Expand Up @@ -591,9 +572,9 @@
"\n",
"---\n",
"## About this Notebook <a class=\"tocSkip\">\n",
"**Author:** [Keyi Ding](kding@stsci.edu)\n",
"**Author:** Keyi Ding\n",
"\n",
"**Updated On:** 2023-01-05\n",
"**Updated On:** 2023-05-18\n",
"\n",
"\n",
"> *This tutorial was generated to be in compliance with the [STScI style guides](https://github.com/spacetelescope/style-guides) and would like to cite the [Jupyter guide](https://github.com/spacetelescope/style-guides/blob/master/templates/example_notebook.ipynb) in particular.*\n",
Expand All @@ -602,13 +583,13 @@
"If you use `astropy`, `matplotlib`, `astroquery`, or `numpy` for published research, please cite the\n",
"authors. Follow these links for more information about citations:\n",
"\n",
"* [Citing `astropy`/`numpy`/`matplotlib`](https://www.scipy.org/citing.html)\n",
"* [Citing `astropy`](https://www.astropy.org/acknowledging.html)/[`numpy`](https://numpy.org/citing-numpy/)/[`matplotlib`](https://matplotlib.org/stable/users/project/citing.html)\n",
"* [Citing `astroquery`](https://astroquery.readthedocs.io/en/latest/)\n",
"\n",
"---\n",
"\n",
"[Top of Page](#top)\n",
"<img style=\"float: right;\" src=\"https://raw.githubusercontent.com/spacetelescope/notebooks/master/assets/stsci_pri_combo_mark_horizonal_white_bkgd.png\" alt=\"Space Telescope Logo\" width=\"200px\"/> "
"<img style=\"float: right;\" src=\"https://raw.githubusercontent.com/spacetelescope/notebooks/master/assets/stsci_pri_combo_mark_horizonal_white_bkgd.png\" alt=\"Space Telescope Logo\" width=\"200px\"/> \n"
]
},
{
Expand Down
Binary file added syn_phot/filters.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading