- Timestamp:
- 18/01/10 17:20:30 (11 years ago)
- Location:
- qesdi/graphplotter/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
qesdi/graphplotter/trunk/df_config/co2.ini
r6311 r6331 7 7 sensitivity=sensitivity_name 8 8 model=model_name 9 10 [DataVariables] 11 data=carbon dioxide -
qesdi/graphplotter/trunk/graphplotter/controllers/buildplot.py
r6330 r6331 21 21 22 22 c.dataFiles = [''] + cr.getDataFileList() 23 log.debug("c.dataFiles = %s" % (c.dataFiles,))23 24 24 params = getParams(request) 25 25 … … 38 38 dfConfig = cr.getConfig(c.selectedDataFile) 39 39 reader = DataReader(dfConfig['path'], dfConfig['axisLookup']) 40 log.debug("dfConfig = %s" % (dfConfig,)) 40 41 41 c.variables = [''] + reader.getVariableNames() 42 if 'dataVariables' in dfConfig: 43 allVars = reader.getVariableNames() 44 45 for v in dfConfig['dataVariables'].keys(): 46 assert v in allVars, 'Variable %s not found in file. Variables found = %s' % (v, allVars) 47 48 c.variables = [('','')] + dfConfig['dataVariables'].items() 49 50 else: 51 c.variables = [''] + reader.getVariableNames() 52 53 42 54 c.selectedVariable = params.get('variable', '') 43 55 -
qesdi/graphplotter/trunk/graphplotter/lib/df_config_reader.py
r6313 r6331 45 45 46 46 dfConfig['axisLookup'] = axisLookup 47 48 if self.cp.has_section('DataVariables'): 49 dataVariables = {} 50 for k in self.cp.options('DataVariables'): 51 dataVariables[k] = self.cp.get('DataVariables',k) 52 53 dfConfig['dataVariables'] = dataVariables 54 47 55 48 56 return dfConfig -
qesdi/graphplotter/trunk/graphplotter/lib/plot_builder.py
r6330 r6331 37 37 plt = Plot() 38 38 39 plt.setYLabel(self. params['variable'])39 plt.setYLabel(self._getVariableName()) 40 40 plt.setXLabel(self.params['axis']) 41 41 42 s = set(selections[0].items())42 commonItems = self._getCommonItems(selections) 43 43 44 for sel in selections[1:]: 45 s = s.intersection(sel.items()) 46 47 commonItems = dict(s) 48 49 title = self.params['variable']+ ' vs ' + self.params['axis'] 50 51 if len(commonItems) > 1: 52 title += ' with ' + self._getLineName(commonItems) 53 54 plt.setTitle(title) 44 self._setPlotTitle(plt, commonItems) 55 45 56 46 log.debug("commonItems = %s" % (commonItems,)) … … 61 51 62 52 53 kwargs ={} 54 63 55 lineName = self._getLineName(sel, commonItems) 64 56 65 plt.draw(xdata, ydata, label=lineName) 57 if lineName != '': 58 kwargs['label'] = lineName 59 60 plt.draw(xdata, ydata, **kwargs) 61 62 log.debug("xdata = %s, ydata = %s" % (xdata, ydata,)) 66 63 67 64 return plt.getImage() … … 111 108 name = name[:-2] 112 109 return name 110 111 def _getCommonItems(self, selections): 112 """ 113 Finds all the common items in all the selection dictionaries 114 """ 115 116 if len(selections) > 1: 117 s = set(selections[0].items()) 118 119 for sel in selections[1:]: 120 s = s.intersection(sel.items()) 121 122 commonItems = dict(s) 123 else: 124 commonItems = {} 125 126 return commonItems 127 128 def _setPlotTitle(self, plt, commonItems): 129 130 title = self._getVariableName() + ' vs ' + self.params['axis'] 131 132 if len(commonItems) > 1: 133 title += ' with ' + self._getLineName(commonItems) 134 135 plt.setTitle(title) 136 137 def _getVariableName(self): 138 """ 139 Attempt to get the variable name from the dataVariables section of the 140 config file, if not just return the variable from the parameters. 141 """ 142 143 if 'dataVariables' in self.config: 144 145 if self.params['variable'] in self.config['dataVariables']: 146 return self.config['dataVariables'][self.params['variable']] 147 148 return self.params['variable'] -
qesdi/graphplotter/trunk/graphplotter/templates/buildplot.html
r6330 r6331 134 134 135 135 </form> 136 <input type="button" value="Remove Selection" onClick=" onAddSelectionClick();"></input>136 <input type="button" value="Remove Selection" onClick=""></input> 137 137 138 138 <input type="button" value="Refresh" onClick="onRefreshClick();"></input>
Note: See TracChangeset
for help on using the changeset viewer.