Skip to content

Commit

Permalink
Display fit results in its own section
Browse files Browse the repository at this point in the history
and fix plot titles
  • Loading branch information
pllim committed Jun 29, 2022
1 parent 0474a04 commit a2111ff
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Imviz
^^^^^

- Added the ability to fit Gaussian1D model to radial profile in
Simple Aperture Photometry plugin. [#1409]
Simple Aperture Photometry plugin. Radial profile now centers
on source centroid, not Subset center. [#1409]

Mosviz
^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class SimpleAperturePhotometry(TemplateMixin, DatasetSelectMixin):
plot_available = Bool(False).tag(sync=True)
radial_plot = Any('').tag(sync=True, **widget_serialization)
fit_radial_profile = Bool(False).tag(sync=True)
fit_results = List().tag(sync=True)

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down Expand Up @@ -349,15 +350,15 @@ def vue_do_aper_phot(self, *args, **kwargs):
label=comp.units or 'Value')]

if self.current_plot_type == "Radial Profile":
self._fig.title = 'Radial profile from Subset center'
self._fig.title = 'Radial profile from source centroid'
x_data, y_data = _radial_profile(
phot_aperstats.data_cutout, phot_aperstats.bbox, phot_aperstats.centroid,
raw=False)
bqplot_line = bqplot.Lines(x=x_data, y=y_data, marker='circle',
scales={'x': line_x_sc, 'y': line_y_sc},
marker_size=32, colors='gray')
else: # Radial Profile (Raw)
self._fig.title = 'Raw radial profile from Subset center'
self._fig.title = 'Raw radial profile from source centroid'
x_data, y_data = _radial_profile(
phot_aperstats.data_cutout, phot_aperstats.bbox, phot_aperstats.centroid,
raw=True)
Expand Down Expand Up @@ -419,16 +420,18 @@ def vue_do_aper_phot(self, *args, **kwargs):
f'{x:.4e} ({phot_table["aperture_sum_counts_err"][0]:.4e})'})
else:
tmp.append({'function': key, 'result': str(x)})

# Also display fit results
fit_tmp = []
if fit_model is not None and isinstance(fit_model, Gaussian1D):
model_name = fit_model.__class__.__name__
for param in ('fwhm', 'mean', 'amplitude'):
p_val = getattr(fit_model, param)
if isinstance(p_val, Parameter):
p_val = p_val.value
tmp.append({'function': f'{model_name}_{param}',
'result': f'{p_val:.4e}'})
fit_tmp.append({'function': param, 'result': f'{p_val:.4e}'})

self.results = tmp
self.fit_results = fit_tmp
self.result_available = True
self.radial_plot = self._fig
self.bqplot_figs_resize = [self._fig]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,25 @@
<jupyter-widget :widget="radial_plot" style="width: 100%; height: 480px" />
</v-row>

<div v-if="plot_available && fit_radial_profile">
<j-plugin-section-header>Gaussian Fit Results</j-plugin-section-header>
<v-row no-gutters>
<v-col cols=6><U>Result</U></v-col>
<v-col cols=6><U>Value</U></v-col>
</v-row>
<v-row
v-for="item in fit_results"
:key="item.function"
no-gutters>
<v-col cols=6>
{{ item.function }}
</v-col>
<v-col cols=6>{{ item.result }}</v-col>
</v-row>
</div>

<div v-if="result_available">
<j-plugin-section-header>Results</j-plugin-section-header>
<j-plugin-section-header>Photometry Results</j-plugin-section-header>
<v-row no-gutters>
<v-col cols=6><U>Result</U></v-col>
<v-col cols=6><U>Value</U></v-col>
Expand Down

0 comments on commit a2111ff

Please sign in to comment.