Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize contam tool #492

Merged
merged 143 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
0c9f91b
Added pysiaf to NIRISS fieldsim
hover2pi Mar 30, 2021
72e1c0c
Added pysiaf to NIRISS fieldsim
hover2pi Mar 30, 2021
a6c222a
optimizing contam tool but need to fix data sources.
hover2pi Apr 27, 2021
0892f63
optimizing contam tool but need to fix data sources.
hover2pi Apr 27, 2021
e48c8b0
opt-o-mize
hover2pi Apr 28, 2021
bfd5050
opt-o-mize
hover2pi Apr 28, 2021
9e4c97b
Merge conflicts
hover2pi Apr 28, 2021
1d3da74
Merge conflicts
hover2pi Apr 28, 2021
ec54466
Added multiprocessing to field_simulator
hover2pi May 10, 2021
faaa835
Added multiprocessing to field_simulator
hover2pi May 10, 2021
4f62d61
Enabled optimized contam tool to work on the Web app
hover2pi May 10, 2021
878609f
Enabled optimized contam tool to work on the Web app
hover2pi May 10, 2021
2e0293f
Trying to figure out these contam plots
hover2pi May 26, 2021
6294651
Trying to figure out these contam plots
hover2pi May 26, 2021
16072ce
Added contam tool support for all modes under one function and suppre…
hover2pi Jul 30, 2021
4ac6a8b
Added contam tool support for all modes under one function and suppre…
hover2pi Jul 30, 2021
d12605b
Renamed contam test module and added field_simulation tests
hover2pi Jul 30, 2021
202519d
Renamed contam test module and added field_simulation tests
hover2pi Jul 30, 2021
6f63b45
Added gtvt test for all instruments
hover2pi Aug 2, 2021
2c7cf89
Added gtvt test for all instruments
hover2pi Aug 2, 2021
79dfdc7
Fixed star FOV bug that was only including target star
hover2pi Aug 6, 2021
63874a5
Fixed star FOV bug that was only including target star
hover2pi Aug 6, 2021
eb9636f
Reworked multiprocessing to make a cube for each PA. May not be optimal.
hover2pi Aug 31, 2021
049ac6f
Reworked multiprocessing to make a cube for each PA. May not be optimal.
hover2pi Aug 31, 2021
683b514
Trying to resolve contam tool trace orientation
hover2pi Dec 29, 2021
246d765
Trying to resolve contam tool trace orientation
hover2pi Dec 29, 2021
3cedad5
Fixed trace generator to work with pandeia v1.6.1
hover2pi Jan 18, 2022
f90991f
Fixed trace generator to work with pandeia v1.6.1
hover2pi Jan 18, 2022
fc19f66
Hacking away at an optmial solution here.
hover2pi Feb 10, 2022
17fd573
Hacking away at an optmial solution here.
hover2pi Feb 10, 2022
84d25e0
The contam slog continues
hover2pi Feb 14, 2022
c551acb
The contam slog continues
hover2pi Feb 14, 2022
d3919da
Ugh
hover2pi Feb 17, 2022
37b3419
Ugh
hover2pi Feb 17, 2022
97761da
shakespeare
hover2pi Apr 5, 2022
8896b01
shakespeare
hover2pi Apr 5, 2022
36f5bc9
Updated contam notebook to debug the field_simulator
hover2pi May 12, 2022
9bac63e
Starting to add order 0 support
hover2pi Jul 29, 2022
ccdfe0b
more improvements
hover2pi Aug 9, 2022
37ab7d2
Major updates to contam tool. Everything works. Just adding finishing…
hover2pi Nov 2, 2022
c1cadeb
Incorporated old contam plot back into the web app
hover2pi Nov 30, 2022
2ed1fff
Merge conflicts
hover2pi Dec 1, 2022
971e40a
Merge conflicts again
hover2pi Dec 2, 2022
839441b
Downgrade batman because of install error in current
hover2pi Dec 2, 2022
09b0eea
i am the batman
hover2pi Dec 2, 2022
82c8a7d
Me code pretty one day
hover2pi Dec 2, 2022
a207a18
Dinna dinna dinna dinnna dinna dinna dinna dinna BATMAM
hover2pi Dec 2, 2022
6c3b829
more conflicts
hover2pi Dec 2, 2022
0cbc223
merging with develop
hover2pi Jan 23, 2023
652b234
update version in base.html
jaymedina Oct 30, 2020
49132af
pep8 compliance
jaymedina Oct 30, 2020
004d7d9
add condition w/ badPAs
falkben Nov 9, 2020
6e5087d
make binComp a list of floats
jaymedina Oct 20, 2020
a7aabff
removed print statement
jaymedina Oct 20, 2020
975079d
Added CHANGELOG.md to repo
hover2pi Nov 9, 2020
92281ff
Minor edit
hover2pi Nov 9, 2020
824efab
Removed deprecated astropy.extern.six.StringIO dependency, replaced w…
bourque Nov 4, 2020
55bd438
updated asteval dependency
bourque Nov 10, 2020
3ffc816
Attempting to kick-start GitHub which for some reason is not respondi…
bourque Nov 10, 2020
6e09718
Repaired logging code and added logging to all Web tools
hover2pi Dec 4, 2020
e420c3e
Added throughputs from pandeia and helpers function to fetch them
hover2pi Dec 23, 2020
9e5a289
Converted fits files to txt so svo_filters can read them and updated …
hover2pi Dec 23, 2020
56a4675
Updated LDC code to work with svo_filters 0.3.0
hover2pi Dec 31, 2020
8601c28
Checking if PyYAML install is case sensitive
hover2pi Dec 31, 2020
e28f92e
Trying to resolve scipy1.6.0 requires PyYAML5.1.0 but bandit requires…
hover2pi Dec 31, 2020
0364820
Removed bandit temporarily to see if builds pass
hover2pi Jan 4, 2021
1fb4810
Bump svo_filters to v0.3.0 in py3.7 env
hover2pi Jan 4, 2021
81a52fd
Setting scipy bandit and pyyaml versions
hover2pi Jan 4, 2021
565b7ed
PEP compliance for utils.py
hover2pi Jan 4, 2021
0840c56
Removed pinned pyyaml version in setup.py that was breking the conda …
hover2pi Jan 5, 2021
7e0b9fd
werkzug version pin
hover2pi Jan 5, 2021
6146064
Added code to generate JWST throughputs and populated the throughputs…
hover2pi Feb 17, 2021
ca510e1
Upgraded PyYAML>=5.4 as per pyup recommendation
hover2pi Feb 17, 2021
46b64d3
Added try except for pandeia install which is only needed to generate…
hover2pi Feb 18, 2021
b77cf1b
Update cython from 0.29.21 to 0.29.22
pyup-bot Mar 1, 2021
8a4f0a1
Update pandas from 1.2.0 to 1.2.2
pyup-bot Mar 1, 2021
75fe8a6
Update pytest from 6.2.1 to 6.2.2
pyup-bot Mar 1, 2021
723f160
Update pyyaml from 5.3.1 to 5.4.1
pyup-bot Mar 1, 2021
e09bbbf
Update scipy from 1.6.0 to 1.6.1
pyup-bot Mar 1, 2021
73f0927
Update sphinx from 3.4.1 to 3.5.1
pyup-bot Mar 1, 2021
5308f76
Update sqlalchemy from 1.3.22 to 1.3.23
pyup-bot Mar 1, 2021
7ae8db1
Update boto3 from 1.16.47 to 1.16.63
pyup-bot Feb 1, 2021
ba02d90
Update matplotlib from 3.3.3 to 3.3.4
pyup-bot Feb 1, 2021
952b259
Update numpy from 1.19.4 to 1.20.0
pyup-bot Feb 1, 2021
7f42161
Update pandas from 1.2.0 to 1.2.1
pyup-bot Feb 1, 2021
ba7a656
Update pytest from 6.2.1 to 6.2.2
pyup-bot Feb 1, 2021
1db8686
Update pyyaml from 5.3.1 to 5.4.1
pyup-bot Feb 1, 2021
ff33c63
Update sphinx from 3.4.1 to 3.4.3
pyup-bot Feb 1, 2021
04c0d1d
pyup updates 02/21
bourque Feb 2, 2021
87a59ca
Moving flask-wtf back to pip since the latest version doesnt appear t…
bourque Feb 2, 2021
9bbd681
Reverting svo_filters as I dont think updating this may break some th…
bourque Feb 2, 2021
0f863c8
Reverting astropy after some failed tests
bourque Feb 2, 2021
b5a22b1
Added explicity pip dependency
bourque Feb 16, 2021
ec85713
Added python3.8 travis build
bourque Feb 16, 2021
ccb4539
Added dependencies
bourque Feb 16, 2021
8f8bdaa
Initial commit of conda 3.9 env
bourque Feb 16, 2021
e1cae03
Added 3.9 build
bourque Feb 16, 2021
4825865
Skipping jwst_gtvt test when using python3.9
bourque Feb 19, 2021
d9e4b55
Remove support for python 3.6
bourque Feb 19, 2021
2151d0f
March 2021 pyup updates
bourque Mar 2, 2021
56cfadb
Added citation information
bourque Feb 22, 2021
7ca31c4
Fixed and added some badges
bourque Feb 22, 2021
5363c85
The README logo is a bit unecissarily large
bourque Feb 22, 2021
86e209e
Fixed typo
bourque Feb 22, 2021
db2ac5e
Added pysiaf to NIRISS fieldsim
hover2pi Mar 30, 2021
2125f87
optimizing contam tool but need to fix data sources.
hover2pi Apr 27, 2021
b829c35
Undoing previous mess
hover2pi Jan 23, 2023
c4e64bb
Merge conflicts
hover2pi Jan 26, 2023
f35a9a0
pinning docutils version
hover2pi Jan 26, 2023
38b85e8
regions and docutils versions
hover2pi Jan 26, 2023
db77b58
Removing docutils pin in setup.py
hover2pi Jan 26, 2023
116adef
Updating test to reflect new value in exomast
hover2pi Jan 26, 2023
4a92d44
Play nice, packages
hover2pi Jan 26, 2023
0142e0e
Messing with sphinx version
hover2pi Jan 26, 2023
7c2b48b
This package stuff is the absolute worst part of programming. I hate it.
hover2pi Jan 26, 2023
72ba5e8
Messing with packages to get build passing
hover2pi Jan 26, 2023
051c7ca
docutils is killing me
hover2pi Jan 26, 2023
a98b794
I hate you sphinx
hover2pi Jan 26, 2023
2e9984c
upgrade astropy
hover2pi Jan 26, 2023
a1a3307
typo
hover2pi Jan 26, 2023
5fffb3d
numpy upgrade so astropy 4.2 works
hover2pi Jan 26, 2023
9bd9f42
astropy bump
hover2pi Jan 30, 2023
fba6531
astropy bump
hover2pi Jan 30, 2023
0c0a736
Starting over with dependencies
hover2pi Feb 14, 2023
965c144
Updated tests
hover2pi Feb 14, 2023
e57ae33
Removed Python 3.7 support
hover2pi Feb 14, 2023
3182119
Removed Python 3.7 support
hover2pi Feb 14, 2023
b30477c
Added python 3.10 support
hover2pi Feb 14, 2023
42b56f1
Upgraded hotsoss to v0.1.8 and fixed broken tests
hover2pi Feb 22, 2023
3036dd7
Why isnt conda installing the astropy version I specify
hover2pi Feb 22, 2023
6acd7d3
Astro-why
hover2pi Feb 22, 2023
3c54f1a
Rolling back dependencies to see what tests fail with old installs
hover2pi Feb 22, 2023
961bf44
I am the batman
hover2pi Feb 22, 2023
1233568
Pinning pyvo
hover2pi Feb 23, 2023
578893f
Perhaps pip installing numpy instead of conda will preserve the versi…
hover2pi Feb 23, 2023
ac6cdd2
Removing old Travis env build.
hover2pi Feb 23, 2023
92ea4e7
Removing reinstall of numpy from ci.yml file
hover2pi Feb 23, 2023
59ff48f
Adding --no-deps flag to exoctk install because everything else is al…
hover2pi Feb 23, 2023
1442195
Adding regions to deps
hover2pi Feb 23, 2023
87b8d57
Adding erfa to deps
hover2pi Feb 23, 2023
1a229c8
Adding pyerfa to deps
hover2pi Feb 23, 2023
656ab61
Reconfigure github actions to only run tests on pull_request
hover2pi Feb 23, 2023
d22b4a1
Use conda, not pip, to install numpy with python3.9 apparently
hover2pi Feb 23, 2023
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
Empty file added Add
Empty file.
1 change: 1 addition & 0 deletions env/environment-3.7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies:
- bibtexparser==1.2.0
- corner==2.2.1
- flask_wtf==0.14.3
- hotsoss==0.1.7
- lmfit==1.0.1
- platon==5.1.2
- pysiaf==0.10.0
Expand Down
1 change: 1 addition & 0 deletions env/environment-3.8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies:
- bibtexparser==1.2.0
- corner==2.2.1
- flask_wtf==0.14.3
- hotsoss==0.1.7
- lmfit==1.0.2
- platon==5.1.2
- pysiaf==0.10.0
Expand Down
1 change: 1 addition & 0 deletions env/environment-3.9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies:
- corner==2.2.1
- docutils==0.15.2
- flask_wtf==0.14.3
- hotsoss==0.1.7
- gunicorn==20.0.4
- lmfit==1.0.2
- platon==5.1.2
Expand Down
1 change: 0 additions & 1 deletion exoctk/contam_visibility/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from . import ephemeris_old2x
from . import visibilityPA
from . import contamination_figure
from . import resolve
from . import time_extensionsx
from . import f_visibilityPeriods
from . import quaternionx
Expand Down
166 changes: 61 additions & 105 deletions exoctk/contam_visibility/contamination_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import numpy as np

from . import visibilityPA as vpa
from ..utils import fill_between


EXOCTK_DATA = os.environ.get('EXOCTK_DATA')
if not EXOCTK_DATA:
Expand Down Expand Up @@ -51,13 +53,12 @@ def nirissContam(cube, paRange=[0, 360]):
# Start calculations
if not TRACES_PATH:
return None
lam_file = os.path.join(TRACES_PATH, 'NIRISS', 'lambda_order1-2.txt')
lam_file = os.path.join(TRACES_PATH, 'NIRISS_old', 'lambda_order1-2.txt')
ypix, lamO1, lamO2 = np.loadtxt(lam_file, unpack=True)

nPA = cube.shape[0]
rows = cube.shape[1]
cols = cube.shape[2]
print('cols ', cols)
dPA = 360 // nPA
PA = np.arange(nPA) * dPA

Expand Down Expand Up @@ -88,23 +89,19 @@ def nirissContam(cube, paRange=[0, 360]):
return contamO1, contamO2


def nircamContam(cube, instrument, paRange=[0, 360]):
def nircamContam(cube, paRange=[0, 360]):
""" Generates the contamination figure that will be plotted on the website
for NIRCam Grism Time Series mode.

PARAMETERS
Parameters
----------
cube : arr or str
A 3D array of the simulated field at every Aperture Position Angle (APA).
The shape of the cube is (361, subY, subX).
or
The name of an HDU .fits file sthat has the cube.

instrument : str
The name of the instrument + what filter is being used. For NIRCam the
options are: 'NIRCam F322W2', 'NIRCam F444W'

RETURNS
Returns
-------
bokeh plot
"""
Expand Down Expand Up @@ -222,7 +219,7 @@ def miriContam(cube, paRange=[0, 360]):
def contam(cube, instrument, targetName='noName', paRange=[0, 360],
badPAs=np.asarray([]), tmpDir="", fig='', to_html=True):

lam_file = os.path.join(TRACES_PATH, 'NIRISS', 'lambda_order1-2.txt')
lam_file = os.path.join(TRACES_PATH, 'NIRISS_old', 'lambda_order1-2.txt')
ypix, lamO1, lamO2 = np.loadtxt(lam_file, unpack=True)

nPA, rows, cols = cube.shape[0], cube.shape[1], cube.shape[2]
Expand All @@ -231,14 +228,28 @@ def contam(cube, instrument, targetName='noName', paRange=[0, 360],
PA = np.arange(PAmin, PAmax, 1)

# Generate the contam figure
if instrument == 'NIRISS':
if instrument in ['NIS_SUBSTRIP256', 'NIS_SUBSTRIP96']:
contamO1, contamO2 = nirissContam(cube)
elif (instrument == 'NIRCam F322W2') or (instrument == 'NIRCam F444W'):
contamO1 = nircamContam(cube, instrument)
elif instrument == 'MIRI':
xlim0 = lamO1.min()
xlim1 = lamO1.max()
elif instrument == 'NRCA5_GRISM256_F444W':
contamO1 = nircamContam(cube)
xlim0 = lam0_nircam444w
xlim1 = lam1_nircam444w
elif instrument == 'NRCA5_GRISM256_F322W2':
contamO1 = nircamContam(cube)
xlim0 = lam0_nircam322w2
xlim1 = lam1_nircam322w2
elif instrument == 'MIRIM_SLITLESSPRISM':
contamO1 = miriContam(cube)
xlim0 = 5
xlim1 = 12

<<<<<<< HEAD
TOOLS = 'pan, box_zoom, crosshair, reset'
=======
TOOLS = 'pan, box_zoom, crosshair, reset, hover'
>>>>>>> 8896b019b83bb82cba37ecaa32f910271449aa6f

y = np.array([0., 0.])
y1 = 0.07
Expand All @@ -252,60 +263,38 @@ def contam(cube, instrument, targetName='noName', paRange=[0, 360],
# Order 1~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# Contam plot
if instrument == 'NIRISS':
xlim0 = lamO1.min()
xlim1 = lamO1.max()
elif instrument == 'NIRCam F322W2':
xlim0 = lam0_nircam322w2
xlim1 = lam1_nircam322w2
elif instrument == 'NIRCam F444W':
xlim0 = lam0_nircam444w
xlim1 = lam1_nircam444w
elif instrument == 'MIRI':
xlim0 = 5
xlim1 = 12

ylim0 = PAmin - 0.5
ylim1 = PAmax + 0.5
color_mapper = LinearColorMapper(palette=PuBu[8][::-1][2:],
low=-4, high=1)
color_mapper = LinearColorMapper(palette=PuBu[8][::-1][2:], low=-4, high=1)
color_mapper.low_color = 'white'
color_mapper.high_color = 'black'

orders = 'Orders 1 & 2' if instrument == 'NIRCam' else 'Order 1'
s2 = figure(
tools=TOOLS, width=500, height=500, title='{} {} Contamination with {}'.format(
orders, targetName, instrument), x_range=Range1d(
xlim0, xlim1), y_range=Range1d(
ylim0, ylim1))

contamO1 = contamO1 if 'NIRCam' in instrument else contamO1.T
contamO1 = np.fliplr(contamO1) if (
instrument == 'MIRI') or (
instrument == 'NIRCam F322W2') else contamO1
fig_data = np.log10(np.clip(contamO1, 1.e-10, 1.)
) # [:, :361] # might this
# index have somethig to
orders = 'Orders 1 & 2' if instrument.startswith('NRCA') else 'Order 1'
s2 = figure(tools=TOOLS, width=500, height=500, title='{} {} Contamination with {}'.format(orders, targetName, instrument), x_range=Range1d(xlim0, xlim1), y_range=Range1d(ylim0, ylim1))

contamO1 = contamO1 if 'NRCA' in instrument else contamO1.T
contamO1 = np.fliplr(contamO1) if (instrument == 'MIRIM_SLITLESSPRISM') or (instrument == 'NRCA5_GRISM256_F322W2') else contamO1
# fig_data = np.clip(contamO1, 1.e-10, 1.) # [:, :361] # might this
fig_data = np.log10(np.clip(contamO1, 1.e-10, 1.)) # [:, :361] # might this

# index have something to
# do w the choppiness
# of o1 in all instruments
# return(fig_data)

X = xlim1 if (instrument == 'MIRI') or (
instrument == 'NIRCam F322W2') else xlim0
DW = xlim0 - xlim1 if (instrument == 'MIRI') or (instrument ==
'NIRCam F322W2') else xlim1 - xlim0
X = xlim1 if (instrument == 'MIRIM_SLITLESSPRISM') or (instrument == 'NRCA5_GRISM256_F322W2') else xlim0
DW = xlim0 - xlim1 if (instrument == 'MIRIM_SLITLESSPRISM') or (instrument == 'NRCA5_GRISM256_F322W2') else xlim1 - xlim0

# Begin plotting ~~~~~~~~~~~~~~~~~~~~~~~~

s2.image([fig_data], x=xlim0, y=ylim0, dw=xlim1 - xlim0, dh=ylim1 - ylim0,
color_mapper=color_mapper)
s2.image([fig_data], x=xlim0, y=ylim0, dw=xlim1 - xlim0, dh=ylim1 - ylim0, color_mapper=color_mapper)
s2.xaxis.axis_label = 'Wavelength (um)'
if instrument != 'NIRISS':
if not instrument.startswith('NIS'):
s2.yaxis.axis_label = 'Aperture Position Angle (degrees)'

# Add bad PAs
bad_PA_color = '#555555'
bad_PA_alpha = 0.6
# for ybad0, ybad1 in badPA:
if len(badPAs) > 0:

tops, bottoms, lefts, rights = [], [], [], []
Expand All @@ -325,52 +314,30 @@ def contam(cube, instrument, targetName='noName', paRange=[0, 360],

# Line plot
#ax = 1 if 'NIRCam' in instrument else 0
channels = cols if 'NIRCam' in instrument else rows
s3 = figure(tools=TOOLS, width=150, height=500,
x_range=Range1d(0, 100), y_range=s2.y_range, title=None)
channels = cols if 'NRCA' in instrument else rows
s3 = figure(tools=TOOLS, width=150, height=500, x_range=Range1d(0, 100), y_range=s2.y_range, title=None)

try:
s3.line(100 * np.sum(contamO1 >= 0.001, axis=1) / channels, PA - dPA / 2,
line_color='blue', legend_label='> 0.001')
s3.line(100 * np.sum(contamO1 >= 0.01, axis=1) / channels, PA - dPA / 2,
line_color='green', legend_label='> 0.01')
s3.line(100 * np.sum(contamO1 >= 0.001, axis=1) / channels, PA - dPA / 2, line_color='blue', legend_label='> 0.001')
s3.line(100 * np.sum(contamO1 >= 0.01, axis=1) / channels, PA - dPA / 2, line_color='green', legend_label='> 0.01')
except AttributeError:
s3.line(100 * np.sum(contamO1 >= 0.001, axis=1) / channels, PA - dPA / 2,
line_color='blue', legend='> 0.001')
s3.line(100 * np.sum(contamO1 >= 0.01, axis=1) / channels, PA - dPA / 2,
line_color='green', legend='> 0.01')
s3.line(100 * np.sum(contamO1 >= 0.001, axis=1) / channels, PA - dPA / 2, line_color='blue', legend='> 0.001')
s3.line(100 * np.sum(contamO1 >= 0.01, axis=1) / channels, PA - dPA / 2, line_color='green', legend='> 0.01')

s3.xaxis.axis_label = '% channels contam.'
s3.yaxis.major_label_text_font_size = '0pt'

# ~~~~~~ Order 2 ~~~~~~
# Contam plot
if instrument == 'NIRISS':
if instrument.startswith('NIS'):
xlim0 = lamO2.min()
xlim1 = lamO2.max()
ylim0 = PA.min() - 0.5 * dPA
ylim1 = PA.max() + 0.5 * dPA
xlim0 = 0.614
s5 = figure(
tools=TOOLS,
width=500,
height=500,
title='Order 2 {} Contamination with {}'.format(
targetName,
instrument),
x_range=Range1d(
xlim0,
xlim1),
y_range=s2.y_range)
s5 = figure(tools=TOOLS, width=500, height=500, title='Order 2 {} Contamination with {}'.format(targetName, instrument), x_range=Range1d(xlim0, xlim1), y_range=s2.y_range)
fig_data = np.log10(np.clip(contamO2.T, 1.e-10, 1.))[:, 300:]
s5.image(
[fig_data],
x=xlim0,
y=ylim0,
dw=xlim1 - xlim0,
dh=ylim1 - ylim0,
color_mapper=color_mapper)
#s5.yaxis.major_label_text_font_size = '0pt'
s5.image([fig_data], x=xlim0, y=ylim0, dw=xlim1 - xlim0, dh=ylim1 - ylim0, color_mapper=color_mapper)
s5.xaxis.axis_label = 'Wavelength (um)'
s5.yaxis.axis_label = 'Aperture Position Angle (degrees)'

Expand All @@ -387,24 +354,17 @@ def contam(cube, instrument, targetName='noName', paRange=[0, 360],
lefts.append(xlim0)
rights.append(xlim1)

s5.quad(top=tops, bottom=bottoms,
left=lefts, right=rights,
color=bad_PA_color, alpha=bad_PA_alpha)
s5.quad(top=tops, bottom=bottoms, left=lefts, right=rights, color=bad_PA_color, alpha=bad_PA_alpha)

# Line plot
s6 = figure(tools=TOOLS, width=150, height=500, y_range=s2.y_range,
x_range=Range1d(100, 0), title=None)
s6 = figure(tools=TOOLS, width=150, height=500, y_range=s2.y_range, x_range=Range1d(0, 100), title=None)

try:
s6.line(100 * np.sum(contamO2 >= 0.001, axis=0) / rows, PA - dPA / 2,
line_color='blue', legend_label='> 0.001')
s6.line(100 * np.sum(contamO2 >= 0.01, axis=0) / rows, PA - dPA / 2,
line_color='green', legend_label='> 0.01')
s6.line(100 * np.sum(contamO2 >= 0.001, axis=0) / rows, PA - dPA / 2, line_color='blue', legend_label='> 0.001')
s6.line(100 * np.sum(contamO2 >= 0.01, axis=0) / rows, PA - dPA / 2, line_color='green', legend_label='> 0.01')
except AttributeError:
s6.line(100 * np.sum(contamO2 >= 0.001, axis=0) / rows, PA - dPA / 2,
line_color='blue', legend='> 0.001')
s6.line(100 * np.sum(contamO2 >= 0.01, axis=0) / rows, PA - dPA / 2,
line_color='green', legend='> 0.01')
s6.line(100 * np.sum(contamO2 >= 0.001, axis=0) / rows, PA - dPA / 2, line_color='blue', legend='> 0.001')
s6.line(100 * np.sum(contamO2 >= 0.01, axis=0) / rows, PA - dPA / 2, line_color='green', legend='> 0.01')

s6.xaxis.axis_label = '% channels contam.'
s6.yaxis.major_label_text_font_size = '0pt'
Expand All @@ -422,20 +382,16 @@ def contam(cube, instrument, targetName='noName', paRange=[0, 360],
lefts.append(0)
rights.append(100)

s3.quad(top=tops, bottom=bottoms,
left=lefts, right=rights,
color=bad_PA_color, alpha=bad_PA_alpha)
if instrument == 'NIRISS':
s6.quad(top=tops, bottom=bottoms,
left=rights, right=lefts,
color=bad_PA_color, alpha=bad_PA_alpha)
s3.quad(top=tops, bottom=bottoms, left=lefts, right=rights, color=bad_PA_color, alpha=bad_PA_alpha)
if instrument.startswith('NIS'):
s6.quad(top=tops, bottom=bottoms, left=rights, right=lefts, color=bad_PA_color, alpha=bad_PA_alpha)

# ~~~~~~ Plotting ~~~~~~

if instrument != 'NIRISS':
fig = gridplot(children=[[s2, s3]])
if instrument.startswith('NIS'):
fig = gridplot(children=[[s2, s3], [s5, s6]])
else:
fig = gridplot(children=[[s6, s5, s2, s3]])
fig = gridplot(children=[[s2, s3]])

return fig # , contamO1

Expand Down
Loading