Added log transform, support for multi selections in navigator-scatter, removed get_project-nonsense
This commit is contained in:
parent
a94c3ed1cc
commit
6996aab2fa
@ -87,7 +87,7 @@ class NavigatorView (gtk.TreeView):
|
||||
|
||||
# set timestamp on newly selected objects
|
||||
[tree.set_value(tree.get_iter(path), 6, time.time())
|
||||
for path in paths if path not in tmp]
|
||||
for path in paths if path not in tmp]
|
||||
|
||||
objs = [tree.get_iter(path) for path in paths]
|
||||
objs = [(tree[iter][6], tree[iter][2]) for iter in objs]
|
||||
@ -97,10 +97,10 @@ class NavigatorView (gtk.TreeView):
|
||||
|
||||
if objs and isinstance(objs[0], dataset.Dataset):
|
||||
logger.debug('Selecting dataset')
|
||||
main.project.set_current_data(objs)
|
||||
main.project.current_data = objs
|
||||
else:
|
||||
logger.debug('Deselecting dataset')
|
||||
main.project.set_current_data([])
|
||||
main.project.current_data = []
|
||||
|
||||
def on_row_changed(self, treestore, pos, iter):
|
||||
"""Set correct focus and colours when rows have changed."""
|
||||
@ -217,6 +217,11 @@ class NavigatorMenu(gtk.Menu):
|
||||
self.trans_menu.append(self.trans_stdc_item)
|
||||
self.trans_stdc_item.show()
|
||||
|
||||
self.trans_log_item = gtk.MenuItem('Log')
|
||||
self.trans_log_item.connect('activate', self.on_log, navigator)
|
||||
self.trans_menu.append(self.trans_log_item)
|
||||
self.trans_log_item.show()
|
||||
|
||||
self.trans_item = gtk.MenuItem("Transformation")
|
||||
self.append(self.trans_item)
|
||||
self.trans_item.set_submenu(self.trans_menu)
|
||||
@ -339,14 +344,26 @@ class NavigatorMenu(gtk.Menu):
|
||||
|
||||
def on_plot_scatter(self, item, navigator):
|
||||
project = main.project
|
||||
ds = self.dataset
|
||||
dims = ds.get_dim_name()
|
||||
ids = ds.get_identifiers(dims[1])
|
||||
plot = plots.ScatterPlot(ds, ds,
|
||||
dims[0], dims[1],
|
||||
ids[0], ids[1],
|
||||
name='Scatter (%s)' % ds.get_name())
|
||||
plot.add_axes_spin_buttons(len(ids), 0, 1)
|
||||
datasets = main.project.current_data
|
||||
ds_major = datasets[0]
|
||||
dims_major = ds_major.get_dim_name()
|
||||
ids_major = ds_major.get_identifiers(dims_major[1])
|
||||
if len(datasets)>1:
|
||||
# If there is more than one active dataset -> try to use the two first
|
||||
ds_minor = datasets[1]
|
||||
dims_minor = ds_minor.get_dim_name()
|
||||
if dims_minor != dims_major or ds_minor.shape[0] != ds_major.shape[0]:
|
||||
# the selected datasets are not matched -> use initial selected
|
||||
ds_minor = ds_major
|
||||
else:
|
||||
#Only one dataset selected
|
||||
ds_minor = ds_major
|
||||
|
||||
plot = plots.ScatterPlot(ds_major, ds_minor,
|
||||
dims_major[0], dims_major[1],
|
||||
ids_major[0], ids_major[1],
|
||||
name='Scatter (%s)' % ds_major.get_name())
|
||||
plot.add_axes_spin_buttons(len(ids_major), 0, 1)
|
||||
icon = fluents.icon_factory.get("line_plot")
|
||||
project.data_tree_insert(self.tree_iter, 'Scatter', plot, None, "black", icon)
|
||||
plot.set_selection_listener(project.set_selection)
|
||||
@ -372,16 +389,32 @@ class NavigatorMenu(gtk.Menu):
|
||||
def on_standardise_rows(self, item, navigator):
|
||||
project = main.project
|
||||
ds = self.dataset.copy()
|
||||
ds._name = self.dataset._name + ".rsc"
|
||||
axis = 1
|
||||
ds._array = ds._array/scipy.expand_dims(ds._array.std(axis), axis)
|
||||
icon = fluents.icon_factory.get("dataset")
|
||||
project.data_tree_insert(self.tree_iter, self.dataset.get_name()+".rsc", ds, None, "black", icon)
|
||||
project.data_tree_insert(self.tree_iter, ds._name, ds, None, "black", icon)
|
||||
|
||||
def on_standardise_cols(self, item, navigator):
|
||||
project = main.project
|
||||
ds = self.dataset.copy()
|
||||
ds._name = self.dataset._name + ".csc"
|
||||
axis = 0
|
||||
ds._array = ds._array/scipy.expand_dims(ds._array.std(axis), axis)
|
||||
icon = fluents.icon_factory.get("dataset")
|
||||
project.data_tree_insert(self.tree_iter, self.dataset.get_name()+".csc", ds, None, "black", icon)
|
||||
project.data_tree_insert(self.tree_iter, ds._name, ds, None, "black", icon)
|
||||
|
||||
def on_log(self, item, navigator):
|
||||
project = main.project
|
||||
try:
|
||||
if not scipy.all(self.dataset._array>0):
|
||||
raise ValueError
|
||||
except:
|
||||
logger.log('warning', 'Datasets needs to be strictly positive for a log transform')
|
||||
return
|
||||
|
||||
ds = self.dataset.copy()
|
||||
ds._array = scipy.log(ds._array)
|
||||
icon = fluents.icon_factory.get("dataset")
|
||||
ds._name = self.dataset.get_name()+".log"
|
||||
project.data_tree_insert(self.tree_iter, ds._name, ds, None, "black", icon)
|
||||
|
Reference in New Issue
Block a user