Changeset 4884
- Timestamp:
- Apr 15, 2021 10:22:56 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIctrlGUI.py
r4873 r4884 722 722 elif self.OKcontrol and previousInvalid: 723 723 self.OKcontrol(True) 724 # always store the result 725 if self.CIFinput and '2' in platform.python_version_tuple()[0]: # CIF/Py2 make results ASCII 726 self.result[self.key] = val.encode('ascii','replace') 727 else: 728 self.result[self.key] = val 729 log.LogVarChange(self.result,self.key) 724 self._SaveStringValue() # always store the result 730 725 731 726 def _GetStringValue(self,event): -
trunk/exports/G2export_CIF.py
r4883 r4884 60 60 import GSASIImapvars as G2mv 61 61 import GSASIIElem as G2el 62 import GSASIIpy3 as G2py3 62 63 63 64 DEBUG = False #True to skip printing of reflection/powder profile lists 64 65 65 66 CIFdic = None 67 68 cellNames = ['length_a','length_b','length_c', 69 'angle_alpha','angle_beta ','angle_gamma', 70 'volume'] 71 66 72 67 73 # Refactored over here to allow access by GSASIIscriptable.py … … 695 701 return ('?',None) 696 702 703 def ShowHstrainCells(self,phasenam,datablockidDict): 704 '''Displays the unit cell parameters for phases where Dij values create 705 mutiple sets of lattice parameters. At present there is no way defined for this in 706 CIF, so local data names are used. 707 ''' 708 phasedict = self.Phases[phasenam] # pointer to current phase info 709 Tlist = {} # histname & T values used for cell w/o Hstrain 710 DijTlist = {} # hId & T values used for cell w/Hstrain 711 # scan over histograms used in this phase 712 for h in phasedict['Histograms']: 713 if not phasedict['Histograms'][h]['Use']: continue 714 if np.any(abs(np.array(phasedict['Histograms'][h]['HStrain'][0])) > 1e-8): 715 DijTlist[h] = self.Histograms[h]['Sample Parameters']['Temperature'] 716 else: 717 Tlist[h] = self.Histograms[h]['Sample Parameters']['Temperature'] 718 if len(DijTlist) == 0: return 719 if len(Tlist) + len(DijTlist) < 2: return 720 SGData = phasedict['General']['SGData'] 721 for i in range(len(G2py3.cellGUIlist)): 722 if SGData['SGLaue'] in G2py3.cellGUIlist[i][0]: 723 terms = G2py3.cellGUIlist[i][5] + [6] 724 break 725 else: 726 print('ShowHstrainCells error: Laue class not found',SGData['SGLaue']) 727 terms = list(range(7)) 728 729 WriteCIFitem(self.fp, '\n# cell parameters generated by hydrostatic strain') 730 WriteCIFitem(self.fp, 'loop_') 731 WriteCIFitem(self.fp, '\t _gsas_measurement_temperature') 732 for i in terms: 733 WriteCIFitem(self.fp, '\t _gsas_cell_'+cellNames[i]) 734 WriteCIFitem(self.fp, '\t _gsas_cell_histogram_blockid') 735 for h,T in Tlist.items(): 736 pId = phasedict['pId'] 737 hId = self.Histograms[h]['hId'] 738 cellList,cellSig = G2strIO.getCellSU(pId,hId, 739 phasedict['General']['SGData'], 740 self.parmDict, 741 self.OverallParms['Covariance']) 742 line = ' ' + PutInCol(G2mth.ValEsd(T,-1.),6) 743 for i in terms: 744 line += PutInCol(G2mth.ValEsd(cellList[i],cellSig[i]),12) 745 line += ' ' + datablockidDict[h] 746 WriteCIFitem(self.fp, line) 747 for h,T in DijTlist.items(): 748 pId = phasedict['pId'] 749 hId = self.Histograms[h]['hId'] 750 cellList,cellSig = G2strIO.getCellSU(pId,hId, 751 phasedict['General']['SGData'], 752 self.parmDict, 753 self.OverallParms['Covariance']) 754 line = ' ' + PutInCol(G2mth.ValEsd(T,-1.),6) 755 for i in terms: 756 line += PutInCol(G2mth.ValEsd(cellList[i],cellSig[i]),12) 757 line += ' ' + datablockidDict[h] 758 WriteCIFitem(self.fp, line) 759 697 760 def _Exporter(self,event=None,phaseOnly=None,histOnly=None,IncludeOnlyHist=None): 698 761 '''Basic code to export a CIF. Export can be full or simple, as set by 699 762 phaseOnly and histOnly which skips distances & angles, etc. 700 763 701 702 703 764 :param bool phaseOnly: used to export only one phase 765 :param bool histOnly: used to export only one histogram 766 :param bool IncludeOnlyHist: used for a full CIF that includes only one of the 704 767 histograms (from a sequential fit) #TODO: needs lots of work! 705 768 ''' … … 1259 1322 1260 1323 defsigL = 3*[-0.00001] + 3*[-0.001] + [-0.01] # significance to use when no sigma 1261 names = ['length_a','length_b','length_c',1262 'angle_alpha','angle_beta ','angle_gamma',1263 'volume']1264 1324 prevsig = 0 1265 for lbl,defsig,val,sig in zip( names,defsigL,cellList,cellSig):1325 for lbl,defsig,val,sig in zip(cellNames,defsigL,cellList,cellSig): 1266 1326 if sig: 1267 1327 txt = G2mth.ValEsd(val,sig) … … 2142 2202 if phaseOnly: #====Phase only CIF ================================ 2143 2203 print('Writing CIF output to file '+self.filename) 2144 #self.OpenFile()2145 2204 oneblock = True 2146 2205 self.quickmode = True … … 2151 2210 # report the phase info 2152 2211 WritePhaseInfo(phaseOnly) 2153 #self.CloseFile()2154 2212 return 2155 2213 elif histOnly: #====Histogram only CIF ================================ 2156 2214 print('Writing CIF output to file '+self.filename) 2157 #self.OpenFile()2158 2215 hist = histOnly 2159 2216 #histname = histOnly.replace(' ','') … … 2312 2369 #====================================================================== 2313 2370 print('Writing CIF output to file '+self.filename+"...") 2314 #self.OpenFile()2315 2371 if self.currentExportType == 'single' or self.currentExportType == 'powder': 2316 2372 #======Data only CIF (powder/xtal) ==================================== … … 2454 2510 if PP: 2455 2511 WriteCIFitem(self.fp, '_pd_proc_ls_profile_function',PP) 2512 self.ShowHstrainCells(phasenam,datablockidDict) 2456 2513 2457 2514 #============================================================
Note: See TracChangeset
for help on using the changeset viewer.