Skip to content

Commit

Permalink
Fix codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
Camilla Pacifici committed Oct 11, 2023
1 parent 7635934 commit 00e31b0
Showing 1 changed file with 39 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"outputs": [],
"source": [
"#to use 100% of the browser window\n",
"# To use 100% of the browser window\n",
"from IPython.display import display, HTML\n",
"display(HTML(\"<style>.container { width:100% !important; }</style>\"))"
]
Expand All @@ -57,24 +57,24 @@
},
"outputs": [],
"source": [
"#plotting and tabling\n",
"# Plotting and tabling\n",
"import matplotlib.pyplot as plt\n",
"\n",
"#import astropy\n",
"# Import astropy\n",
"import astropy\n",
"import astropy.units as u\n",
"from astropy.io import fits\n",
"from astropy.nddata import StdDevUncertainty\n",
"from astropy.table import QTable\n",
"\n",
"#import specutils\n",
"# Import specutils\n",
"import specutils\n",
"from specutils import Spectrum1D, SpectralRegion\n",
"from specutils.manipulation import extract_region\n",
"\n",
"#import viztools\n",
"# Import viztools\n",
"import jdaviz\n",
"from jdaviz import Specviz, Mosviz"
"from jdaviz import Specviz"
]
},
{
Expand All @@ -83,13 +83,13 @@
"metadata": {},
"outputs": [],
"source": [
"#customization of matplotlib style\n",
"plt.rcParams[\"figure.figsize\"] = (10,5)\n",
"params={'legend.fontsize':'18','axes.labelsize':'18',\n",
" 'axes.titlesize':'18','xtick.labelsize':'18',\n",
" 'ytick.labelsize':'18','lines.linewidth':2,\n",
" 'axes.linewidth':2,'animation.html': 'html5',\n",
" 'figure.figsize':(8,6)}\n",
"# Customization of matplotlib style\n",
"plt.rcParams[\"figure.figsize\"] = (10, 5)\n",
"params={'legend.fontsize': '18', 'axes.labelsize': '18',\n",
" 'axes.titlesize': '18', 'xtick.labelsize': '18',\n",
" 'ytick.labelsize': '18', 'lines.linewidth': 2,\n",
" 'axes.linewidth': 2, 'animation.html': 'html5',\n",
" 'figure.figsize': (8, 6)}\n",
"plt.rcParams.update(params)\n",
"plt.rcParams.update({'figure.max_open_warning': 0})"
]
Expand All @@ -109,9 +109,9 @@
},
"outputs": [],
"source": [
"print('astropy:',astropy.__version__)\n",
"print('specutils:',specutils.__version__)\n",
"print('jdaviz:',jdaviz.__version__)"
"print('astropy:', astropy.__version__)\n",
"print('specutils:', specutils.__version__)\n",
"print('jdaviz:', jdaviz.__version__)"
]
},
{
Expand Down Expand Up @@ -168,18 +168,18 @@
},
"outputs": [],
"source": [
"for i in range(74,75):\n",
"for i in range(74, 75):\n",
" spec_load = hdu[i+1].data\n",
" wave = spec_load['WAVELENGTH']\n",
" flux = spec_load['FLUX']\n",
" error = spec_load['FLUX_ERROR']\n",
" # mask the parts where the sensitivity in the bandpass is poor\n",
" mask = ((wave>1.34) & (wave<1.66))\n",
" mask = ((wave > 1.34) & (wave < 1.66))\n",
" spec1d = Spectrum1D(spectral_axis=wave[mask]*u.um, \n",
" flux=flux[mask]*u.Jy, \n",
" uncertainty=StdDevUncertainty(error[mask]*u.Jy)) #\n",
" flux=flux[mask]*u.Jy, \n",
" uncertainty=StdDevUncertainty(error[mask]*u.Jy)) #\n",
" \n",
" viz.load_data(spec1d,\"NIRISS 1D {}\".format(str(i+1)))"
" viz.load_data(spec1d, \"NIRISS 1D {}\".format(str(i+1)))"
]
},
{
Expand Down Expand Up @@ -257,7 +257,7 @@
},
"outputs": [],
"source": [
"cont_region = SpectralRegion(1.598*u.um,1.621*u.um)\n",
"cont_region = SpectralRegion(1.598*u.um, 1.621*u.um)\n",
"spec1d_el_code = extract_region(spec1d_line, cont_region)\n",
"print(spec1d_el_code)"
]
Expand All @@ -282,7 +282,7 @@
" print(spec1d_el_viz)\n",
"except:\n",
" print(\"Region was not defined in the GUI\")\n",
" #define spec1d_el_viz as spec1d_el_code\n",
" # Define spec1d_el_viz as spec1d_el_code\n",
" spec1d_el_viz = spec1d_el_code"
]
},
Expand All @@ -299,14 +299,14 @@
"metadata": {},
"outputs": [],
"source": [
"plt.plot(spec1d_line.spectral_axis,spec1d_line.flux, label='data')\n",
"plt.plot(spec1d_el_viz.spectral_axis,spec1d_el_viz.flux, label='subset defined in tool')\n",
"plt.plot(spec1d_el_code.spectral_axis,spec1d_el_code.flux, label='subset defined in code')\n",
"plt.plot(spec1d_line.spectral_axis, spec1d_line.flux, label='data')\n",
"plt.plot(spec1d_el_viz.spectral_axis, spec1d_el_viz.flux, label='subset defined in tool')\n",
"plt.plot(spec1d_el_code.spectral_axis, spec1d_el_code.flux, label='subset defined in code')\n",
"plt.legend()\n",
"plt.xlabel(\"wavelength ({:latex})\".format(spec1d_line.spectral_axis.unit))\n",
"plt.ylabel(\"flux ({:latex})\".format(spec1d_line.flux.unit))\n",
"plt.title(\"NIRISS ID 75\")\n",
"plt.show()\n"
"plt.show()"
]
},
{
Expand Down Expand Up @@ -346,7 +346,7 @@
"metadata": {},
"outputs": [],
"source": [
"viz2.load_data(spec1d_line,\"NIRISS 1D lines\")"
"viz2.load_data(spec1d_line, \"NIRISS 1D lines\")"
]
},
{
Expand All @@ -367,8 +367,8 @@
"outputs": [],
"source": [
"lt = QTable()\n",
"lt['linename'] = ['Hb','[OIII]1','[OIII]2']\n",
"lt['rest'] = [4861.3,4958.9,5006.8]*u.AA\n",
"lt['linename'] = ['Hb', '[OIII]1', '[OIII]2']\n",
"lt['rest'] = [4861.3, 4958.9, 5006.8]*u.AA\n",
"\n",
"viz2.load_line_list(lt)"
]
Expand Down Expand Up @@ -399,11 +399,11 @@
"print()\n",
"\n",
"if spec1d_redshift.redshift != 0.0:\n",
" print(\"NIRISS 1D lines redshift=\",spec1d_redshift.redshift)\n",
" print(\"NIRISS 1D lines redshift=\", spec1d_redshift.redshift)\n",
"else:\n",
" print(\"Redshift was not defined in GUI. Defining it here.\")\n",
" spec1d_redshift.set_redshift_to(2.2138)\n",
" print(\"NIRISS 1D lines redshift=\",spec1d_redshift.redshift)"
" print(\"NIRISS 1D lines redshift=\", spec1d_redshift.redshift)"
]
},
{
Expand Down Expand Up @@ -436,7 +436,7 @@
"metadata": {},
"outputs": [],
"source": [
"viz3.load_data(spec1d_line,\"NIRISS 1D lines\")"
"viz3.load_data(spec1d_line, \"NIRISS 1D lines\")"
]
},
{
Expand Down Expand Up @@ -473,15 +473,15 @@
"source": [
"try:\n",
" dataout3 = viz3.get_spectra()\n",
" spectrum = dataout3[\"NIRISS 1D lines\"] #this is exactly the same as the spec1d_lines loaded a few cells above\n",
" spectrum = dataout3[\"NIRISS 1D lines\"] # This is exactly the same as the spec1d_lines loaded a few cells above\n",
" continuum = dataout3[\"continuum\"]\n",
" model_param = viz3.get_model_parameters()\n",
" print(continuum)\n",
" print(model_param['continuum'])\n",
" \n",
"except:\n",
" print(\"Continuum has not been created. Setting it to 0\")\n",
" continuum = Spectrum1D(spectral_axis=spectrum.spectral_axis, flux= 0.*spectrum.flux)"
" continuum = Spectrum1D(spectral_axis=spectrum.spectral_axis, flux=0.*spectrum.flux)"
]
},
{
Expand All @@ -506,13 +506,12 @@
"metadata": {},
"outputs": [],
"source": [
"plt.plot(spectrum_sub.spectral_axis,spectrum_sub.flux)\n",
"plt.hlines(0,1.3,1.7,color='black')\n",
"\n",
"plt.plot(spectrum_sub.spectral_axis, spectrum_sub.flux)\n",
"plt.hlines(0, 1.3, 1.7, color='black')\n",
"plt.xlabel(\"wavelength ({:latex})\".format(spectrum_sub.spectral_axis.unit))\n",
"plt.ylabel(\"flux ({:latex})\".format(spectrum_sub.flux.unit))\n",
"plt.title(\"NIRISS ID 6\")\n",
"plt.show()\n"
"plt.title(\"NIRISS ID 75\")\n",
"plt.show()"
]
},
{
Expand Down

0 comments on commit 00e31b0

Please sign in to comment.