Changeset 3016
- Timestamp:
- Aug 18, 2017 12:12:42 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIscriptable.py
r3015 r3016 1097 1097 1098 1098 WARNING it does not check the constraint is well-constructed""" 1099 constrs = self ['Constraints']['data']1099 constrs = self.data['Constraints']['data'] 1100 1100 if 'Global' not in constrs: 1101 1101 constrs['Global'] = [] … … 1139 1139 phaseObj = phase 1140 1140 phase = G2obj.PhaseRanIdLookup[phase.ranId] 1141 elif phase in self ['Phases']:1141 elif phase in self.data['Phases']: 1142 1142 phaseObj = self.phase(phase) 1143 1143 phaseRanId = phaseObj.ranId … … 1254 1254 @property 1255 1255 def name(self): 1256 return self ['data'][-1]1256 return self.data['data'][-1] 1257 1257 1258 1258 @property 1259 1259 def ranId(self): 1260 return self ['data'][0]['ranId']1260 return self.data['data'][0]['ranId'] 1261 1261 1262 1262 @property 1263 1263 def residuals(self): 1264 data = self ['data'][0]1264 data = self.data['data'][0] 1265 1265 return {key: data[key] 1266 1266 for key in ['R', 'Rb', 'wR', 'wRb', 'wRmin']} 1267 1267 1268 # TODO Figure out G2obj.HistRanIdLookup reload1269 1268 @property 1270 1269 def id(self): 1271 return G2obj.HistRanIdLookup[self.ranId]1270 return self.data['data'][0]['hId'] 1272 1271 1273 1272 def fit_fixed_points(self): … … 1291 1290 return dataType, instDict, insVary 1292 1291 1293 bgrnd = self ['Background']1292 bgrnd = self.data['Background'] 1294 1293 1295 1294 # Need our fixed points in order … … 1298 1297 Y = [y for x, y in bgrnd[1]['FixedPoints']] 1299 1298 1300 limits = self ['Limits'][1]1299 limits = self.data['Limits'][1] 1301 1300 if X[0] > limits[0]: 1302 1301 X = [limits[0]] + X … … 1308 1307 # Some simple lookups 1309 1308 controls = self.proj['Controls']['data'] 1310 inst, inst2 = self ['Instrument Parameters']1311 pwddata = self ['data'][1]1309 inst, inst2 = self.data['Instrument Parameters'] 1310 pwddata = self.data['data'][1] 1312 1311 1313 1312 # Construct the data for background fitting … … 1342 1341 1343 1342 def y_calc(self): 1344 return self ['data'][1][3]1343 return self.data['data'][1][3] 1345 1344 1346 1345 def plot(self, Yobs=True, Ycalc=True, Background=True, Residual=True): 1347 1346 try: 1348 1347 import matplotlib.pyplot as plt 1349 data = self ['data'][1]1348 data = self.data['data'][1] 1350 1349 if Yobs: 1351 1350 plt.plot(data[0], data[1], label='Yobs') … … 1424 1423 if do_fit_fixed_points: 1425 1424 # Background won't be fit if refinement flag not set 1426 orig = self ['Background'][0][1]1427 self ['Background'][0][1] = True1425 orig = self.data['Background'][0][1] 1426 self.data['Background'][0][1] = True 1428 1427 self.fit_fixed_points() 1429 1428 # Restore the previous value 1430 self ['Background'][0][1] = orig1429 self.data['Background'][0][1] = orig 1431 1430 1432 1431 def clear_refinements(self, refs): … … 1527 1526 @property 1528 1527 def id(self): 1529 return G2obj.PhaseRanIdLookup[self.ranId]1528 return self.data['pId'] 1530 1529 1531 1530 def get_cell(self): … … 1533 1532 'length_a', 'length_b', 'length_c', 'angle_alpha', 'angle_beta', 'angle_gamma', 'volume' 1534 1533 1535 :returns: a dict""" 1536 cell = self['General']['Cell'] 1534 :returns: a dict 1535 1536 .. seealso:: 1537 :func:`~G2Phase.get_cell_and_esd` 1538 """ 1539 cell = self.data['General']['Cell'] 1537 1540 return {'length_a': cell[1], 'length_b': cell[2], 'length_c': cell[3], 1538 1541 'angle_alpha': cell[4], 'angle_beta': cell[5], 'angle_gamma': cell[6], 1539 1542 'volume': cell[7]} 1543 1544 def get_cell_and_esd(self): 1545 """ 1546 Returns a pair of dictionaries, the first representing the unit cell, the second 1547 representing the estimated standard deviations of the unit cell. 1548 1549 :returns: a tuple of two dictionaries 1550 .. seealso:: 1551 :func:`~G2Phase.get_cell` 1552 """ 1553 # translated from GSASIIstrIO.ExportBaseclass.GetCell 1554 import GSASIIstrIO as G2stIO 1555 import GSASIIlattice as G2lat 1556 import GSASIImapvars as G2mv 1557 try: 1558 pfx = str(self.id) + '::' 1559 sgdata = self['General']['SGData'] 1560 covDict = self.proj['Covariance']['data'] 1561 1562 parmDict = dict(zip(covDict.get('varyList',[]), 1563 covDict.get('variables',[]))) 1564 sigDict = dict(zip(covDict.get('varyList',[]), 1565 covDict.get('sig',[]))) 1566 1567 if covDict.get('covMatrix') is not None: 1568 sigDict.update(G2mv.ComputeDepESD(covDict['covMatrix'], 1569 covDict['varyList'], 1570 parmDict)) 1571 1572 A, sigA = G2stIO.cellFill(pfx, sgdata, parmDict, sigDict) 1573 cellSig = G2stIO.getCellEsd(pfx, sgdata, A, self.proj['Covariance']['data']) 1574 cellList = G2lat.A2cell(A) + (G2lat.calc_V(A),) 1575 cellDict, cellSigDict = {}, {} 1576 for i, key in enumerate(['length_a', 'length_b', 'length_c', 1577 'angle_alpha', 'angle_beta', 'angle_gamma', 1578 'volume']): 1579 cellDict[key] = cellList[i] 1580 cellSigDict[key] = cellSig[i] 1581 return cellDict, cellSigDict 1582 except KeyError: 1583 cell = self.get_cell() 1584 return cell, {key: 0.0 for key in cell} 1540 1585 1541 1586 def export_CIF(self, outputname, quickmode=True): … … 1556 1601 for c in CIFname.replace(' ', '_')]) 1557 1602 try: 1558 author = self.proj['Controls'] .get('Author','').strip()1603 author = self.proj['Controls']['data'].get('Author','').strip() 1559 1604 except KeyError: 1560 1605 pass 1561 1606 oneblock = True 1562 1607 1563 covDict = self.proj['Covariance'] 1608 covDict = self.proj['Covariance']['data'] 1564 1609 parmDict = dict(zip(covDict.get('varyList',[]), 1565 1610 covDict.get('variables',[]))) … … 1588 1633 1589 1634 cif.WriteCIFitem(fp, '_symmetry_cell_setting', 1590 self ['General']['SGData']['SGSys'])1591 1592 spacegroup = self ['General']['SGData']['SpGrp'].strip()1635 self.data['General']['SGData']['SGSys']) 1636 1637 spacegroup = self.data['General']['SGData']['SpGrp'].strip() 1593 1638 # regularize capitalization and remove trailing H/R 1594 1639 spacegroup = spacegroup[0].upper() + spacegroup[1:].lower().rstrip('rh ') … … 1597 1642 # generate symmetry operations including centering and center of symmetry 1598 1643 SymOpList, offsetList, symOpList, G2oprList, G2opcodes = G2spc.AllOps( 1599 self ['General']['SGData'])1644 self.data['General']['SGData']) 1600 1645 cif.WriteCIFitem(fp, 'loop_\n _space_group_symop_id\n _space_group_symop_operation_xyz') 1601 1646 for i, op in enumerate(SymOpList,start=1): … … 1605 1650 1606 1651 # report atom params 1607 if self ['General']['Type'] in ['nuclear','macromolecular']: #this needs macromolecular variant, etc!1652 if self.data['General']['Type'] in ['nuclear','macromolecular']: #this needs macromolecular variant, etc! 1608 1653 cif.WriteAtomsNuclear(fp, self.data, self.name, parmDict, sigDict, []) 1609 1654 # self._WriteAtomsNuclear(fp, parmDict, sigDict) 1610 1655 else: 1611 raise Exception,"no export for "+str(self ['General']['Type'])+" coordinates implemented"1656 raise Exception,"no export for "+str(self.data['General']['Type'])+" coordinates implemented" 1612 1657 # report cell contents 1613 1658 cif.WriteComposition(fp, self.data, self.name, parmDict) 1614 if not quickmode and self ['General']['Type'] == 'nuclear': # report distances and angles1659 if not quickmode and self.data['General']['Type'] == 'nuclear': # report distances and angles 1615 1660 # WriteDistances(fp,self.name,SymOpList,offsetList,symOpList,G2oprList) 1616 1661 raise NotImplementedError("only quickmode currently supported") 1617 if 'Map' in self ['General'] and 'minmax' in self['General']['Map']:1662 if 'Map' in self.data['General'] and 'minmax' in self.data['General']['Map']: 1618 1663 cif.WriteCIFitem(fp,'\n# Difference density results') 1619 MinMax = self ['General']['Map']['minmax']1664 MinMax = self.data['General']['Map']['minmax'] 1620 1665 cif.WriteCIFitem(fp,'_refine_diff_density_max',G2mth.ValEsd(MinMax[0],-0.009)) 1621 1666 cif.WriteCIFitem(fp,'_refine_diff_density_min',G2mth.ValEsd(MinMax[1],-0.009)) … … 1685 1730 """ 1686 1731 if histograms == 'all': 1687 histograms = self ['Histograms'].values()1732 histograms = self.data['Histograms'].values() 1688 1733 else: 1689 histograms = [self ['Histograms'][h.name] for h in histograms]1734 histograms = [self.data['Histograms'][h.name] for h in histograms] 1690 1735 1691 1736 for key, val in refs.items(): … … 1761 1806 """ 1762 1807 if histograms == 'all': 1763 histograms = self ['Histograms'].values()1808 histograms = self.data['Histograms'].values() 1764 1809 else: 1765 histograms = [self ['Histograms'][h.name] for h in histograms]1810 histograms = [self.data['Histograms'][h.name] for h in histograms] 1766 1811 1767 1812 for key, val in refs.items():
Note: See TracChangeset
for help on using the changeset viewer.