From a03f487a74df41a6d26b050b088dbebc76e6a54a Mon Sep 17 00:00:00 2001 From: Jackie Brown Date: Tue, 29 Oct 2024 21:41:25 -0400 Subject: [PATCH] PEP 8 fixes --- ...oronagraphic_Observation_Feasibility.ipynb | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/notebooks/STIS/contrast_sensitivity/STIS_Coronagraphic_Observation_Feasibility.ipynb b/notebooks/STIS/contrast_sensitivity/STIS_Coronagraphic_Observation_Feasibility.ipynb index 00e6df354..2963f9e77 100644 --- a/notebooks/STIS/contrast_sensitivity/STIS_Coronagraphic_Observation_Feasibility.ipynb +++ b/notebooks/STIS/contrast_sensitivity/STIS_Coronagraphic_Observation_Feasibility.ipynb @@ -153,14 +153,14 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 12, "id": "520b8fa0", "metadata": {}, "outputs": [], "source": [ - "def plot_contrast(texp, tsubexp, peakpixel_countrate, readnoise=8.9, sdark=0.288, \\\n", - " szodi=2.45, searth=1.34, extract_box_size=3, plot_psfintensity=True, target_name=None, feature=None, \\\n", - " comp_sep = None, comp_contrast=None, disk_profile=None, disk_contrast=None, \\\n", + "def plot_contrast(texp, tsubexp, peakpixel_countrate, readnoise=8.9, sdark=0.288, szodi=2.45, \n", + " searth=1.34, extract_box_size=3, plot_psfintensity=True, target_name=None, feature=None, \n", + " comp_sep=None, comp_contrast=None, disk_profile=None, disk_contrast=None, \n", " disk_filename=None, save_fig=None, **kwargs):\n", " \"\"\"\n", " plot_contrast\n", @@ -197,12 +197,12 @@ " \n", " \"\"\"\n", " \n", - " data = np.loadtxt('GO12923raw.dat', usecols=(0,1,2)) \n", + " data = np.loadtxt('GO12923raw.dat', usecols=(0, 1, 2))\n", " # This file corresponds to the azimuthally averaged STIS PSF wings, with column 1 being the radius in arcsecs and\n", " # column 2 is the contrast. This is the PSF intensity that is an optional parameter to plot on the contrast curve.\n", - " rawr =data[:,0]\n", - " rawcont = data[:,1]\n", - " rawcont_error = data[:,2]\n", + " rawr = data[:, 0]\n", + " rawcont = data[:, 1]\n", + " #rawcont_error = data[:, 2]\n", " \n", " spsf = rawcont * peakpixel_countrate # PSF intensity\n", "\n", @@ -213,7 +213,7 @@ " n2poiss = extract_box_size * tsubexp * spsf # poission noise^2\n", "\n", " spec_int = 0.00128*(rawr/0.05071)**(-2.86) \n", - " #empirical fit to the average speckle intensity as a function of radius (Debes et al. 2019)\n", + " # empirical fit to the average speckle intensity as a function of radius (Debes et al. 2019)\n", "\n", " n2spec = (spec_int*tsubexp)**2 * peakpixel_countrate**2 * extract_box_size**2 * tsubexp/texp # speckle noise\n", "\n", @@ -227,18 +227,18 @@ " cperpix_3sigma = totnoise_3sigma / (peakpixel_countrate/0.23*0.5*tsubexp)\n", " cperpix_1sigma = totnoise_1sigma / (peakpixel_countrate/0.23*0.5*tsubexp)\n", " \n", - " contrast_plot = plt.figure(figsize=(14,10))\n", + " contrast_plot = plt.figure(figsize=(14, 10))\n", "\n", - " plt.plot(rawr, cperpix_5sigma, label = 'Predicted Limit 5$\\sigma$', color='lightsteelblue')\n", - " plt.plot(rawr, cperpix_3sigma, label = 'Predicted Limit 3$\\sigma$', color='steelblue')\n", - " plt.plot(rawr, cperpix_1sigma, label = 'Predicted Limit 1$\\sigma$', color='midnightblue')\n", + " plt.plot(rawr, cperpix_5sigma, label=f\"Predicted Limit 5 sigma\", color='lightsteelblue')\n", + " plt.plot(rawr, cperpix_3sigma, label=f\"Predicted Limit 3 sigma\", color='steelblue')\n", + " plt.plot(rawr, cperpix_1sigma, label=f\"Predicted Limit 1 sigma\", color='midnightblue')\n", "\n", " plt.fill_between(rawr, cperpix_5sigma, color='lightsteelblue')\n", " plt.fill_between(rawr, cperpix_3sigma, color='steelblue')\n", " plt.fill_between(rawr, cperpix_1sigma, color='midnightblue')\n", "\n", - " if plot_psfintensity == True: # option to plot the PSF intensity on the contrast plot\n", - " plt.plot(rawr, rawcont, ls='--', label = 'PSF Intensity', color='black', linewidth=2)\n", + " if plot_psfintensity: # option to plot the PSF intensity on the contrast plot\n", + " plt.plot(rawr, rawcont, ls='--', label='PSF Intensity', color='black', linewidth=2)\n", " else:\n", " None \n", " \n", @@ -267,9 +267,9 @@ " raise NameError(\"Surface brightness profile file name is not specified.\")\n", " \n", " diskfilename = disk_filename\n", - " disk_sb_profile = np.loadtxt(diskfilename, usecols=(0,1)) # contrast as a function of radius, rawr here is in arcsecs\n", - " disk_r = disk_sb_profile[:,0]\n", - " disk_cont = disk_sb_profile[:,1] \n", + " disk_sb_profile = np.loadtxt(diskfilename, usecols=(0, 1)) # contrast as a function of radius, rawr here is in arcsecs\n", + " disk_r = disk_sb_profile[:, 0]\n", + " disk_cont = disk_sb_profile[:, 1]\n", " plt.plot(disk_r, disk_cont, ls='--', linewidth=4, color='orange', label=target_name)\n", " \n", " elif diskprofile == None:\n", @@ -284,15 +284,15 @@ " plt.legend(fontsize=18, loc='best', markerscale=0.5)\n", " plt.xlabel('Separation (\")', fontsize=20)\n", " plt.ylabel('Contrast Sensitivity', fontsize=20)\n", - " plt.xlim(0.2,1.2)\n", + " plt.xlim(0.2, 1.2)\n", " plt.yscale('log')\n", " plt.tick_params(axis='both', which='both', labelsize=20, size=6)\n", " \n", " if 'save_fig' not in kwargs:\n", " None\n", " else:\n", - " savefig=kwargs['save_fig']\n", - " if savefig == True:\n", + " savefig = kwargs['save_fig']\n", + " if savefig:\n", " contrast_plot.savefig('STIS_contrast_plot_'+target_name+'.pdf')" ] }, @@ -433,7 +433,7 @@ ], "metadata": { "kernelspec": { - "display_name": "stis", + "display_name": "test", "language": "python", "name": "python3" }, @@ -447,7 +447,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.10" + "version": "3.12.4" } }, "nbformat": 4,