Skip to content

Commit

Permalink
Use ApertureSettings in notebook 01
Browse files Browse the repository at this point in the history
  • Loading branch information
mwcraig committed Aug 10, 2023
1 parent 6750a32 commit de64722
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
11 changes: 8 additions & 3 deletions stellarphot/gui_tools/seeing_profile_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def __init__(self, imagewidget=None, width=500):
self.in_t = ipw.IntText(description='Inner annulus', value=10, layout=layout, style=desc_style)
self.out_t = ipw.IntText(description='Outer annulus', value=20, layout=layout, style=desc_style)
self.save_aps = ipw.Button(description="Save settings")
hb.children = [self.aperture_settings] #, self.save_aps] #, self.in_t, self.out_t]
hb.children = [self.aperture_settings, self.save_aps] #, self.save_aps] #, self.in_t, self.out_t]

lil_box = ipw.VBox()
lil_tabs = ipw.Tab()
Expand Down Expand Up @@ -627,6 +627,11 @@ def show_event(viewer, event=None, datax=None, datay=None, aperture=None):
# Set this AFTER the radial profile has been created to avoid an attribute
# error.
self.ap_t.value = aperture_radius
self.aperture_settings.value = dict(
radius=aperture_radius,
inner_annulus=aperture_radius + 5,
outer_annulus=aperture_radius + 15
)
else:
# User changed aperture
aperture_radius = aperture
Expand All @@ -639,8 +644,8 @@ def show_event(viewer, event=None, datax=None, datay=None, aperture=None):
self._seeing_plot_fig = seeing_plot(rad_prof.r_exact, rad_prof.scaled_exact_counts,
rad_prof.ravg,
rad_prof.scaled_profile, rad_prof.HWHM,
self.object_name, gap=10, annulus_width=15,
radius = aperture_radius,
self.object_name,
aperture_settings=ApertureSettings(**self.aperture_settings.value),
figsize=fig_size)
plt.show()

Expand Down
27 changes: 16 additions & 11 deletions stellarphot/plotting/aij_plots.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import matplotlib.pyplot as plt

from ..settings.models import ApertureSettings

__all__ = ['seeing_plot']


def seeing_plot(raw_radius, raw_counts, binned_radius, binned_counts, HWHM,
plot_title='', file_name='', gap=6, annulus_width=13, radius=None,
plot_title='', file_name='', aperture_settings=None,
figsize=(20, 10)):
"""
Show a seeing plot for data from an image with radius on the x axis and counts (ADU) on the y axis.
Expand Down Expand Up @@ -32,11 +34,8 @@ def seeing_plot(raw_radius, raw_counts, binned_radius, binned_counts, HWHM,
file_name : optional, string
if entered, file will save as png with this name
gap : number
the distance between the aperture and the inner annulus
annulus_width : number
the distance between the inner and outer annulus
aperture_settings : optional, `ApertureSettings`
The aperture settings used to create the plot.
figsize : tuple of int, optional
Size of figure.
Expand All @@ -47,13 +46,19 @@ def seeing_plot(raw_radius, raw_counts, binned_radius, binned_counts, HWHM,
`matplotlib.pyplot.figure`
The figure object containing the seeing plot.
"""
if radius is None:
radius = HWHM * 4
if aperture_settings is None:
radius = 4 * HWHM
aperture_settings = ApertureSettings(radius=radius,
inner_annulus=radius + 10,
outer_annulus=radius + 25)


radius = aperture_settings.radius
inner_annulus = aperture_settings.inner_annulus
outer_annulus = aperture_settings.outer_annulus

fig = plt.figure(figsize=figsize)
plt.grid(True)
inner_annulus = radius + gap
outer_annulus = inner_annulus + annulus_width

# plot the raw radius and raw counts
plt.plot(raw_radius, raw_counts, linestyle='none',
Expand Down Expand Up @@ -101,4 +106,4 @@ def seeing_plot(raw_radius, raw_counts, binned_radius, binned_counts, HWHM,
if file_name:
safe_name = file_name.replace(" ", "-")
plt.savefig(f"{safe_name + '-seeing-profile'}.png")
return fig
return fig

0 comments on commit de64722

Please sign in to comment.