Changeset 5c4b674 in sasview
- Timestamp:
- Mar 2, 2011 4:35:08 PM (13 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 883e5f5
- Parents:
- 22b3fe1
- Location:
- guiframe
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/dataFitting.py
r8a7d922 r5c4b674 33 33 self.ytransform = None 34 34 self.title = "" 35 35 self.scale = None 36 36 37 def copy_from_datainfo(self, data1d): 37 38 """ … … 107 108 self.ytransform = None 108 109 self.title = "" 110 self.scale = None 109 111 110 112 def copy_from_datainfo(self, data1d): … … 176 178 q_data=q_data, mask=mask) 177 179 self.id = None 180 self.group_id = [] 181 self.is_data = True 178 182 self.path = None 183 self.xtransform = None 184 self.ytransform = None 179 185 self.title = "" 180 186 self.scale = None 181 self.group_id = []182 187 183 188 def copy_from_datainfo(self, data2d): -
guiframe/data_manager.py
ra07e72f r5c4b674 117 117 msg += "" 118 118 logging.info(msg) 119 data_state = DataState(data) 119 self.stored_data[data.id].data = data 120 data_state = self.stored_data[data.id] 121 else: 122 data_state = DataState(data) 123 self.stored_data[data.id] = data_state 120 124 self._selected_data[data.id] = data_state 121 self.stored_data[data.id] = data_state122 125 123 126 def set_auto_plot(self, flag=False): -
guiframe/data_panel.py
rea5692d r5c4b674 21 21 22 22 PANEL_WIDTH = 200 23 23 #PANEL_HEIGHT = 560 24 PANEL_HEIGHT = 800 24 25 class DataTreeCtrl(CT.CustomTreeCtrl): 25 26 """ … … 47 48 #ALWAYS_ON = True 48 49 def __init__(self, parent, list=[],list_of_perspective=[], 49 size=(PANEL_WIDTH, 560), manager=None, *args, **kwds):50 size=(PANEL_WIDTH,PANEL_HEIGHT), manager=None, *args, **kwds): 50 51 kwds['size']= size 51 52 ScrolledPanel.__init__(self, parent=parent, *args, **kwds) … … 68 69 self.define_panel_structure() 69 70 self.layout_selection() 70 self.layout_list() 71 self.layout_data_list() 72 self.layout_theory_list() 71 73 self.layout_button() 72 74 self.layout_batch() … … 79 81 self.vbox = wx.BoxSizer(wx.VERTICAL) 80 82 self.sizer1 = wx.BoxSizer(wx.VERTICAL) 81 self.sizer1.SetMinSize((w/12, h/2)) 83 self.sizer1.SetMinSize((w/12, h*1/5)) 84 self.sizer6 = wx.BoxSizer(wx.VERTICAL) 85 self.sizer6.SetMinSize((w/12, h*1/5)) 82 86 self.sizer2 = wx.BoxSizer(wx.VERTICAL) 83 87 self.sizer3 = wx.GridBagSizer(5,5) … … 87 91 self.vbox.Add(self.sizer5, 0,wx.EXPAND|wx.ALL,10) 88 92 self.vbox.Add(self.sizer1, 0,wx.EXPAND|wx.ALL,0) 93 self.vbox.Add(self.sizer6, 0,wx.EXPAND|wx.ALL,0) 89 94 self.vbox.Add(self.sizer2, 0,wx.EXPAND|wx.ALL,10) 90 95 self.vbox.Add(self.sizer3, 0,wx.EXPAND|wx.ALL,10) … … 269 274 (self.rb_batch_mode,0, wx.ALL,5)]) 270 275 271 def layout_ list(self):276 def layout_data_list(self): 272 277 """ 273 278 Add a listcrtl in the panel … … 280 285 self.sizer1.Add(label, 0, wx.LEFT, 10) 281 286 self.sizer1.Add(self.tree_ctrl,1, wx.EXPAND|wx.ALL, 10) 287 288 def layout_theory_list(self): 289 """ 290 Add a listcrtl in the panel 291 """ 292 self.tree_ctrl_theory = DataTreeCtrl(parent=self) 293 self.tree_ctrl_theory.Bind(CT.EVT_TREE_ITEM_CHECKED, self.on_check_item) 294 self.tree_ctrl_theory.Bind(CT.EVT_TREE_ITEM_RIGHT_CLICK, self.on_right_click) 295 label = wx.StaticText(self, -1, "CREATED DATA") 296 label.SetForegroundColour('blue') 297 self.sizer6.Add(label, 0, wx.LEFT, 10) 298 self.sizer6.Add(self.tree_ctrl_theory,1, wx.EXPAND|wx.ALL, 10) 282 299 283 300 def on_right_click(self, event): … … 332 349 path = dstate.get_path() 333 350 theory_list = dstate.get_theory() 334 theory = None335 if theory_list:336 theory = theory_list[len(theory_list)-1]337 351 data_child = None 338 for item in self.list_cb_data: 339 if self.tree_ctrl.GetItemText(item) == data_name: 340 data_child = item 341 for process in data.process: 342 theory_child = self.tree_ctrl.FindItem(data_child, 343 "Available Theories"), 344 if theory is not None: 345 av_theory_child =self.tree_ctrl.AppendItem(theory_child, 346 theory.name,ct_type=1, data=theory.id) 347 self.list_cb_theory.append(av_theory_child) 348 av_theory_child_info =self.tree_ctrl.AppendItem(av_theory_child, 349 'info') 350 for process in theory.process: 351 info_time_child =self.tree_ctrl.AppendItem(av_theory_child_info, 352 process.__str__()) 353 354 break 352 if theory_list: 353 for theory_id,theory in theory_list: 354 for item in self.list_cb_data: 355 data_id, data_class = self.tree_ctrl.GetItemPyData(item) 356 if data_id == data.id: 357 data_child = item 358 for process in data.process: 359 theory_child = self.tree_ctrl.FindItem(data_child, 360 "Available Theories"), 361 if theory is not None: 362 av_theory_child =self.tree_ctrl.AppendItem(theory_child, 363 theory.name,ct_type=1, 364 data=(theory_id, theory)) 365 self.list_cb_theory.append(av_theory_child) 366 av_theory_child_info =self.tree_ctrl.AppendItem(av_theory_child, 367 'info') 368 for process in theory.process: 369 info_time_child = self.tree_ctrl.AppendItem(av_theory_child_info, 370 process.__str__()) 371 372 break 355 373 if data_child is None: 356 data_child =self.tree_ctrl.InsertItem(self.tree_ctrl.root,0, 357 data_name,ct_type=1, data=(data.id, data_class)) 374 data_child = self.tree_ctrl.InsertItem(self.tree_ctrl.root,0, 375 data_name, ct_type=1, 376 data=(data.id, data_class)) 358 377 cb_data = self.tree_ctrl.GetFirstChild(self.tree_ctrl.root) 359 378 item, id = cb_data … … 466 485 ALWAYS_ON = True 467 486 468 def __init__(self, parent=None, owner=None, manager=None,size=(600, 600),487 def __init__(self, parent=None, owner=None, manager=None,size=(600, 800), 469 488 list_of_perspective=[],list=[], *args, **kwds): 470 489 #kwds['size'] = size -
guiframe/data_state.py
r584c4c4 r5c4b674 23 23 self.name = "" 24 24 self.path = None 25 self.theory_list = []25 self.theory_list = {} 26 26 self.state_list = [] 27 27 self.message = "" … … 52 52 """ 53 53 """ 54 self.theory_list .append(theory)54 self.theory_list[theory.id] = theory 55 55 56 56 def get_theory(self): -
guiframe/local_perspectives/plotting/plotting.py
ra07e72f r5c4b674 75 75 """show plug-in panel""" 76 76 pass 77 78 #def _on_plot_event(self, event): 79 # return profile(self.tested_on_plot_event, event) 77 80 78 81 def _on_plot_event(self, event): … … 162 165 163 166 return 167 168 def profile(fn, *args, **kw): 169 import cProfile, pstats, os 170 global call_result 171 def call(): 172 global call_result 173 call_result = fn(*args, **kw) 174 cProfile.runctx('call()', dict(call=call), {}, 'profile.txt') 175 stats = pstats.Stats('profile.txt') 176 stats.sort_stats('time') 177 #stats.sort_stats('calls') 178 stats.print_stats() 179 #os.unlink('profile.out') 180 return call_result 181 164 182 -
guiframe/state_reader.py
ra07e72f r5c4b674 39 39 from lxml import etree 40 40 import xml.dom.minidom 41 from DataLoader.readers.cansas_reader import Reader as CansasReader 41 42 42 has_converter = True 43 43 try: … … 46 46 has_converter = False 47 47 48 CANSAS_NS = "cansas1d/1.0"48 STATE_NS = "State/1.0" 49 49 50 50 def write_node(doc, parent, name, value, attr={}): … … 76 76 :return: Element, or None 77 77 """ 78 nodes = node.xpath(location, namespaces={'ns': CANSAS_NS})78 nodes = node.xpath(location, namespaces={'ns': STATE_NODE}) 79 79 80 80 if len(nodes)>0: … … 90 90 :param node: node to start at 91 91 """ 92 nodes = node.xpath(location, namespaces={'ns': CANSAS_NS})92 nodes = node.xpath(location, namespaces={'ns': STATE_NODE}) 93 93 94 94 value = None … … 99 99 except: 100 100 # Could not pass, skip and return None 101 msg = " cansas_reader.get_float: could not "101 msg = "state_reader.get_float: could not " 102 102 msg += " convert '%s' to float" % nodes[0].text 103 103 logging.error(msg) … … 107 107 108 108 109 class Reader1D (CansasReader):109 class Reader1D: 110 110 """ 111 Class to load cansas 1D XML files111 read state of a plugin and available data 112 112 113 113 :Dependencies: … … 125 125 126 126 def __init__(self): 127 CansasReader.__init__(self)128 127 ## List of errors 129 128 self.errors = [] … … 155 154 156 155 entry_list = root.xpath('/ns:SASroot/ns:SASentry', 157 namespaces={'ns': CANSAS_NS})156 namespaces={'ns': STATE_NODE}) 158 157 159 158 for entry in entry_list: … … 196 195 197 196 # Look up run number 198 nodes = dom.xpath('ns:Run', namespaces={'ns': CANSAS_NS})197 nodes = dom.xpath('ns:Run', namespaces={'ns': STATE_NODE}) 199 198 for item in nodes: 200 199 if item.text is not None: … … 210 209 211 210 # Notes 212 note_list = dom.xpath('ns:SASnote', namespaces={'ns': CANSAS_NS})211 note_list = dom.xpath('ns:SASnote', namespaces={'ns': STATE_NODE}) 213 212 for note in note_list: 214 213 try: … … 218 217 data_info.notes.append(note_value) 219 218 except: 220 err_mess = " cansas_reader.read: error processing"219 err_mess = "state_reader.read: error processing" 221 220 err_mess += " entry notes\n %s" % sys.exc_value 222 221 self.errors.append(err_mess) … … 238 237 239 238 nodes = dom.xpath('ns:SASsample/ns:details', 240 namespaces={'ns': CANSAS_NS})239 namespaces={'ns': STATE_NODE}) 241 240 for item in nodes: 242 241 try: … … 246 245 data_info.sample.details.append(detail_value) 247 246 except: 248 err_mess = " cansas_reader.read: error processing "247 err_mess = "state_reader.read: error processing " 249 248 err_mess += " sample details\n %s" % sys.exc_value 250 249 self.errors.append(err_mess) … … 299 298 # Collimation info ################### 300 299 nodes = dom.xpath('ns:SASinstrument/ns:SAScollimation', 301 namespaces={'ns': CANSAS_NS})300 namespaces={'ns': STATE_NODE}) 302 301 for item in nodes: 303 302 collim = Collimation() … … 307 306 308 307 # Look for apertures 309 apert_list = item.xpath('ns:aperture', namespaces={'ns': CANSAS_NS})308 apert_list = item.xpath('ns:aperture', namespaces={'ns': STATE_NODE}) 310 309 for apert in apert_list: 311 310 aperture = Aperture() … … 331 330 # Detector info ###################### 332 331 nodes = dom.xpath('ns:SASinstrument/ns:SASdetector', 333 namespaces={'ns': CANSAS_NS})332 namespaces={'ns': STATE_NODE}) 334 333 for item in nodes: 335 334 … … 373 372 374 373 # Processes info ###################### 375 nodes = dom.xpath('ns:SASprocess', namespaces={'ns': CANSAS_NS})374 nodes = dom.xpath('ns:SASprocess', namespaces={'ns': STATE_NODE}) 376 375 for item in nodes: 377 376 process = Process() … … 380 379 self._store_content('ns:description', item, 'description', process) 381 380 382 term_list = item.xpath('ns:term', namespaces={'ns': CANSAS_NS})381 term_list = item.xpath('ns:term', namespaces={'ns': STATE_NODE}) 383 382 for term in term_list: 384 383 try: … … 390 389 process.term.append(term_attr) 391 390 except: 392 err_mess = " cansas_reader.read: error processing "391 err_mess = "state_reader.read: error processing " 393 392 err_mess += " process term\n %s" % sys.exc_value 394 393 self.errors.append(err_mess) … … 396 395 397 396 note_list = item.xpath('ns:SASprocessnote', 398 namespaces={'ns': CANSAS_NS})397 namespaces={'ns': STATE_NODE}) 399 398 for note in note_list: 400 399 if note.text is not None: … … 405 404 406 405 # Data info ###################### 407 nodes = dom.xpath('ns:SASdata', namespaces={'ns': CANSAS_NS})406 nodes = dom.xpath('ns:SASdata', namespaces={'ns': STATE_NODE}) 408 407 if len(nodes) > 1: 409 408 msg = "CanSAS reader is not compatible with multiple" … … 411 410 raise RuntimeError, msg 412 411 413 nodes = dom.xpath('ns:SASdata/ns:Idata', namespaces={'ns': CANSAS_NS})412 nodes = dom.xpath('ns:SASdata/ns:Idata', namespaces={'ns': STATE_NODE}) 414 413 415 414 x = numpy.zeros(0) … … 634 633 write_node(doc, pt, "Idev", datainfo.dy[i], 635 634 {'unit':datainfo.y_unit}) 636 637 635 #data gui info 636 gui_info = doc.createElement("DataInfoGui") 637 638 write_node(doc, gui_info, "group_id", 'group_id') 639 for item in datainfo.group_id: 640 write_node(doc, gui_info, "group_id", str(item)) 641 write_node(doc, gui_info, "name", datainfo.name) 642 write_node(doc, gui_info, "id", datainfo.id) 643 write_node(doc, gui_info, "group_id", datainfo.groud_id) 644 write_node(doc, gui_info, "name", datainfo.name) 645 write_node(doc, gui_info, "is_data", datainfo.is_data) 646 write_node(doc, gui_info, "xtransform", datainfo.xtransform) 647 write_node(doc, gui_info, "scale", datainfo.scale) 648 write_node(doc, gui_info, "ytransform", datainfo.ytransform) 649 write_node(doc, gui_info, "path", datainfo.path) 650 node.appendChild(gui_info) 638 651 # Sample info 639 652 sample = doc.createElement("SASsample") … … 922 935 923 936 924 class Reader2D (CansasReader):937 class Reader2D: 925 938 """ 926 Class to load a .fitv fitting file939 Class to load a basic guiframe state 927 940 """ 928 941 ## File type … … 1154 1167 return doc, entry_node 1155 1168 1156 def _parse_state(self, entry ):1169 def _parse_state(self, entry, NODE_NAME= 'state'): 1157 1170 """ 1158 1171 Read a fit result from an XML node … … 1166 1179 # Locate the P(r) node 1167 1180 try: 1168 nodes = entry.xpath('ns:%s' % FITTING_NODE_NAME, namespaces={'ns': CANSAS_NS})1181 nodes = entry.xpath('ns:%s' % NODE_NAME, namespaces={'ns': STATE_NODE}) 1169 1182 if nodes !=[]: 1170 1183 # Create an empty state … … 1187 1200 1188 1201 """ 1189 node = dom.xpath('ns:data_class', namespaces={'ns': CANSAS_NS})1202 node = dom.xpath('ns:data_class', namespaces={'ns': STATE_NODE}) 1190 1203 if not node or node[0].text.lstrip().rstrip() != "Data2D": 1191 1204 return CansasReader._parse_entry(self, dom) … … 1198 1211 1199 1212 # Look up run number 1200 nodes = dom.xpath('ns:Run', namespaces={'ns': CANSAS_NS})1213 nodes = dom.xpath('ns:Run', namespaces={'ns': STATE_NODE}) 1201 1214 for item in nodes: 1202 1215 if item.text is not None: … … 1211 1224 1212 1225 # Notes 1213 note_list = dom.xpath('ns:SASnote', namespaces={'ns': CANSAS_NS})1226 note_list = dom.xpath('ns:SASnote', namespaces={'ns': STATE_NODE}) 1214 1227 for note in note_list: 1215 1228 try: … … 1219 1232 data_info.notes.append(note_value) 1220 1233 except: 1221 err_mess = " cansas_reader.read: error processing entry notes\n %s" % sys.exc_value1234 err_mess = "state_reader.read: error processing entry notes\n %s" % sys.exc_value 1222 1235 self.errors.append(err_mess) 1223 1236 logging.error(err_mess) … … 1237 1250 dom, 'temperature', data_info.sample) 1238 1251 1239 nodes = dom.xpath('ns:SASsample/ns:details', namespaces={'ns': CANSAS_NS})1252 nodes = dom.xpath('ns:SASsample/ns:details', namespaces={'ns': STATE_NODE}) 1240 1253 for item in nodes: 1241 1254 try: … … 1245 1258 data_info.sample.details.append(detail_value) 1246 1259 except: 1247 err_mess = " cansas_reader.read: error processing sample details\n %s" % sys.exc_value1260 err_mess = "state_reader.read: error processing sample details\n %s" % sys.exc_value 1248 1261 self.errors.append(err_mess) 1249 1262 logging.error(err_mess) … … 1296 1309 1297 1310 # Collimation info ################### 1298 nodes = dom.xpath('ns:SASinstrument/ns:SAScollimation', namespaces={'ns': CANSAS_NS})1311 nodes = dom.xpath('ns:SASinstrument/ns:SAScollimation', namespaces={'ns': STATE_NODE}) 1299 1312 for item in nodes: 1300 1313 collim = Collimation() … … 1304 1317 1305 1318 # Look for apertures 1306 apert_list = item.xpath('ns:aperture', namespaces={'ns': CANSAS_NS})1319 apert_list = item.xpath('ns:aperture', namespaces={'ns': STATE_NODE}) 1307 1320 for apert in apert_list: 1308 1321 aperture = Aperture() … … 1327 1340 1328 1341 # Detector info ###################### 1329 nodes = dom.xpath('ns:SASinstrument/ns:SASdetector', namespaces={'ns': CANSAS_NS})1342 nodes = dom.xpath('ns:SASinstrument/ns:SASdetector', namespaces={'ns': STATE_NODE}) 1330 1343 for item in nodes: 1331 1344 … … 1360 1373 1361 1374 # Processes info ###################### 1362 nodes = dom.xpath('ns:SASprocess', namespaces={'ns': CANSAS_NS})1375 nodes = dom.xpath('ns:SASprocess', namespaces={'ns': STATE_NODE}) 1363 1376 for item in nodes: 1364 1377 process = Process() … … 1367 1380 self._store_content('ns:description', item, 'description', process) 1368 1381 1369 term_list = item.xpath('ns:term', namespaces={'ns': CANSAS_NS})1382 term_list = item.xpath('ns:term', namespaces={'ns': STATE_NODE}) 1370 1383 for term in term_list: 1371 1384 try: … … 1377 1390 process.term.append(term_attr) 1378 1391 except: 1379 err_mess = " cansas_reader.read: error processing process term\n %s" % sys.exc_value1392 err_mess = "state_reader.read: error processing process term\n %s" % sys.exc_value 1380 1393 self.errors.append(err_mess) 1381 1394 logging.error(err_mess) 1382 1395 1383 note_list = item.xpath('ns:SASprocessnote', namespaces={'ns': CANSAS_NS})1396 note_list = item.xpath('ns:SASprocessnote', namespaces={'ns': STATE_NODE}) 1384 1397 for note in note_list: 1385 1398 if note.text is not None: … … 1390 1403 1391 1404 # Data info ###################### 1392 nodes = dom.xpath('ns:SASdata', namespaces={'ns': CANSAS_NS})1405 nodes = dom.xpath('ns:SASdata', namespaces={'ns': STATE_NODE}) 1393 1406 if len(nodes)>1: 1394 1407 raise RuntimeError, "CanSAS reader is not compatible with multiple SASdata entries" … … 1439 1452 # Specifying the namespace will take care of the file format version 1440 1453 root = tree.getroot() 1441 entry_list = root.xpath('ns:SASentry', namespaces={'ns': CANSAS_NS})1454 entry_list = root.xpath('ns:SASentry', namespaces={'ns': STATE_NODE}) 1442 1455 for entry in entry_list: 1443 1456 try: … … 1587 1600 logging.basicConfig(level=logging.ERROR, 1588 1601 format='%(asctime)s %(levelname)s %(message)s', 1589 filename=' cansas_reader.log',1602 filename='state_reader.log', 1590 1603 filemode='w') 1591 1604 reader = Reader()
Note: See TracChangeset
for help on using the changeset viewer.