Skip to content
This repository has been archived by the owner on Jul 22, 2021. It is now read-only.

Commit

Permalink
Merge pull request #402 from nmearl/master
Browse files Browse the repository at this point in the history
Fix model loading issue and unit generation
  • Loading branch information
nmearl authored Apr 30, 2018
2 parents 0683eeb + 509777f commit 975abcd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
4 changes: 3 additions & 1 deletion specviz/plugins/model_fitting_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def setup_connections(self):
self.save_model)

self.contents.button_load_model.clicked.connect(
self.load_model)
lambda: self.load_model())

self.contents.button_export_model.clicked.connect(
self.export_model)
Expand Down Expand Up @@ -553,9 +553,11 @@ def toggle_fitting(self, *args, **kwargs):
if root.childCount() > 0:
self.contents.group_box_fitting.setEnabled(True)
self.contents.button_save_model.setEnabled(True)
self.contents.button_export_model.setEnabled(True)
else:
self.contents.group_box_fitting.setEnabled(False)
self.contents.button_save_model.setEnabled(False)
self.contents.button_export_model.setEnabled(True)

@dispatch.register_listener("on_selected_layer")
def toggle_io(self, layer_item, *args, **kwargs):
Expand Down
24 changes: 12 additions & 12 deletions specviz/widgets/sub_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,22 @@ def get_all_layers(self):

@dispatch.register_listener("changed_units")
def change_units(self, x=None, y=None, z=None):
for cntr in self._plots:
cntr.change_units(x, y, z)

if len(self._plots) > 0:
cur_disp_line_pos = Quantity(
self._disp_line.value(),
self._plot_units[0] or self._plots[0].layer.dispersion_unit)
for cntr in self._plots:
cntr.change_units(x, y, z)

self._plot_units = [self._plots[0].layer.dispersion_unit,
self._plots[0].layer.unit, z]

cur_disp_line_pos = Quantity(
self._disp_line.value(),
self._plot_units[0] or self._plots[0].layer.dispersion_unit)

# Update vertical line indicated position
self._disp_line.setValue(cur_disp_line_pos.to(
self._plots[0].layer.dispersion_unit).value)
else:
self._plot_units = [x, y, z]

self.set_labels(*self._plot_units)
self._plot_item.enableAutoRange()
Expand Down Expand Up @@ -456,14 +458,15 @@ def comp_disp(plot, layer):
new_plot = LinePlot.from_layer(
layer, **(style or {'color': next(self._available_colors)}))

if len(self._plots) == 0:
self.change_units(new_plot.layer.dispersion_unit, new_plot.layer.unit)
else:
if len(self._plots) > 0:
if not new_plot.layer.set_units(*self._plot_units[:2]):
logging.error("Unable to convert data layer units to plot units.")

dispatch.on_remove_layer.emit(layer=layer)
return
else:
# Update plot units
self.change_units(new_plot.layer.dispersion_unit, new_plot.layer.unit)

if new_plot.error is not None:
self._plot_item.addItem(new_plot.error)
Expand All @@ -476,9 +479,6 @@ def comp_disp(plot, layer):

self.set_active_plot(new_plot.layer)

# Update plot units
self._plot_units = [layer.dispersion_unit, layer.unit, None]

# Make sure the dynamic axis object has access to a layer
self._dynamic_axis._layer = self._plots[0].layer

Expand Down

0 comments on commit 975abcd

Please sign in to comment.