Skip to content

Commit

Permalink
Fixes based on comments and added changelog.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmccully committed Nov 5, 2024
1 parent 47df98f commit b46e95f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 26 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
0.2.0 (2024-11-05)
------------------
- Added the ability to re-extract via the GUI

0.1.0 (2024-06-06)
------------------
- Initial Release
30 changes: 8 additions & 22 deletions banzai_floyds_ui/gui/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,11 @@
from scipy.interpolate import LinearNDInterpolator
from banzai_floyds_ui.gui.utils.plot_utils import unfilled_histogram, EXTRACTION_REGION_LINE_ORDER
from banzai_floyds_ui.gui.utils.plot_utils import extraction_region_traces, plot_extracted_data
from banzai_floyds_ui.gui.utils.plot_utils import DARK_BLUE, COLORMAP, DARK_SALMON, LAVENDER
import importlib
import json


COLORMAP = [
[0, '#fff7fb'],
[0.125, '#ece7f2'],
[0.25, '#d0d1e6'],
[0.375, '#a6bddb'],
[0.5, '#74a9cf'],
[0.625, '#3690c0'],
[0.75, '#0570b0'],
[0.875, '#045a8d'],
[1, '#023858']
]
DARK_SALMON = '#8F0B0B'
LAVENDER = '#BB69F5'

template_path = importlib.resources.files('banzai_floyds_ui.gui').joinpath('data/plotly_template.json')
PLOTLY_TEMPLATE = json.loads(template_path.read_text())

Expand Down Expand Up @@ -71,9 +58,9 @@ def make_2d_sci_plot(frame, filename):
frame['SCI'].data.shape)
order_polynomial = np.polynomial.Legendre(orders.coeffs[order - 1], domain=orders.domains[order - 1])

wavelenth_solution = WavelengthSolution.from_header(frame['WAVELENGTHS'].header, orders)
wavelengths_polynomial = Legendre(coef=wavelenth_solution.coefficients[order - 1],
domain=wavelenth_solution.domains[order - 1])
wavelength_solution = WavelengthSolution.from_header(frame['WAVELENGTHS'].header, orders)
wavelengths_polynomial = Legendre(coef=wavelength_solution.coefficients[order - 1],
domain=wavelength_solution.domains[order - 1])
center_polynomial = header_to_polynomial(frame['PROFILEFITS'].header, 'CTR', order)
width_polynomal = header_to_polynomial(frame['PROFILEFITS'].header, 'WID', order)
for polynomial, key in zip([order_polynomial, center_polynomial, width_polynomal, wavelengths_polynomial],
Expand All @@ -99,7 +86,6 @@ def make_2d_sci_plot(frame, filename):
wavelengths_polynomial, extract_lower_n_sigma, upper_lower_n_sigma,
bkg_left_upper_n_sigma, bkg_right_lower_n_sigma, bkg_left_lower_n_sigma,
bkg_right_upper_n_sigma)
print('Got here', f'{extract_lower_n_sigma=}', f'{upper_lower_n_sigma=}', f'{bkg_left_upper_n_sigma=}', f'{bkg_right_lower_n_sigma=}', f'{bkg_left_lower_n_sigma=}', f'{bkg_right_upper_n_sigma=}')
if order == 2:
center_name = 'Extraction Center'
center_legend = True
Expand Down Expand Up @@ -270,7 +256,7 @@ def make_arc_line_plots(arc_frame_hdu):
figure_data.append(
dict(
type='scatter', x=residuals_wavelengths.tolist(), y=residuals.tolist(),
mode='markers', marker=dict(color='#023858'),
mode='markers', marker=dict(color=DARK_BLUE),
hovertext=residual_hover_text,
hovertemplate='%{y}\u212B: %{hovertext}<extra></extra>',
xaxis=f'x{plot_column[order] + 2}', yaxis=f'y{plot_column[order] + 2}'
Expand Down Expand Up @@ -336,7 +322,7 @@ def make_profile_plot(sci_2d_frame):

figure_data = []
plot_row = {2: 1, 1: 2}
# Define the coordinate refernce plot manually per order
# Define the coordinate reference plot manually per order
reference_axes = {2: 1, 1: 3}
# Approximate wavelength center to plot the profile
order_center = {1: 7000, 2: 4500}
Expand All @@ -359,7 +345,7 @@ def make_profile_plot(sci_2d_frame):
model_name = None
data_name = None
figure_data.append(
unfilled_histogram(data['y_order'], data['data'], '#023858', name=data_name, legend='legend2',
unfilled_histogram(data['y_order'], data['data'], DARK_BLUE, name=data_name, legend='legend2',
axis=2 * plot_row[order] - 1),
)

Expand All @@ -373,7 +359,7 @@ def make_profile_plot(sci_2d_frame):
dict(
type='scatter', x=traced_points['wavelength'],
y=traced_points['center'],
mode='markers', marker={'color': '#023858'},
mode='markers', marker={'color': DARK_BLUE},
hoverinfo='skip', showlegend=False,
xaxis=f'x{plot_row[order] * 2}', yaxis=f'y{plot_row[order] * 2}'
)
Expand Down
22 changes: 19 additions & 3 deletions banzai_floyds_ui/gui/utils/plot_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
import numpy as np


DARK_BLUE = '#023858'
COLORMAP = [
[0, '#fff7fb'],
[0.125, '#ece7f2'],
[0.25, '#d0d1e6'],
[0.375, '#a6bddb'],
[0.5, '#74a9cf'],
[0.625, '#3690c0'],
[0.75, '#0570b0'],
[0.875, '#045a8d'],
[1, DARK_BLUE]
]
DARK_SALMON = '#8F0B0B'
LAVENDER = '#BB69F5'


def xy_to_svg_path(x, y):
# We don't want a Z at the end because we're not closing the path
return 'M ' + ' L '.join(f'{i},{j}' for i, j in zip(x, y))
Expand Down Expand Up @@ -65,16 +81,16 @@ def plot_extracted_data(frame_data):
top_row_axis = '' if plot_column[order] == 1 else plot_column[order]
figure_data.append(
dict(type='scatter', x=frame_data['wavelength'][where_order], y=frame_data['flux'][where_order],
line=dict(color='#023858'), mode='lines', xaxis=f'x{top_row_axis}', yaxis=f'y{top_row_axis}')
line=dict(color=DARK_BLUE), mode='lines', xaxis=f'x{top_row_axis}', yaxis=f'y{top_row_axis}')
)
mid_row_axis = plot_column[order] + 2
figure_data.append(
dict(type='scatter', x=frame_data['wavelength'][where_order], y=frame_data['fluxraw'][where_order],
line=dict(color='#023858'), mode='lines', xaxis=f'x{mid_row_axis}', yaxis=f'y{mid_row_axis}')
line=dict(color=DARK_BLUE), mode='lines', xaxis=f'x{mid_row_axis}', yaxis=f'y{mid_row_axis}')
)
bottom_row_axis = plot_column[order] + 4
figure_data.append(
dict(type='scatter', x=frame_data['wavelength'][where_order], y=frame_data['background'][where_order],
line=dict(color='#023858'), mode='lines', xaxis=f'x{bottom_row_axis}', yaxis=f'y{bottom_row_axis}')
line=dict(color=DARK_BLUE), mode='lines', xaxis=f'x{bottom_row_axis}', yaxis=f'y{bottom_row_axis}')
)
return figure_data
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies = [
"django_redis",
"whitenoise",
"httpx",
"banzai_floyds @ git+https://github.com/lcogt/banzai-floyds@reextract",
"banzai_floyds @ git+https://github.com/lcogt/banzai-floyds@0.10.0",
"scipy"
]

Expand Down

0 comments on commit b46e95f

Please sign in to comment.