Changeset e89aed5 in sasview for src/sas/sasgui/perspectives/fitting/pagestate.py
- Timestamp:
- Oct 6, 2016 3:47:28 PM (8 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, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 1dbdb83
- Parents:
- ef3e09b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/pagestate.py
ra95ae9a re89aed5 860 860 :param file: .fitv file 861 861 :param node: node of a XML document to read from 862 863 862 """ 864 863 if file is not None: … … 867 866 raise RuntimeError, msg 868 867 869 if node.get('version') and node.get('version') == '1.0':868 if node.get('version') and node.get('version') == '1.0': 870 869 871 870 # Get file name … … 1272 1271 1273 1272 :param entry: XML node to read from 1274 1275 1273 :return: PageState object 1276 1274 """ … … 1281 1279 nodes = entry.xpath('ns:%s' % FITTING_NODE_NAME, 1282 1280 namespaces={'ns': CANSAS_NS}) 1283 if nodes != []:1281 if nodes: 1284 1282 # Create an empty state 1285 1283 state = PageState() … … 1291 1289 1292 1290 return state 1291 1292 def _parse_simfit_state(self, entry): 1293 """ 1294 Parses the saved data for a simultaneous fit 1295 :param entry: XML object to read from 1296 :return: XML object for a simultaneous fit or None 1297 """ 1298 nodes = entry.xpath('ns:%s' % FITTING_NODE_NAME, 1299 namespaces={'ns': CANSAS_NS}) 1300 if nodes: 1301 simfitstate = nodes[0].xpath('ns:simultaneous_fit', 1302 namespaces={'ns': CANSAS_NS}) 1303 if simfitstate: 1304 from simfitpage import SimFitPageState 1305 sim_fit_state = SimFitPageState() 1306 simfitstate_0 = simfitstate[0] 1307 all = simfitstate_0.xpath('ns:select_all', 1308 namespaces={'ns': CANSAS_NS}) 1309 atts = all[0].attrib 1310 checked = atts.get('checked') 1311 sim_fit_state.select_all = bool(checked) 1312 model_list = simfitstate_0.xpath('ns:model_list', 1313 namespaces={'ns': CANSAS_NS}) 1314 model_list_items = model_list[0].xpath('ns:model_list_item', 1315 namespaces={'ns': CANSAS_NS}) 1316 for model in model_list_items: 1317 attrs = model.attrib 1318 sim_fit_state.model_list.append(attrs) 1319 constraints = simfitstate_0.xpath('ns:constraints', 1320 namespaces={'ns': CANSAS_NS}) 1321 constraint_list = constraints[0].xpath('ns:constraint', 1322 namespaces={'ns': CANSAS_NS}) 1323 for constraint in constraint_list: 1324 attrs = constraint.attrib 1325 sim_fit_state.constraints_list.append(attrs) 1326 1327 return sim_fit_state 1328 else: 1329 return None 1293 1330 1294 1331 def _parse_save_state_entry(self, dom): … … 1552 1589 def _read_cansas(self, path): 1553 1590 """ 1554 Load data and P(r)information from a CanSAS XML file.1591 Load data and fitting information from a CanSAS XML file. 1555 1592 1556 1593 :param path: file path 1557 1558 1594 :return: Data1D object if a single SASentry was found, 1559 1595 or a list of Data1D objects if multiple entries were found, 1560 1596 or None of nothing was found 1561 1562 1597 :raise RuntimeError: when the file can't be opened 1563 1598 :raise ValueError: when the length of the data vectors are inconsistent 1564 1565 1599 """ 1566 1600 output = [] 1601 simfitstate = None 1567 1602 basename = os.path.basename(path) 1568 1603 root, extension = os.path.splitext(basename) … … 1584 1619 raise 1585 1620 fitstate = self._parse_state(entry) 1621 simfitstate = self._parse_simfit_state(entry) 1586 1622 1587 1623 # state could be None when .svs file is loaded … … 1591 1627 sas_entry.filename = fitstate.file 1592 1628 output.append(sas_entry) 1629 1593 1630 else: 1594 1631 self.call_back(format=ext) … … 1634 1671 datainfo=output[ind], format=ext) 1635 1672 self.state = state 1673 if simfitstate is not None: 1674 self.call_back(state=simfitstate) 1675 1636 1676 return output 1637 1677 except:
Note: See TracChangeset
for help on using the changeset viewer.