def onColClick(self, event): # wxGlade: TemperatureSeriesPanel.<event_handler>
     """Sort by temperature."""
     column = event.GetColumn()
     # sort by temperature
     if column == 0:
         sortkey = lambda tf : float(tf[0])
     # sort by filename with numerical comparison of digits
     elif column == 1:
         filenames = [f for t, f in self.datasets]
         numericStringSort(filenames)
         order = dict(zip(filenames, range(len(filenames))))
         sortkey = lambda tf : order[tf[1]]
     # ignore unhandled columns
     else:
         return
     self.datasets.sort(key=sortkey, reverse=self.reverse)
     self.reverse = not self.reverse
     self.fillList()
     return
Beispiel #2
0
 def onColClick(self,
                event):  # wxGlade: TemperatureSeriesPanel.<event_handler>
     """Sort by temperature."""
     column = event.GetColumn()
     # sort by temperature
     if column == 0:
         sortkey = lambda tf: float(tf[0])
     # sort by filename with numerical comparison of digits
     elif column == 1:
         filenames = [f for t, f in self.datasets]
         numericStringSort(filenames)
         order = dict(zip(filenames, range(len(filenames))))
         sortkey = lambda tf: order[tf[1]]
     # ignore unhandled columns
     else:
         return
     self.datasets.sort(key=sortkey, reverse=self.reverse)
     self.reverse = not self.reverse
     self.fillList()
     return
Beispiel #3
0
 def _represent(mixedNames):
     vals = ["@%i"%item for item in mixedNames if isinstance(item, int)]
     others  = [item for item in mixedNames if not isinstance(item, int)]
     vals.extend(others)
     numericStringSort(vals)
     return vals
Beispiel #4
0
    def updateWidgets(self):
        """Enable or disable certain widgets depending upon what is selected in
        the tree and in the plotting widgets.
        """
        # selections: selected nodes in treeCtrl
        # fits:  only different fittings
        # refs:  data item ids ( can be calculation, fit, structure and dataset 
        selections = self.treeCtrlMain.GetSelections()
        # Only proceed if we have compatible items selected from the tree.
        if not selections: 
            self.enableWidgets(False)
            return
        self.enableWidgets(True)
        fits = dict.fromkeys([self.treeCtrlMain.GetControlData(self.treeCtrlMain.GetFitRoot(sel)) 
                              for sel in selections])          
        refs = [self.treeCtrlMain.GetControlData(sel) for sel in selections]
        
        xdata = []
        # step is added if selections include type other than calculation
        for type in [ self.treeCtrlMain.GetNodeType(sel) for sel in selections ]:
            if type != 'calculation':
                xdata.append('step')
                break

        # index is added if mutiple selections are chosen from different fits
        if len(fits) > 1:
            xdata.append('index')

        for ref in refs:
            xdata.extend(ref.getXNames())

        for fit in fits:
            xdata.extend(fit.getMetaDataNames())
            # also can plot y against y so add yNames as well
            xdata.extend(fit.getYNames())

        # reduce 
        xdata = dict.fromkeys(xdata).keys()

        # Make the parameter entries a bit more presentable.
        def _represent(mixedNames):
            vals = ["@%i"%item for item in mixedNames if isinstance(item, int)]
            others  = [item for item in mixedNames if not isinstance(item, int)]
            vals.extend(others)
            numericStringSort(vals)
            return vals
            
        xvals = _represent(xdata)
        try:
            xvals.remove('rw')    
        except:
            pass
        numericStringSort(xvals)
        
        # Fill the xDataCombo
        if self.xDataCombo.GetCount():
            current = self.xDataCombo.GetValue()
        else:
            current = None
        self.xDataCombo.Clear()
        for item in xvals:
            self.xDataCombo.Append(item)
            
        # Set default value for xDataCombo
        # Either keep the current plot value selected, select 'r', or the
        # first in the list.
        defaultOrders = [ 'r', 'step', 'index']
        if current:
            defaultOrders.insert(0, current)
        for item in defaultOrders:
            if item in xvals:
                self.xDataCombo.SetValue(item)
                break
        else:
            self.xDataCombo.SetSelection(0)

        # Y-DATA is the common subset of all data id
        ydata = refs[0].getYNames()
        for ref in refs[1:]:
            for name in ydata[:]:
                if name not in ref.getYNames(): ydata.remove(name)

        yvals = _represent(ydata)

        # Fill the List
        self.yDataList.DeleteAllItems()
        for val in yvals:
            self.yDataList.InsertStringItem(sys.maxint, str(val))
        self.yDataList.makeIDM()
        self.yDataList.initializeSorter()
        if yvals:
            self.yDataList.Select(0)
            
        #self.prevSelectionType = selectiontype
        self._check(None)

        return
 def _represent(mixedNames):
     vals = ["@%i"%item for item in mixedNames if isinstance(item, int)]
     others  = [item for item in mixedNames if not isinstance(item, int)]
     vals.extend(others)
     numericStringSort(vals)
     return vals
    def updateWidgets(self):
        """Enable or disable certain widgets depending upon what is selected in
        the tree and in the plotting widgets.
        """
        # selections: selected nodes in treeCtrl
        # fits:  only different fittings
        # refs:  data item ids ( can be calculation, fit, structure and dataset
        selections = self.treeCtrlMain.GetSelections()
        # Only proceed if we have compatible items selected from the tree.
        if not selections:
            self.enableWidgets(False)
            return
        self.enableWidgets(True)
        fits = dict.fromkeys([self.treeCtrlMain.GetControlData(self.treeCtrlMain.GetFitRoot(sel))
                              for sel in selections])
        refs = [self.treeCtrlMain.GetControlData(sel) for sel in selections]

        xdata = []
        # step is added if selections include type other than calculation
        for type in [ self.treeCtrlMain.GetNodeType(sel) for sel in selections ]:
            if type != 'calculation':
                xdata.append('step')
                break

        # index is added if mutiple selections are chosen from different fits
        if len(fits) > 1:
            xdata.append('index')

        for ref in refs:
            xdata.extend(ref.getXNames())

        for fit in fits:
            xdata.extend(fit.getMetaDataNames())
            # also can plot y against y so add yNames as well
            xdata.extend(fit.getYNames())

        # reduce
        xdata = dict.fromkeys(xdata).keys()

        # Make the parameter entries a bit more presentable.
        def _represent(mixedNames):
            vals = ["@%i"%item for item in mixedNames if isinstance(item, int)]
            others  = [item for item in mixedNames if not isinstance(item, int)]
            vals.extend(others)
            numericStringSort(vals)
            return vals

        xvals = _represent(xdata)
        try:
            xvals.remove('rw')
        except:
            pass
        numericStringSort(xvals)

        # Fill the xDataCombo
        if self.xDataCombo.GetCount():
            current = self.xDataCombo.GetValue()
        else:
            current = None
        self.xDataCombo.Clear()
        for item in xvals:
            self.xDataCombo.Append(item)

        # Set default value for xDataCombo
        # Either keep the current plot value selected, select 'r', or the
        # first in the list.
        defaultOrders = [ 'r', 'step', 'index']
        if current:
            defaultOrders.insert(0, current)
        for item in defaultOrders:
            if item in xvals:
                self.xDataCombo.SetValue(item)
                break
        else:
            self.xDataCombo.SetSelection(0)

        # Y-DATA is the common subset of all data id
        ydata = refs[0].getYNames()
        for ref in refs[1:]:
            for name in ydata[:]:
                if name not in ref.getYNames(): ydata.remove(name)

        yvals = _represent(ydata)

        # Fill the List
        self.yDataList.DeleteAllItems()
        for val in yvals:
            self.yDataList.InsertStringItem(sys.maxint, str(val))
        self.yDataList.makeIDM()
        self.yDataList.initializeSorter()
        if yvals:
            self.yDataList.Select(0)

        #self.prevSelectionType = selectiontype
        self._check(None)

        return