Changeset 989
- Timestamp:
- Jul 13, 2013 10:21:12 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIimgGUI.py
r923 r989 182 182 Data['range'] = oldData['range'] 183 183 Data['size'] = oldData['size'] 184 Data['GonioAngles'] = oldData ['GonioAngles']184 Data['GonioAngles'] = oldData.get('GonioAngles', [0.,0.,0.]) 185 185 Data['ring'] = [] 186 186 Data['rings'] = [] -
trunk/GSASIIlattice.py
r961 r989 4 4 --------------------------- 5 5 6 Perform lattice-related computations''' 6 Perform lattice-related computations 7 8 Note that *g* is the reciprocal lattice tensor, and *G* is its inverse, 9 :math:`G = g^{-1}`, where 10 11 .. math:: 12 13 G = \\left( \\begin{matrix} 14 a^2 & a b\\cos\gamma & a c\\cos\\beta \\\\ 15 a b\\cos\\gamma & b^2 & b c \cos\\alpha \\\\ 16 a c\\cos\\beta & b c \\cos\\alpha & c^2 17 \\end{matrix}\\right) 18 19 The "*A* tensor" terms are defined as 20 :math:`A = (\\begin{matrix} G_{11} & G_{22} & G_{33} & 2G_{12} & 2G_{13} & 2G_{23}\\end{matrix})` and *A* can be used in this fashion: 21 :math:`d^* = \sqrt {A_1 h^2 + A_2 k^2 + A_3 l^2 + A_4 hk + A_5 hl + A_6 kl}`, where 22 *d* is the d-spacing, and :math:`d^*` is the reciprocal lattice spacing, 23 :math:`Q = 2 \\pi d^* = 2 \\pi / d` 24 ''' 7 25 ########### SVN repository information ################### 8 26 # $Date$ … … 90 108 91 109 def A2Gmat(A,inverse=True): 92 """Fill real & reciprocal metric tensor (G) from A 110 """Fill real & reciprocal metric tensor (G) from A. 93 111 94 112 :param A: reciprocal metric tensor elements as [G11,G22,G33,2*G12,2*G13,2*G23] -
trunk/GSASIImapvars.py
r903 r989 906 906 parameter names. 907 907 908 :param dict dMdv: a dict containing derivatives for dependent parameter computed from909 derivDict908 :param list dMdv: a Jacobian, as a list of np.array containing derivatives for dependent 909 parameter computed from derivDict 910 910 911 911 ''' -
trunk/GSASIImath.py
r984 r989 1271 1271 ''' 1272 1272 # Note: this routine is Python 3 compatible -- I think 1273 if esd != 0: 1273 if math.isnan(value): # invalid value, bail out 1274 return '?' 1275 if math.isnan(esd): # invalid esd, treat as zero 1276 esd = 0 1277 esdoff = 5 1278 elif esd != 0: 1274 1279 # transform the esd to a one or two digit integer 1275 1280 l = math.log10(abs(esd)) % 1 … … 1300 1305 extra = -math.log10(abs(value)) 1301 1306 if extra > 0: extra += 1 1302 print 'fmt=',"{:."+str(max(0,esdoff+int(extra)))+"f}"1303 1307 out = ("{:."+str(max(0,esdoff+int(extra)))+"f}").format(value) # format the value 1304 1308 if esd > 0: -
trunk/GSASIIpath.py
r981 r989 81 81 82 82 :returns: None if svn is not found or an absolute path to the subversion 83 executable file.83 executable file. 84 84 ''' 85 85 def is_exe(fpath): … … 196 196 '''This performs an update of the files in a local directory from a server. 197 197 198 :param fpath: path to repository dictionary, defaults to directory where198 :param str fpath: path to repository dictionary, defaults to directory where 199 199 the current file is located 200 200 :param version: the number of the version to be loaded. Used only 201 cast as a string, but should be an integer or something that corresponds to a 202 string representation of an integer value when cast. A value of None (default) 203 causes the latest version on the server to be used. 201 204 :returns: A dictionary with the files that have been changed/added and 202 a code describing how they have been updated (see changetype) ro205 a code describing how they have been updated (see changetype) or 203 206 None if there is a subversion error (likely because the path is 204 207 not a repository or svn is not found) 205 206 208 ''' 207 209 import subprocess -
trunk/GSASIIstrIO.py
r981 r989 1019 1019 1020 1020 def cellFill(pfx,SGData,parmDict,sigDict): 1021 'needs a doc string' 1021 '''Returns the filled-out reciprocal cell (A) terms and their uncertainties 1022 from the parameter and sig dictionaries. 1023 1024 :param str pfx: parameter prefix ("n::", where n is a phase number) 1025 :param dict SGdata: a symmetry object 1026 :param dict parmDict: a dictionary of parameters 1027 :param dict sigDict: a dictionary of uncertainties on parameters 1028 1029 :returns: A,sigA where each is a list of six terms with the A terms 1030 ''' 1022 1031 if SGData['SGLaue'] in ['-1',]: 1023 1032 A = [parmDict[pfx+'A0'],parmDict[pfx+'A1'],parmDict[pfx+'A2'], 1024 1033 parmDict[pfx+'A3'],parmDict[pfx+'A4'],parmDict[pfx+'A5']] 1025 sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'],1026 sigDict[pfx+'A3'],sigDict[pfx+'A4'],sigDict[pfx+'A5']]1027 1034 elif SGData['SGLaue'] in ['2/m',]: 1028 1035 if SGData['SGUniq'] == 'a': 1029 1036 A = [parmDict[pfx+'A0'],parmDict[pfx+'A1'],parmDict[pfx+'A2'], 1030 1037 parmDict[pfx+'A3'],0,0] 1031 sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'],1032 sigDict[pfx+'A3'],0,0]1033 1038 elif SGData['SGUniq'] == 'b': 1034 1039 A = [parmDict[pfx+'A0'],parmDict[pfx+'A1'],parmDict[pfx+'A2'], 1035 1040 0,parmDict[pfx+'A4'],0] 1036 sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'],1037 0,sigDict[pfx+'A4'],0]1038 1041 else: 1039 1042 A = [parmDict[pfx+'A0'],parmDict[pfx+'A1'],parmDict[pfx+'A2'], 1040 1043 0,0,parmDict[pfx+'A5']] 1041 sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'],1042 0,0,sigDict[pfx+'A5']]1043 1044 elif SGData['SGLaue'] in ['mmm',]: 1044 1045 A = [parmDict[pfx+'A0'],parmDict[pfx+'A1'],parmDict[pfx+'A2'],0,0,0] 1045 sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'],0,0,0]1046 1046 elif SGData['SGLaue'] in ['4/m','4/mmm']: 1047 1047 A = [parmDict[pfx+'A0'],parmDict[pfx+'A0'],parmDict[pfx+'A2'],0,0,0] 1048 sigA = [sigDict[pfx+'A0'],0,sigDict[pfx+'A2'],0,0,0]1049 1048 elif SGData['SGLaue'] in ['6/m','6/mmm','3m1', '31m', '3']: 1050 1049 A = [parmDict[pfx+'A0'],parmDict[pfx+'A0'],parmDict[pfx+'A2'], 1051 1050 parmDict[pfx+'A0'],0,0] 1052 sigA = [sigDict[pfx+'A0'],0,sigDict[pfx+'A2'],0,0,0]1053 1051 elif SGData['SGLaue'] in ['3R', '3mR']: 1054 1052 A = [parmDict[pfx+'A0'],parmDict[pfx+'A0'],parmDict[pfx+'A0'], 1055 1053 parmDict[pfx+'A3'],parmDict[pfx+'A3'],parmDict[pfx+'A3']] 1056 sigA = [sigDict[pfx+'A0'],0,0,sigDict[pfx+'A3'],0,0]1057 1054 elif SGData['SGLaue'] in ['m3m','m3']: 1058 1055 A = [parmDict[pfx+'A0'],parmDict[pfx+'A0'],parmDict[pfx+'A0'],0,0,0] 1059 sigA = [sigDict[pfx+'A0'],0,0,0,0,0] 1056 1057 try: 1058 if SGData['SGLaue'] in ['-1',]: 1059 sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'], 1060 sigDict[pfx+'A3'],sigDict[pfx+'A4'],sigDict[pfx+'A5']] 1061 elif SGData['SGLaue'] in ['2/m',]: 1062 if SGData['SGUniq'] == 'a': 1063 sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'], 1064 sigDict[pfx+'A3'],0,0] 1065 elif SGData['SGUniq'] == 'b': 1066 sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'], 1067 0,sigDict[pfx+'A4'],0] 1068 else: 1069 sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'], 1070 0,0,sigDict[pfx+'A5']] 1071 elif SGData['SGLaue'] in ['mmm',]: 1072 sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'],0,0,0] 1073 elif SGData['SGLaue'] in ['4/m','4/mmm']: 1074 sigA = [sigDict[pfx+'A0'],0,sigDict[pfx+'A2'],0,0,0] 1075 elif SGData['SGLaue'] in ['6/m','6/mmm','3m1', '31m', '3']: 1076 sigA = [sigDict[pfx+'A0'],0,sigDict[pfx+'A2'],0,0,0] 1077 elif SGData['SGLaue'] in ['3R', '3mR']: 1078 sigA = [sigDict[pfx+'A0'],0,0,sigDict[pfx+'A3'],0,0] 1079 elif SGData['SGLaue'] in ['m3m','m3']: 1080 sigA = [sigDict[pfx+'A0'],0,0,0,0,0] 1081 except KeyError: 1082 sigA = [0,0,0,0,0,0] 1083 1060 1084 return A,sigA 1061 1085 -
trunk/GSASIIstrMath.py
r961 r989 1623 1623 ApplyRBModelDervs(dFdvDict,parmDict,rigidbodyDict,Phase) 1624 1624 dMdvh = np.zeros((len(varylist),len(refList))) 1625 dependentVars = G2mv.GetDependentVars() 1626 depDerivDict = {} 1627 for j in dependentVars: 1628 depDerivDict[j] = np.zeros(shape=(len(refList))) 1625 1629 if calcControls['F**2']: 1626 1630 for iref,ref in enumerate(refList): … … 1632 1636 if var in dFdvDict: 1633 1637 dMdvh[j][iref] = w*dFdvDict[var][iref]*parmDict[phfx+'Scale']*dervCor 1638 for var in dependentVars: 1639 if var in dFdvDict: 1640 depDerivDict[var][iref] = w*dFdvDict[var][iref]*parmDict[phfx+'Scale']*dervCor 1634 1641 if phfx+'Scale' in varylist: 1635 1642 dMdvh[varylist.index(phfx+'Scale')][iref] = w*ref[9]*dervCor 1643 elif phfx+'Scale' in dependentVars: 1644 depDerivDict[phfx+'Scale'][iref] = w*ref[9]*dervCor 1636 1645 for item in ['Ep','Es','Eg']: 1637 1646 if phfx+item in varylist: 1638 1647 dMdvh[varylist.index(phfx+item)][iref] = w*dervDict[phfx+item]*parmDict[phfx+'Scale'] 1648 elif phfx+item in dependentVars: 1649 depDerivDict[phfx+item][iref] = w*dervDict[phfx+item]*parmDict[phfx+'Scale'] 1639 1650 for item in ['BabA','BabU']: 1640 1651 if phfx+item in varylist: 1641 1652 dMdvh[varylist.index(phfx+item)][iref] = w*dervCor*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale'] 1653 elif phfx+item in dependentVars: 1654 depDerivDict[phfx+item][iref] = w*dervCor*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale'] 1642 1655 else: 1643 1656 for iref,ref in enumerate(refList): … … 1651 1664 if var in dFdvDict: 1652 1665 dMdvh[j][iref] = w*dFdvDict[var][iref]*dervCor*parmDict[phfx+'Scale'] 1666 for var in dependentVars: 1667 if var in dFdvDict: 1668 depDerivDict[var][iref] = w*dFdvDict[var][iref]*dervCor*parmDict[phfx+'Scale'] 1653 1669 if phfx+'Scale' in varylist: 1654 dMdvh[varylist.index(phfx+'Scale')][iref] = w*ref[9]*dervCor 1670 dMdvh[varylist.index(phfx+'Scale')][iref] = w*ref[9]*dervCor 1671 elif phfx+'Scale' in dependentVars: 1672 depDerivDict[phfx+'Scale'][iref] = w*ref[9]*dervCor 1655 1673 for item in ['Ep','Es','Eg']: 1656 1674 if phfx+item in varylist: 1657 1675 dMdvh[varylist.index(phfx+item)][iref] = w*dervDict[phfx+item]*parmDict[phfx+'Scale'] 1676 elif phfx+item in dependentVars: 1677 depDerivDict[phfx+item][iref] = w*dervDict[phfx+item]*parmDict[phfx+'Scale'] 1658 1678 for item in ['BabA','BabU']: 1659 1679 if phfx+item in varylist: 1660 1680 dMdvh[varylist.index(phfx+item)][iref] = w*dervCor*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale'] 1681 elif phfx+item in dependentVars: 1682 depDerivDict[phfx+item][iref] = w*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale']*dervCor 1683 # now process derivatives in constraints 1684 G2mv.Dict2Deriv(varylist,depDerivDict,dMdvh) 1661 1685 else: 1662 1686 continue #skip non-histogram entries … … 1728 1752 ApplyRBModelDervs(dFdvDict,parmDict,rigidbodyDict,Phase) 1729 1753 dMdvh = np.zeros((len(varylist),len(refList))) 1754 dependentVars = G2mv.GetDependentVars() 1755 depDerivDict = {} 1756 for j in dependentVars: 1757 depDerivDict[j] = np.zeros(shape=(len(refList))) 1730 1758 wdf = np.zeros(len(refList)) 1731 1759 if calcControls['F**2']: … … 1739 1767 if var in dFdvDict: 1740 1768 dMdvh[j][iref] = w*dFdvDict[var][iref]*dervCor*parmDict[phfx+'Scale'] 1769 for var in dependentVars: 1770 if var in dFdvDict: 1771 depDerivDict[var][iref] = w*dFdvDict[var][iref]*dervCor*parmDict[phfx+'Scale'] 1741 1772 if phfx+'Scale' in varylist: 1742 1773 dMdvh[varylist.index(phfx+'Scale')][iref] = w*ref[9]*dervCor 1774 elif phfx+'Scale' in dependentVars: 1775 depDerivDict[phfx+'Scale'][iref] = w*ref[9]*dervCor 1743 1776 for item in ['Ep','Es','Eg']: 1744 1777 if phfx+item in varylist: 1745 1778 dMdvh[varylist.index(phfx+item)][iref] = w*dervDict[phfx+item]*parmDict[phfx+'Scale'] 1779 elif phfx+item in dependentVars: 1780 depDerivDict[phfx+item][iref] = w*dervDict[phfx+item]*parmDict[phfx+'Scale'] 1746 1781 for item in ['BabA','BabU']: 1747 1782 if phfx+item in varylist: 1748 1783 dMdvh[varylist.index(phfx+item)][iref] = w*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale']*dervCor 1784 elif phfx+item in dependentVars: 1785 depDerivDict[phfx+item][iref] = w*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale']*dervCor 1749 1786 else: 1750 1787 for iref,ref in enumerate(refList): … … 1759 1796 if var in dFdvDict: 1760 1797 dMdvh[j][iref] = w*dFdvDict[var][iref]*dervCor*parmDict[phfx+'Scale'] 1798 for var in dependentVars: 1799 if var in dFdvDict: 1800 depDerivDict[var][iref] = w*dFdvDict[var][iref]*dervCor*parmDict[phfx+'Scale'] 1761 1801 if phfx+'Scale' in varylist: 1762 dMdvh[varylist.index(phfx+'Scale')][iref] = w*ref[9]*dervCor 1802 dMdvh[varylist.index(phfx+'Scale')][iref] = w*ref[9]*dervCor 1803 elif phfx+'Scale' in dependentVars: 1804 depDerivDict[phfx+'Scale'][iref] = w*ref[9]*dervCor 1763 1805 for item in ['Ep','Es','Eg']: 1764 1806 if phfx+item in varylist: 1765 1807 dMdvh[varylist.index(phfx+item)][iref] = w*dervDict[phfx+item]*parmDict[phfx+'Scale'] 1808 elif phfx+item in dependentVars: 1809 depDerivDict[phfx+item][iref] = w*dervDict[phfx+item]*parmDict[phfx+'Scale'] 1766 1810 for item in ['BabA','BabU']: 1767 1811 if phfx+item in varylist: 1768 1812 dMdvh[varylist.index(phfx+item)][iref] = w*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale']*dervCor 1769 1813 elif phfx+item in dependentVars: 1814 depDerivDict[phfx+item][iref] = w*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale']*dervCor 1815 # now process derivatives in constraints 1816 G2mv.Dict2Deriv(varylist,depDerivDict,dMdvh) 1817 1770 1818 if dlg: 1771 1819 dlg.Update(Histogram['wR'],newmsg='Hessian for histogram %d Rw=%8.3f%s'%(hId,Histogram['wR'],'%'))[0] -
trunk/exports/G2cif.py
r981 r989 9 9 import GSASIIgrid as G2gd 10 10 import GSASIIstrIO as G2stIO 11 #reload(G2stIO) 11 12 #import GSASIImapvars as G2mv 12 13 import GSASIImath as G2mth 14 reload(G2mth) 13 15 import GSASIIlattice as G2lat 14 16 import GSASIIspc as G2spg 15 17 #reload(G2spg) 16 reload(G2mth)17 18 18 19 def getCallerDocString(): # for development … … 585 586 refprx = '_refln_' # normal 586 587 587 print histblk.keys()588 # for key in histblk:589 # print key590 print inst591 print self.parmDict.keys()592 print self.sigDict.keys()593 588 WriteCIFitem('\n# SCATTERING FACTOR INFO') 594 589 if 'Lam1' in inst: … … 618 613 WriteCIFitem('_diffrn_radiation_wavelength',G2mth.ValEsd(lam1,slam1)) 619 614 620 raise Exception, "testing"621 615 622 616 if not oneblock: … … 629 623 '\n\t_pd_phase_block_id' + 630 624 '\n\t_pd_phase_mass_%') 625 wtFrSum = 0. 631 626 for phasenam in phasebyhistDict.get(histlbl): 632 pass 633 634 WriteCIFitem('_pd_proc_ls_prof_R_factor','?') 635 WriteCIFitem('_pd_proc_ls_prof_wR_factor','?') 636 WriteCIFitem('_pd_proc_ls_prof_wR_expected','?') 637 WriteCIFitem('_refine_ls_R_Fsqd_factor','?') 627 hapData = self.Phases[phasenam]['Histograms'][histlbl] 628 General = self.Phases[phasenam]['General'] 629 wtFrSum += hapData['Scale'][0]*General['Mass'] 630 631 for phasenam in phasebyhistDict.get(histlbl): 632 hapData = self.Phases[phasenam]['Histograms'][histlbl] 633 General = self.Phases[phasenam]['General'] 634 wtFr = hapData['Scale'][0]*General['Mass']/wtFrSum 635 pfx = str(self.Phases[phasenam]['pId'])+':'+str(hId)+':' 636 if pfx+'Scale' in self.sigDict: 637 sig = self.sigDict[pfx+'Scale']*wtFr/hapData['Scale'][0] 638 else: 639 sig = -0.0001 640 WriteCIFitem( 641 ' '+ 642 str(self.Phases[phasenam]['pId']) + 643 ' '+datablockidDict[phasenam]+ 644 ' '+G2mth.ValEsd(wtFr,sig) 645 ) 646 647 # this will need help from Bob 648 # WriteCIFitem('_pd_proc_ls_prof_R_factor','?') 649 # WriteCIFitem('_pd_proc_ls_prof_wR_factor','?') 650 # WriteCIFitem('_pd_proc_ls_prof_wR_expected','?') 651 # WriteCIFitem('_refine_ls_R_Fsqd_factor','?') 652 653 phasenam = self.Phases.keys()[0] 654 for key in self.Phases[phasenam]['Histograms']: 655 print key 656 print '------------' 657 print self.Phases[phasenam]['Histograms'][key] 658 raise Exception, "testing" 659 print histblk.keys() 660 for key in histblk: 661 print key,histblk[key] 662 print inst 663 #print self.parmDict.keys() 664 #print self.sigDict.keys() 638 665 639 666 #WriteCIFitem('_pd_meas_2theta_fixed',text) … … 1050 1077 WriteCIFitem('_pd_block_id',datablockidDict[hist]) 1051 1078 WritePowderTemplate() 1052 WritePowderData( key1)1079 WritePowderData(hist) 1053 1080 elif hist.startswith("HKLF"): 1054 1081 WriteCIFitem('\ndata_'+self.CIFname+"_sx_"+str(i)) … … 1058 1085 WriteCIFitem('_pd_block_id',datablockidDict[hist]) 1059 1086 WriteSnglXtalTemplate() 1060 WriteSingleXtalData( key1)1087 WriteSingleXtalData(hist) 1061 1088 1062 1089 WriteCIFitem('#--' + 15*'eof--' + '#')
Note: See TracChangeset
for help on using the changeset viewer.