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

Fix profile plots #25

Merged
merged 2 commits into from
Oct 20, 2020
Merged
Changes from all commits
Commits
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
21 changes: 19 additions & 2 deletions stellarphot/visualization/seeing_profile_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,19 @@ def radial_profile(data, center, size=30, return_scaled=True):
return r_exact, ravg, radialprofile


def find_hwhm(r, intensity):
"""
Estimate HWHM from normalized, angle-averaged intensity profile.
"""
# Make the bold assumption that intensity decreases monotonically
# so that we just need to find the first place where intensity is
# less than 0.5 to estimate the HWHM.
less_than_half = intensity < 0.5
half_index = np.arange(len(less_than_half))[less_than_half][0]
before_half = half_index - 1
return (r[before_half] + r[half_index]) / 2


def make_show_event(iw):
def show_event(viewer, event, datax, datay):

Expand Down Expand Up @@ -217,7 +230,8 @@ def show_event(viewer, event, datax, datay):
# print(event.data_x, event.data_y)
plt.clf()
# sub_med += med
seeing_plot(r_exact, scaled_exact_counts, ravg, scaled_profile, 5,
HWHM = find_hwhm(ravg, scaled_profile)
seeing_plot(r_exact, scaled_exact_counts, ravg, scaled_profile, HWHM,
'Some Image Name', file_name='some_name', gap=6, annulus_width=13)
plt.show()

Expand Down Expand Up @@ -265,6 +279,7 @@ def show_event(viewer, event, datax, datay):

def box(imagewidget):
big_box = ipw.HBox()
big_box = ipw.GridspecLayout(1, 2)
layout = ipw.Layout(width='20ch')
hb = ipw.HBox()
ap_t = ipw.IntText(description='Aperture', value=5, layout=layout)
Expand All @@ -274,7 +289,9 @@ def box(imagewidget):

lil_box = ipw.VBox()
lil_box.children = [out, out2, out3]
big_box.children = [imagewidget, lil_box]
# big_box.children = [imagewidget, lil_box]
big_box[0, 0] = imagewidget
big_box[0, 1] = lil_box
big_box.layout.width = '100%'
# Line below puts space between the image and the plots so the plots
# don't jump around as the image value changes.
Expand Down