From b57f18a388658f4c8d55789b7391de6f825593c1 Mon Sep 17 00:00:00 2001 From: Matt Craig Date: Tue, 20 Oct 2020 08:48:51 -0500 Subject: [PATCH 1/2] Calculate HWHM --- .../visualization/seeing_profile_functions.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/stellarphot/visualization/seeing_profile_functions.py b/stellarphot/visualization/seeing_profile_functions.py index 6ad3b20c..d121c239 100644 --- a/stellarphot/visualization/seeing_profile_functions.py +++ b/stellarphot/visualization/seeing_profile_functions.py @@ -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): @@ -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() From d1d8cb05b76921554629c0bbf4308f34acf96095 Mon Sep 17 00:00:00 2001 From: Matt Craig Date: Tue, 20 Oct 2020 08:49:44 -0500 Subject: [PATCH 2/2] Fix width of viewer and extra plots --- stellarphot/visualization/seeing_profile_functions.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stellarphot/visualization/seeing_profile_functions.py b/stellarphot/visualization/seeing_profile_functions.py index d121c239..2046be35 100644 --- a/stellarphot/visualization/seeing_profile_functions.py +++ b/stellarphot/visualization/seeing_profile_functions.py @@ -279,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) @@ -288,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.