- Timestamp:
- Aug 6, 2010 7:36:07 PM (14 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:
- 028a0e8
- Parents:
- a93f525
- Location:
- prview/perspectives/pr
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
prview/perspectives/pr/inversion_panel.py
r0d21ac1 rb35d3d1 252 252 253 253 dlg.Destroy() 254 254 255 state = self.get_state() 256 257 self.manager.save_data(filepath=path, prstate=state) 258 259 return state 260 261 def get_state(self): 262 """ 263 Get the current state 264 265 : return: state object 266 """ 255 267 # Construct the state object 256 268 state = InversionState() … … 287 299 state.iq0 = self.iq0 288 300 state.bck = self.bck 289 290 self.manager.save_data(filepath=path, prstate=state)291 301 292 302 return state -
prview/perspectives/pr/inversion_state.py
r7116b6e0 rb35d3d1 341 341 342 342 ## Wildcards 343 type = ["P(r) files (*.prv)|*.prv"] 343 type = ["P(r) files (*.prv)|*.prv", 344 "SANSView files (*.svs)|*.svs"] 344 345 ## List of allowed extensions 345 ext=['.prv', '.PRV' ]346 ext=['.prv', '.PRV', '.svs', '.SVS'] 346 347 347 348 def __init__(self, call_back, cansas=True): … … 401 402 402 403 """ 403 # Create an empty state 404 state = InversionState() 404 state = None 405 405 406 406 # Locate the P(r) node 407 407 try: 408 408 nodes = entry.xpath('ns:%s' % PRNODE_NAME, namespaces={'ns': CANSAS_NS}) 409 state.fromXML(node=nodes[0]) 409 if nodes !=[]: 410 # Create an empty state 411 state = InversionState() 412 state.fromXML(node=nodes[0]) 410 413 except: 411 414 logging.info("XML document does not contain P(r) information.\n %s" % sys.exc_value) … … 447 450 sas_entry = self._parse_entry(entry) 448 451 prstate = self._parse_prstate(entry) 449 sas_entry.meta_data['prstate'] = prstate 450 sas_entry.filename = prstate.file 451 output.append(sas_entry) 452 #prstate could be None when .svs file is loaded 453 #in this case, skip appending to output 454 if prstate != None: 455 sas_entry.meta_data['prstate'] = prstate 456 sas_entry.filename = prstate.file 457 output.append(sas_entry) 452 458 else: 453 459 raise RuntimeError, "%s is not a file" % path … … 475 481 # Sanity check 476 482 if self.cansas == True: 477 if datainfo is None: 478 datainfo = DataLoader.data_info.Data1D(x=[], y=[]) 479 elif not issubclass(datainfo.__class__, DataLoader.data_info.Data1D): 480 raise RuntimeError, "The cansas writer expects a Data1D instance: %s" % str(datainfo.__class__.__name__) 481 482 # Create basic XML document 483 doc, sasentry = self._to_xml_doc(datainfo) 484 485 # Add the P(r) information to the XML document 486 if prstate is not None: 487 prstate.toXML(doc=doc, entry_node=sasentry) 488 483 doc =self.write_toXML(datainfo, prstate) 489 484 # Write the XML document 490 485 fd = open(filename, 'w') … … 494 489 prstate.toXML(file=filename) 495 490 496 497 491 def write_toXML(self, datainfo=None, state=None): 492 """ 493 Write toXML, a helper for write() 494 495 : return: xml doc 496 """ 497 if datainfo is None: 498 datainfo = DataLoader.data_info.Data1D(x=[], y=[]) 499 elif not issubclass(datainfo.__class__, DataLoader.data_info.Data1D): 500 raise RuntimeError, "The cansas writer expects a Data1D instance: %s" % str(datainfo.__class__.__name__) 501 502 # Create basic XML document 503 doc, sasentry = self._to_xml_doc(datainfo) 504 505 # Add the invariant information to the XML document 506 if state is not None: 507 state.toXML(doc=doc, entry_node=sasentry) 508 509 return doc 510 -
prview/perspectives/pr/pr.py
red90edb rb35d3d1 112 112 l = Loader() 113 113 l.associate_file_reader('.prv', self.state_reader) 114 l.associate_file_reader(".sav", self.state_reader) 114 115 115 116 # Log startup
Note: See TracChangeset
for help on using the changeset viewer.