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

v1.2.5 #575

Merged
merged 31 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a9ca52d
Added alternate model grid function that just selects the model with …
hover2pi Jul 19, 2023
c78a90f
Changed arg names
hover2pi Jul 19, 2023
6d03187
Added print statement
hover2pi Jul 19, 2023
57ec4a4
Updated LDC and ModelGrid to skip interpolation and just get closest …
hover2pi Jul 19, 2023
9a02df5
Updated hotsoss to v0.1.9 for python 3.9+ support
hover2pi Jul 21, 2023
9ab9c33
Upgraded svo_filters to v0.5.0 for py10 support
hover2pi Jul 21, 2023
fd5b704
Bumped hotsoss version to v0.1.9
hover2pi Aug 16, 2023
fd8babc
Merge conflicts
hover2pi Aug 28, 2023
2d0820d
Bumper hotsoss to v0.1.9
hover2pi Aug 28, 2023
fc4492f
Loosened up dependencies
hover2pi Aug 28, 2023
1302925
Updated Panel to TabPanel for bokeh
hover2pi Aug 28, 2023
04800de
Updated LDC tests for bokeh 3.0
hover2pi Aug 28, 2023
979a8c7
Merging develop into ldc_fix
hover2pi Aug 29, 2023
946cd05
Adding new_vis_plot.py module
hover2pi Aug 29, 2023
82f9d19
Added tests for new_vis_plot.py
hover2pi Aug 29, 2023
bae34a3
Fixed plotting stuff
hover2pi Aug 29, 2023
24e940e
Fixed bokeh plot_width issue in LDC and added wavelength ranges to mo…
hover2pi Aug 29, 2023
0ab536d
bohel plot keyword fix
hover2pi Aug 30, 2023
2f2cf7a
pinning werkzeug
hover2pi Aug 30, 2023
2f0795a
Trying to fix visibility table download button
hover2pi Aug 30, 2023
d2517fd
Trying download button
hover2pi Aug 30, 2023
ea1844f
Trying by passing DF to form
hover2pi Aug 30, 2023
d391c89
Save as dat
hover2pi Aug 30, 2023
505d5d8
typo
hover2pi Aug 30, 2023
c40a343
Fixing visib download
hover2pi Aug 30, 2023
e85ffe2
Spruced up contam plot reeeeal nice
hover2pi Sep 1, 2023
f890313
Hovertool kwarg update
hover2pi Sep 1, 2023
0621b0f
Reduced max cores to 8
hover2pi Sep 1, 2023
0b190ac
Superfluous line
hover2pi Sep 1, 2023
efcc196
Fixed the tap tool for contam plots
hover2pi Sep 5, 2023
8382b56
Fixed requirements so RTD build passes
hover2pi Sep 26, 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
6 changes: 3 additions & 3 deletions env/environment-3.10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
- defaults
dependencies:
- astropy>=5.3.1
- bokeh=2.4.3
- bokeh>=3.2.2
- cython>=0.29.35
- docopt>=0.6.2
- docutils>=0.16
Expand Down Expand Up @@ -35,7 +35,7 @@ dependencies:
- docutils>=0.16
- flask_wtf>=1.1.1
- h5py>=3.9.0
- hotsoss>=0.1.8
- hotsoss>=0.1.9
- gunicorn>=21.1.0
- numpy>=1.25.1
- platon>=5.4
Expand All @@ -47,6 +47,6 @@ dependencies:
- scipy>=1.11.1
- sphinx_astropy>=1.9.1
- svo-filters>=0.4.4
- werkzeug>=2.3.6
- werkzeug==2.0.3
- jwst_gtvt>=1.0.0
- astroquery>=0.4.6
6 changes: 3 additions & 3 deletions env/environment-3.11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
- defaults
dependencies:
- astropy>=5.3.1
- bokeh=2.4.3
- bokeh>=3.2.2
- cython>=0.29.35
- docopt>=0.6.2
- docutils>=0.16
Expand Down Expand Up @@ -35,7 +35,7 @@ dependencies:
- docutils>=0.16
- flask_wtf>=1.1.1
- h5py>=3.9.0
- hotsoss>=0.1.8
- hotsoss>=0.1.9
- gunicorn>=21.1.0
- numpy>=1.25.1
- platon>=5.4
Expand All @@ -47,6 +47,6 @@ dependencies:
- scipy>=1.11.1
- sphinx_astropy>=1.9.1
- svo-filters>=0.4.4
- werkzeug>=2.3.6
- werkzeug==2.0.3
- jwst_gtvt>=1.0.0
- astroquery>=0.4.6
9 changes: 5 additions & 4 deletions env/environment-3.9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
- defaults
dependencies:
- astropy>=5.3.1
- bokeh=2.4.3
- bokeh>=3.2.2
- cython>=0.29.35
- docopt>=0.6.2
- docutils>=0.16
Expand Down Expand Up @@ -35,8 +35,9 @@ dependencies:
- docutils>=0.16
- flask_wtf>=1.1.1
- h5py>=3.9.0
- hotsoss>=0.1.8
- hotsoss>=0.1.9
- gunicorn>=21.1.0
- markupsafe==2.0.1
- numpy>=1.25.1
- platon>=5.4
- pyerfa>=2.0.0
Expand All @@ -47,6 +48,6 @@ dependencies:
- scipy>=1.11.1
- sphinx_astropy>=1.9.1
- svo-filters>=0.4.4
- werkzeug>=2.3.6
- werkzeug==2.0.3
- jwst_gtvt>=1.0.0
- astroquery>=0.4.6
- astroquery>=0.4.6
132 changes: 63 additions & 69 deletions exoctk/contam_visibility/contamination_figure.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os
import sys
from itertools import groupby, count

from astropy.io import fits
from bokeh.layouts import gridplot
from bokeh.models import Range1d, LinearColorMapper
from bokeh.models import Range1d, LinearColorMapper, CrosshairTool, HoverTool, Span
from bokeh.palettes import PuBu
from bokeh.plotting import figure
import numpy as np
Expand Down Expand Up @@ -214,8 +215,7 @@ def miriContam(cube, paRange=[0, 360]):
return contamO1


def contam(cube, instrument, targetName='noName', paRange=[0, 360],
badPAs=np.asarray([]), tmpDir="", fig='', to_html=True):
def contam(cube, instrument, targetName='noName', paRange=[0, 360], badPAs=[]):

rows, cols = cube.shape[1], cube.shape[2]

Expand All @@ -241,10 +241,7 @@ def contam(cube, instrument, targetName='noName', paRange=[0, 360],
xlim0 = 5
xlim1 = 12

TOOLS = 'pan, box_zoom, crosshair, reset'

bad_PA_color = '#dddddd'
bad_PA_alpha = 0.7
TOOLS = 'pan, box_zoom, reset'
dPA = 1

# Order 1~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -255,22 +252,17 @@ def contam(cube, instrument, targetName='noName', paRange=[0, 360],
color_mapper = LinearColorMapper(palette=PuBu[8][::-1][2:], low=-4, high=1)
color_mapper.low_color = 'white'
color_mapper.high_color = 'black'
width = Span(dimension="width", line_width=1)
height = Span(dimension="height", line_width=1)

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))
s2 = figure(tools=TOOLS, width=800, height=600, title='{} {} Contamination with {}'.format(orders, targetName, instrument), x_range=Range1d(xlim0, xlim1), y_range=Range1d(ylim0, ylim1))
o1_crosshair = CrosshairTool(overlay=[width, height])
s2.add_tools(o1_crosshair)

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 == 'MIRIM_SLITLESSPRISM') or (instrument == 'NRCA5_GRISM256_F322W2') else xlim0
DW = xlim0 - xlim1 if (instrument == 'MIRIM_SLITLESSPRISM') or (instrument == 'NRCA5_GRISM256_F322W2') else xlim1 - xlim0
fig_data = np.log10(np.clip(contamO1, 1.e-10, 1.))

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

Expand All @@ -279,30 +271,11 @@ def contam(cube, instrument, targetName='noName', paRange=[0, 360],
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
if len(badPAs) > 0:

tops, bottoms, lefts, rights = [], [], [], []
for idx in range(0, len(badPAs)):
PAgroup = badPAs[idx]
top_idx = np.max(PAgroup)
bot_idx = np.min(PAgroup)

tops.append(top_idx)
bottoms.append(bot_idx)
lefts.append(xlim0)
rights.append(xlim1)

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

# Line plot
#ax = 1 if 'NIRCam' in instrument else 0
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)
s3 = figure(tools=TOOLS, width=150, height=600, x_range=Range1d(0, 100), y_range=s2.y_range, title=None)
s3.add_tools(o1_crosshair)

try:
s3.line(100 * np.sum(contamO1 >= 0.001, axis=1) / channels, PA - dPA / 2, line_color='blue', legend_label='> 0.001')
Expand All @@ -313,38 +286,52 @@ def contam(cube, instrument, targetName='noName', paRange=[0, 360],

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

# Add shaded region for bad PAs
bad_PA_color = '#555555'
bad_PA_alpha = 0.6
if len(badPAs) > 0:

# Group bad PAs
badPA_groups = [list(map(int, g)) for _, g in groupby(badPAs, lambda n, c=count(): n-next(c))]

tops, bottoms, lefts, rights, lefts_line, rights_line = [], [], [], [], [], []
for idx in range(0, len(badPA_groups)):
PAgroup = badPA_groups[idx]
top_idx = np.max(PAgroup)
bot_idx = np.min(PAgroup)

tops.append(top_idx)
bottoms.append(bot_idx)
lefts.append(xlim0)
rights.append(xlim1)
lefts_line.append(0)
rights_line.append(100)

s2.quad(top=tops, bottom=bottoms, left=lefts, right=rights, color=bad_PA_color, alpha=bad_PA_alpha)
s3.quad(top=tops, bottom=bottoms, left=lefts_line, right=rights_line, color=bad_PA_color, alpha=bad_PA_alpha)

# ~~~~~~ Order 2 ~~~~~~

# Contam plot
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=800, height=600, 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.xaxis.axis_label = 'Wavelength (um)'
s5.yaxis.axis_label = 'Aperture Position Angle (degrees)'

if len(badPAs) > 0:

tops, bottoms, lefts, rights = [], [], [], []
for idx in range(0, len(badPAs)):
PAgroup = badPAs[idx]
top_idx = np.max(PAgroup)
bot_idx = np.min(PAgroup)

tops.append(top_idx)
bottoms.append(bot_idx)
lefts.append(xlim0)
rights.append(xlim1)

s5.quad(top=tops, bottom=bottoms, left=lefts, right=rights, color=bad_PA_color, alpha=bad_PA_alpha)
o2_crosshair = CrosshairTool(overlay=[width, height])
s5.add_tools(o2_crosshair)

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

try:
s6.line(100 * np.sum(contamO2 >= 0.001, axis=0) / rows, PA - dPA / 2, line_color='blue', legend_label='> 0.001')
Expand All @@ -355,23 +342,30 @@ def contam(cube, instrument, targetName='noName', paRange=[0, 360],

s6.xaxis.axis_label = '% channels contam.'
s6.yaxis.major_label_text_font_size = '0pt'
s6.ygrid.grid_line_color = None

if len(badPAs) > 0:
# Add shaded region for bad PAs
if len(badPAs) > 0:

tops, bottoms, lefts, rights = [], [], [], []
for idx in range(0, len(badPAs)):
PAgroup = badPAs[idx]
top_idx = np.max(PAgroup)
bot_idx = np.min(PAgroup)
# Group bad PAs
badPA_groups = [list(map(int, g)) for _, g in groupby(badPAs, lambda n, c=count(): n - next(c))]

tops.append(top_idx)
bottoms.append(bot_idx)
lefts.append(0)
rights.append(100)
tops, bottoms, lefts, rights, lefts_line, rights_line = [], [], [], [], [], []
for idx in range(0, len(badPA_groups)):
PAgroup = badPA_groups[idx]
top_idx = np.max(PAgroup)
bot_idx = np.min(PAgroup)

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)
tops.append(top_idx)
bottoms.append(bot_idx)
lefts.append(xlim0)
rights.append(xlim1)
lefts_line.append(0)
rights_line.append(100)

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

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

Expand Down
Loading
Loading